Annotation of src/lib/checkvers, Revision 1.6
1.1 erh 1: #!/bin/ksh
1.6 ! gmcgarry 2: # $NetBSD: checkvers,v 1.5 2000/07/22 16:04:57 erh Exp $
1.1 erh 3: #
4: # Copyright (c) 1998 The NetBSD Foundation, Inc.
5: # All rights reserved.
6: #
7: # This code is derived from software contributed to The NetBSD Foundation
8: # by Eric Haszlakiewicz.
9: #
10: # Redistribution and use in source and binary forms, with or without
11: # modification, are permitted provided that the following conditions
12: # are met:
13: # 1. Redistributions of source code must retain the above copyright
14: # notice, this list of conditions and the following disclaimer.
15: # 2. Redistributions in binary form must reproduce the above copyright
16: # notice, this list of conditions and the following disclaimer in the
17: # documentation and/or other materials provided with the distribution.
18: # 3. All advertising materials mentioning features or use of this software
19: # must display the following acknowledgement:
20: # This product includes software developed by the NetBSD
21: # Foundation, Inc. and its contributors.
22: # 4. Neither the name of The NetBSD Foundation nor the names of its
23: # contributors may be used to endorse or promote products derived
24: # from this software without specific prior written permission.
25: #
26: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: # POSSIBILITY OF SUCH DAMAGE.
37: #
38:
39: #--------------------------------------------------------------------#
40: # checkvers [-q] [systemlibdir [library name]]
41: #
42: # This is a wrapper script around checkver. It will find
43: # all directories withing the current directory containing
44: # a shlib_version file and call checkver for each.
45: #
46: # As with checkver, a list of directories of installed libraries
47: # may be specified. This will replace the default of "/usr/lib"
48: # and search there instead.
1.4 simonb 49: #
1.1 erh 50: # A library name may also be specified. However, this script
51: # will not work correctly if it finds shlib_version files
52: # corresponding to a different library.
53: #
54: # This script produces no output if all library version are ok.
55: # If the versions aren't ok the header will be displayed once
56: # followed by a list of problematic libraries.
57: #
58:
1.2 erh 59: # checkvers:
60: # if "-s", build list, pass with -f to checkver.
61: # if "-d", build list, pass with -f to checkver.
62: # if "-f", pass with -f to checkver.
63:
1.1 erh 64:
65: # Cleanup on exit.
1.2 erh 66: TMP=/tmp/checkvers.$$
67: trap "exit 2" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
1.1 erh 68: trap "rm -rf $TMP" 0
69:
70: Usage ( ) {
1.2 erh 71: echo "Usage: $1 [-q] -d [installedlibdir [library name]]"
72: echo " $1 [-q] -s [setlistdir [library name]]"
73: echo " $1 [-q] -f liblistfile [library name]"
1.1 erh 74: }
75:
1.2 erh 76: basedir=/usr/src
77: setsdir=$basedir/distrib/sets/lists
78: libdir=/usr/lib
79:
80: error=0
81: quiet=0
82: usedir=0
83: usefile=0
84: usesets=0
85: CWD=`pwd`
86: args=`getopt "df:shq" "$@"`
87: if [ $? -ne 0 ] ; then
1.1 erh 88: Usage $0
89: exit 0
90: fi
91:
1.2 erh 92: set -- $args
93:
94: while . ; do
95: case "$1" in
96: -d) usedir=1 ; shift
97: if [ $usefile -eq 1 -o $usesets -eq 1 ]; then
98: Usage $0 ; exit 2
99: fi;;
100: -f) usefile=1 ; arg1=$2 ; shift ; shift
101: if [ $usedir -eq 1 -o $usesets -eq 1 ]; then
102: Usage $0 ; exit 2
103: fi;;
104: -s) usesets=1 ; shift
105: if [ $usedir -eq 1 -o $usefile -eq 1 ]; then
106: Usage $0 ; exit 2
107: fi;;
108: -h) Usage $0 ; exit 0;;
109: -q) quiet=1 ; shift;;
110: --) shift ; break;;
111: esac
112: done
113:
114: if [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ] ; then
115: Usage $0 ; exit 2
116: fi
117: if [ $usefile -eq 0 -a $# -gt 2 ] ; then
118: Usage $0 ; exit 2
119: fi
120: if [ $usefile -eq 1 -a $# -gt 1 ] ; then
121: Usage $0 ; exit 2
122: fi
123:
124: #-------------------------#
125:
126: QUIET=
127: LIBNAME=
128:
129: # Supress header.
130: if [ quiet -eq 1 ] ; then
1.1 erh 131: QUIET="-q"
1.2 erh 132: fi
133:
134: if ! mkdir -m 700 $TMP ; then
135: echo "$0: Unable to create temp directory."
136: exit 2
137: fi
138:
139: if [ $usefile -eq 1 ] ; then
140: # Just pass the file name to checkver.
141: LIBLIST="$arg1"
1.1 erh 142: else
1.2 erh 143: LIBLIST=$TMP/libs.lst
144: fi
145:
146: # Build list from the installed libraries.
147: if [ $usedir -eq 1 ] ; then
148: if [ "X$1" != "X" ] ; then
149: libdir="$1"
150: fi
1.3 erh 151: for f in $libdir ; do
152: ls $f/lib*.so.*.*
1.5 erh 153: done > $LIBLIST 2> /dev/null
1.1 erh 154: fi
155:
1.2 erh 156: # Build list from set lists. Parameter may be either
157: # the "lists" directory or the top of the source tree.
158: if [ $usesets -eq 1 ] ; then
159: if [ "X$1" != "X" ] ; then
160: setsdir="$1"
161: if [ -d "$setsdir/distrib/sets/lists" ] ; then
162: setsdir="$setsdir/distrib/sets/lists"
163: fi
164: fi
165: (cd $setsdir ;
166: cat */[a-z]* | grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' \
167: | sort -u > $LIBLIST
168: )
1.1 erh 169: fi
1.2 erh 170:
1.1 erh 171: if [ "X$2" != "X" ] ; then
172: LIBNAME="$2"
173: fi
174:
175: EXECDIR=`eval "(cd \`dirname $0\` ; pwd)"`
176:
177: CWD=`pwd`
178: VERFILES=`find $CWD -name shlib_version -print`
179:
180: for f in $VERFILES ; do
1.2 erh 181: # Call checkver. We always have a list of libraries
182: # here, whether given to us or built, so always
183: # pass the -f flag.
1.1 erh 184: (cd `dirname $f` ;
1.6 ! gmcgarry 185: "sh $EXECDIR"/checkver $QUIET -f "$LIBLIST" "$LIBNAME" ;
1.1 erh 186: exit $?)
1.2 erh 187: ERR=$?
188: if [ $ERR -eq 2 ] ; then
189: echo "$0: checkver failed. LIBLIST=$LIBLIST $LIBNAME=$LIBNAME"
190: exit 2
191: fi
192: if [ $ERR -ne 0 ] ; then
1.1 erh 193: QUIET="-q"
194: error=1
195: fi
196:
197: if [ "X$LIBNAME" = "X" ] ; then
198: # Build the library name from the directory it's in.
199: libname=`dirname $f`
200: libname=`basename $libname`
201: if ! echo $libname | grep -q "^lib" ; then
202: libname="lib$libname"
203: fi
204: else
205: libname="$LIBNAME"
206: fi
207:
208: if [ -e $TMP/$libname ] ; then
209: echo "Warning: $libname sources encountered multiple times."
210: echo " Previous location: `cat $TMP/$libname`"
211: echo " Current location: `dirname $f`"
212: fi
213: echo "`dirname $f`" > $TMP/$libname
214:
215: done
216:
1.2 erh 217: exit $error
CVSweb <webmaster@jp.NetBSD.org>