Annotation of src/lib/bumpversion, Revision 1.2
1.1 deraadt 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 without 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: #
1.2 ! deraadt 31: # $Id: bumpversion,v 1.1.1.1 1995/10/18 08:41:17 deraadt Exp $
1.1 deraadt 32: #
33:
34: while :
35: do case "$1" in
36: # -c says to create new shlib_version files
37: -c)
38: create=TRUE
39: shift ;;
40:
41: # -n sets 'do nothing mode'
42: -n)
43: donothing=TRUE
44: shift ;;
45:
46: # -m says to bump major number, rather than minor number
47: -m)
48: bumpmajor=TRUE
49: shift ;;
50:
51: *)
52: break ;;
53: esac
54: done
55:
56: if [ $# = 0 ] ; then
57: echo "usage: $0 [-c] [-m] [-n] dir ..."
58: exit 2
59: fi
60:
61: TMP=/tmp/bump$$
62: error=0
63:
64: trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
65:
66: for dir in $@ ; do
67: versf=$dir/shlib_version
68:
69: if [ "X$create" != "X" ] ; then
70: if [ ! -d $dir ] ; then
71: echo $0: $dir is not a directory 1>&2
72: error=1
73: continue
74: fi
75: if [ -e $versf ] ; then
76: echo $0: $versf exists\; not replacing 1>&2
77: error=1
78: continue
79: fi
80: else
81: if [ ! -e $versf ] ; then
82: echo $0: $versf does not exist 1>&2
83: error=1
84: continue
85: fi
86: if [ ! -f $versf ] ; then
87: echo $0: $versf is not a regular file 1>&2
88: error=1
89: continue
90: fi
91: if [ ! -r $versf ] ; then
92: echo $0: $versf is not readable 1>&2
93: error=1
94: continue
95: fi
96: if [ ! -w $versf ] ; then
97: echo $0: $versf is not a writable 1>&2
98: error=1
99: continue
100: fi
101:
102: . $versf
103: fi
104:
105: if [ "X$create" != "X" ] ; then
106: nmajor=0
107: nminor=0
108: elif [ "X$bumpmajor" != "X" ] ; then
109: nmajor=`expr $major + 1`
110: nminor=0
111: else
112: nmajor=$major
113: nminor=`expr $minor + 1`
114: fi
115:
116: if [ "X$donothing" = "X" ] ; then
117: echo major=$nmajor > $TMP
118: echo minor=$nminor >> $TMP
119: mv $TMP $versf
120: else
121: echo "$0: $versf -> $nmajor.$nminor"
122: fi
123: done
124:
125: exit $error