11.1Scgd#!/bin/sh
21.10Ssalo# $NetBSD: bumpversion,v 1.10 2003/07/26 19:24:24 salo Exp $
31.1Scgd#
41.1Scgd# Copyright (c) 1993 Christopher G. Demetriou
51.1Scgd# All rights reserved.
61.9Scgd# 
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.9Scgd#          This product includes software developed for the
181.10Ssalo#          NetBSD Project.  See http://www.NetBSD.org/ for
191.9Scgd#          information about NetBSD.
201.1Scgd# 4. The name of the author may not be used to endorse or promote products
211.9Scgd#    derived from this software without specific prior written permission.
221.9Scgd# 
231.1Scgd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
241.1Scgd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
251.1Scgd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
261.1Scgd# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
271.1Scgd# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
281.1Scgd# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
291.1Scgd# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
301.1Scgd# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
311.1Scgd# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
321.1Scgd# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
331.9Scgd# 
341.9Scgd# <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
351.1Scgd
361.1Scgdwhile :
371.1Scgd	do case "$1" in
381.1Scgd		# -c says to create new shlib_version files
391.1Scgd		-c)
401.1Scgd			create=TRUE
411.1Scgd			shift ;;
421.1Scgd
431.1Scgd		# -n sets 'do nothing mode'
441.1Scgd		-n)
451.1Scgd			donothing=TRUE
461.1Scgd			shift ;;
471.1Scgd
481.1Scgd		# -m says to bump major number, rather than minor number
491.1Scgd		-m)
501.1Scgd			bumpmajor=TRUE
511.1Scgd			shift ;;
521.1Scgd
531.1Scgd		*)
541.1Scgd			break ;;
551.1Scgd	esac
561.1Scgddone
571.1Scgd
581.1Scgdif [ $# = 0 ] ; then
591.2Scgd	echo "usage: $0 [-c] [-m] [-n] dir ..."
601.1Scgd	exit 2
611.1Scgdfi
621.1Scgd
631.1ScgdTMP=/tmp/bump$$
641.1Scgderror=0
651.1Scgd
661.1Scgdtrap 'rm -f $TMP ; exit 1' 1 2 3 13 15
671.1Scgd
681.1Scgdfor dir in $@ ; do
691.1Scgd	versf=$dir/shlib_version
701.1Scgd
711.1Scgd	if [ "X$create" != "X" ] ; then
721.1Scgd		if [ ! -d $dir ] ; then
731.1Scgd		        echo $0: $dir is not a directory 1>&2
741.1Scgd		        error=1
751.1Scgd			continue
761.1Scgd		fi
771.1Scgd		if [ -e $versf ] ; then
781.1Scgd		        echo $0: $versf exists\; not replacing 1>&2
791.1Scgd		        error=1
801.1Scgd			continue
811.1Scgd		fi
821.1Scgd	else
831.1Scgd		if [ ! -e $versf ] ; then
841.1Scgd		        echo $0: $versf does not exist 1>&2
851.1Scgd		        error=1
861.1Scgd			continue
871.1Scgd		fi
881.1Scgd		if [ ! -f $versf ] ; then
891.1Scgd		        echo $0: $versf is not a regular file 1>&2
901.1Scgd		        error=1
911.1Scgd			continue
921.1Scgd		fi
931.1Scgd		if [ ! -r $versf ] ; then
941.1Scgd		        echo $0: $versf is not readable 1>&2
951.1Scgd		        error=1
961.1Scgd			continue
971.1Scgd		fi
981.1Scgd		if [ ! -w $versf ] ; then
991.1Scgd		        echo $0: $versf is not a writable 1>&2
1001.1Scgd		        error=1
1011.1Scgd			continue
1021.1Scgd		fi
1031.7Ssimonb
1041.1Scgd		. $versf
1051.1Scgd	fi
1061.1Scgd
1071.1Scgd	if [ "X$create" != "X" ] ; then
1081.1Scgd		nmajor=0
1091.1Scgd		nminor=0
1101.1Scgd	elif [ "X$bumpmajor" != "X" ] ; then
1111.1Scgd		nmajor=`expr $major + 1`
1121.1Scgd		nminor=0
1131.1Scgd	else
1141.1Scgd		nmajor=$major
1151.1Scgd		nminor=`expr $minor + 1`
1161.1Scgd	fi
1171.1Scgd
1181.1Scgd	if [ "X$donothing" = "X" ] ; then
1191.1Scgd		echo major=$nmajor > $TMP
1201.1Scgd		echo minor=$nminor >> $TMP
1211.1Scgd		mv $TMP $versf
1221.1Scgd	else
1231.1Scgd		echo "$0: $versf -> $nmajor.$nminor"
1241.1Scgd	fi
1251.1Scgddone
1261.1Scgd
1271.1Scgdexit $error
128