bumpversion revision 1.7
11.1Scgd#!/bin/sh
21.7Ssimonb#	$NetBSD: bumpversion,v 1.7 1999/07/02 15:12:15 simonb Exp $
31.1Scgd#
41.1Scgd# Copyright (c) 1993 Christopher G. Demetriou
51.1Scgd# All rights reserved.
61.1Scgd#
71.1Scgd# Redistribution and use in source and binary forms, with or without
81.1Scgd# modification, are permitted provided that the following conditions
91.1Scgd# are met:
101.1Scgd# 1. Redistributions of source code must retain the above copyright
111.1Scgd#    notice, this list of conditions and the following disclaimer.
121.1Scgd# 2. Redistributions in binary form must reproduce the above copyright
131.1Scgd#    notice, this list of conditions and the following disclaimer in the
141.1Scgd#    documentation and/or other materials provided with the distribution.
151.1Scgd# 3. All advertising materials mentioning features or use of this software
161.1Scgd#    must display the following acknowledgement:
171.1Scgd#      This product includes software developed by Christopher G. Demetriou.
181.1Scgd# 4. The name of the author may not be used to endorse or promote products
191.3Sjtc#    derived from this software without specific prior written permission
201.1Scgd#
211.1Scgd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
221.1Scgd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
231.1Scgd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
241.1Scgd# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
251.1Scgd# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
261.1Scgd# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
271.1Scgd# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
281.1Scgd# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
291.1Scgd# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
301.1Scgd# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
311.1Scgd#
321.1Scgd
331.1Scgdwhile :
341.1Scgd	do case "$1" in
351.1Scgd		# -c says to create new shlib_version files
361.1Scgd		-c)
371.1Scgd			create=TRUE
381.1Scgd			shift ;;
391.1Scgd
401.1Scgd		# -n sets 'do nothing mode'
411.1Scgd		-n)
421.1Scgd			donothing=TRUE
431.1Scgd			shift ;;
441.1Scgd
451.1Scgd		# -m says to bump major number, rather than minor number
461.1Scgd		-m)
471.1Scgd			bumpmajor=TRUE
481.1Scgd			shift ;;
491.1Scgd
501.1Scgd		*)
511.1Scgd			break ;;
521.1Scgd	esac
531.1Scgddone
541.1Scgd
551.1Scgdif [ $# = 0 ] ; then
561.2Scgd	echo "usage: $0 [-c] [-m] [-n] dir ..."
571.1Scgd	exit 2
581.1Scgdfi
591.1Scgd
601.1ScgdTMP=/tmp/bump$$
611.1Scgderror=0
621.1Scgd
631.1Scgdtrap 'rm -f $TMP ; exit 1' 1 2 3 13 15
641.1Scgd
651.1Scgdfor dir in $@ ; do
661.1Scgd	versf=$dir/shlib_version
671.1Scgd
681.1Scgd	if [ "X$create" != "X" ] ; then
691.1Scgd		if [ ! -d $dir ] ; then
701.1Scgd		        echo $0: $dir is not a directory 1>&2
711.1Scgd		        error=1
721.1Scgd			continue
731.1Scgd		fi
741.1Scgd		if [ -e $versf ] ; then
751.1Scgd		        echo $0: $versf exists\; not replacing 1>&2
761.1Scgd		        error=1
771.1Scgd			continue
781.1Scgd		fi
791.1Scgd	else
801.1Scgd		if [ ! -e $versf ] ; then
811.1Scgd		        echo $0: $versf does not exist 1>&2
821.1Scgd		        error=1
831.1Scgd			continue
841.1Scgd		fi
851.1Scgd		if [ ! -f $versf ] ; then
861.1Scgd		        echo $0: $versf is not a regular file 1>&2
871.1Scgd		        error=1
881.1Scgd			continue
891.1Scgd		fi
901.1Scgd		if [ ! -r $versf ] ; then
911.1Scgd		        echo $0: $versf is not readable 1>&2
921.1Scgd		        error=1
931.1Scgd			continue
941.1Scgd		fi
951.1Scgd		if [ ! -w $versf ] ; then
961.1Scgd		        echo $0: $versf is not a writable 1>&2
971.1Scgd		        error=1
981.1Scgd			continue
991.1Scgd		fi
1001.7Ssimonb
1011.1Scgd		. $versf
1021.1Scgd	fi
1031.1Scgd
1041.1Scgd	if [ "X$create" != "X" ] ; then
1051.1Scgd		nmajor=0
1061.1Scgd		nminor=0
1071.1Scgd	elif [ "X$bumpmajor" != "X" ] ; then
1081.1Scgd		nmajor=`expr $major + 1`
1091.1Scgd		nminor=0
1101.1Scgd	else
1111.1Scgd		nmajor=$major
1121.1Scgd		nminor=`expr $minor + 1`
1131.1Scgd	fi
1141.1Scgd
1151.1Scgd	if [ "X$donothing" = "X" ] ; then
1161.1Scgd		echo major=$nmajor > $TMP
1171.1Scgd		echo minor=$nminor >> $TMP
1181.1Scgd		mv $TMP $versf
1191.1Scgd	else
1201.1Scgd		echo "$0: $versf -> $nmajor.$nminor"
1211.1Scgd	fi
1221.1Scgddone
1231.1Scgd
1241.1Scgdexit $error
125