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