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