bumpversion revision 1.7
1#!/bin/sh 2# $NetBSD: bumpversion,v 1.7 1999/07/02 15:12:15 simonb Exp $ 3# 4# Copyright (c) 1993 Christopher G. Demetriou 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 3. All advertising materials mentioning features or use of this software 16# must display the following acknowledgement: 17# This product includes software developed by Christopher G. Demetriou. 18# 4. The name of the author may not be used to endorse or promote products 19# derived from this software without specific prior written permission 20# 21# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31# 32 33while : 34 do case "$1" in 35 # -c says to create new shlib_version files 36 -c) 37 create=TRUE 38 shift ;; 39 40 # -n sets 'do nothing mode' 41 -n) 42 donothing=TRUE 43 shift ;; 44 45 # -m says to bump major number, rather than minor number 46 -m) 47 bumpmajor=TRUE 48 shift ;; 49 50 *) 51 break ;; 52 esac 53done 54 55if [ $# = 0 ] ; then 56 echo "usage: $0 [-c] [-m] [-n] dir ..." 57 exit 2 58fi 59 60TMP=/tmp/bump$$ 61error=0 62 63trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 64 65for dir in $@ ; do 66 versf=$dir/shlib_version 67 68 if [ "X$create" != "X" ] ; then 69 if [ ! -d $dir ] ; then 70 echo $0: $dir is not a directory 1>&2 71 error=1 72 continue 73 fi 74 if [ -e $versf ] ; then 75 echo $0: $versf exists\; not replacing 1>&2 76 error=1 77 continue 78 fi 79 else 80 if [ ! -e $versf ] ; then 81 echo $0: $versf does not exist 1>&2 82 error=1 83 continue 84 fi 85 if [ ! -f $versf ] ; then 86 echo $0: $versf is not a regular file 1>&2 87 error=1 88 continue 89 fi 90 if [ ! -r $versf ] ; then 91 echo $0: $versf is not readable 1>&2 92 error=1 93 continue 94 fi 95 if [ ! -w $versf ] ; then 96 echo $0: $versf is not a writable 1>&2 97 error=1 98 continue 99 fi 100 101 . $versf 102 fi 103 104 if [ "X$create" != "X" ] ; then 105 nmajor=0 106 nminor=0 107 elif [ "X$bumpmajor" != "X" ] ; then 108 nmajor=`expr $major + 1` 109 nminor=0 110 else 111 nmajor=$major 112 nminor=`expr $minor + 1` 113 fi 114 115 if [ "X$donothing" = "X" ] ; then 116 echo major=$nmajor > $TMP 117 echo minor=$nminor >> $TMP 118 mv $TMP $versf 119 else 120 echo "$0: $versf -> $nmajor.$nminor" 121 fi 122done 123 124exit $error 125