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