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