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