checkvers revision 1.1 1 1.1 erh #!/bin/ksh
2 1.1 erh #
3 1.1 erh # Copyright (c) 1998 The NetBSD Foundation, Inc.
4 1.1 erh # All rights reserved.
5 1.1 erh #
6 1.1 erh # This code is derived from software contributed to The NetBSD Foundation
7 1.1 erh # by Eric Haszlakiewicz.
8 1.1 erh #
9 1.1 erh # Redistribution and use in source and binary forms, with or without
10 1.1 erh # modification, are permitted provided that the following conditions
11 1.1 erh # are met:
12 1.1 erh # 1. Redistributions of source code must retain the above copyright
13 1.1 erh # notice, this list of conditions and the following disclaimer.
14 1.1 erh # 2. Redistributions in binary form must reproduce the above copyright
15 1.1 erh # notice, this list of conditions and the following disclaimer in the
16 1.1 erh # documentation and/or other materials provided with the distribution.
17 1.1 erh # 3. All advertising materials mentioning features or use of this software
18 1.1 erh # must display the following acknowledgement:
19 1.1 erh # This product includes software developed by the NetBSD
20 1.1 erh # Foundation, Inc. and its contributors.
21 1.1 erh # 4. Neither the name of The NetBSD Foundation nor the names of its
22 1.1 erh # contributors may be used to endorse or promote products derived
23 1.1 erh # from this software without specific prior written permission.
24 1.1 erh #
25 1.1 erh # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 1.1 erh # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 erh # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 erh # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 1.1 erh # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 erh # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 erh # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 erh # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 erh # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 erh # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 erh # POSSIBILITY OF SUCH DAMAGE.
36 1.1 erh #
37 1.1 erh
38 1.1 erh #--------------------------------------------------------------------#
39 1.1 erh # checkvers [-q] [systemlibdir [library name]]
40 1.1 erh #
41 1.1 erh # This is a wrapper script around checkver. It will find
42 1.1 erh # all directories withing the current directory containing
43 1.1 erh # a shlib_version file and call checkver for each.
44 1.1 erh #
45 1.1 erh # As with checkver, a list of directories of installed libraries
46 1.1 erh # may be specified. This will replace the default of "/usr/lib"
47 1.1 erh # and search there instead.
48 1.1 erh #
49 1.1 erh # A library name may also be specified. However, this script
50 1.1 erh # will not work correctly if it finds shlib_version files
51 1.1 erh # corresponding to a different library.
52 1.1 erh #
53 1.1 erh # This script produces no output if all library version are ok.
54 1.1 erh # If the versions aren't ok the header will be displayed once
55 1.1 erh # followed by a list of problematic libraries.
56 1.1 erh #
57 1.1 erh
58 1.1 erh TMP=/tmp/check.$$
59 1.1 erh error=0
60 1.1 erh
61 1.1 erh # Cleanup on exit.
62 1.1 erh trap "exit 1" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
63 1.1 erh trap "rm -rf $TMP" 0
64 1.1 erh
65 1.1 erh Usage ( ) {
66 1.1 erh echo "$1 [-q] [installedlibdir [library name]]"
67 1.1 erh }
68 1.1 erh
69 1.1 erh if echo "$*" |
70 1.1 erh egrep -q '([[:space:]]|^)-h([[:space:]]|$)|([[:space:]]|^)--help*' ; then
71 1.1 erh Usage $0
72 1.1 erh exit 0
73 1.1 erh fi
74 1.1 erh
75 1.1 erh if [ "X$1" = "X-q" ] ; then
76 1.1 erh # Supress header.
77 1.1 erh QUIET="-q"
78 1.1 erh shift
79 1.1 erh else
80 1.1 erh QUIET=
81 1.1 erh fi
82 1.1 erh
83 1.1 erh if [ "X$1" != "X" ] ; then
84 1.1 erh LIBDIR="$1"
85 1.1 erh else
86 1.1 erh LIBDIR="/usr/lib"
87 1.1 erh fi
88 1.1 erh if [ "X$2" != "X" ] ; then
89 1.1 erh LIBNAME="$2"
90 1.1 erh else
91 1.1 erh LIBNAME=
92 1.1 erh fi
93 1.1 erh
94 1.1 erh if ! mkdir -m 700 $TMP ; then
95 1.1 erh echo "Unable to create temp directory."
96 1.1 erh exit 1
97 1.1 erh fi
98 1.1 erh
99 1.1 erh EXECDIR=`eval "(cd \`dirname $0\` ; pwd)"`
100 1.1 erh
101 1.1 erh CWD=`pwd`
102 1.1 erh VERFILES=`find $CWD -name shlib_version -print`
103 1.1 erh
104 1.1 erh for f in $VERFILES ; do
105 1.1 erh
106 1.1 erh (cd `dirname $f` ;
107 1.1 erh "$EXECDIR"/checkver $QUIET "$LIBDIR" "$LIBNAME" ;
108 1.1 erh exit $?)
109 1.1 erh if [ $? -ne 0 ] ; then
110 1.1 erh QUIET="-q"
111 1.1 erh error=1
112 1.1 erh fi
113 1.1 erh
114 1.1 erh if [ "X$LIBNAME" = "X" ] ; then
115 1.1 erh # Build the library name from the directory it's in.
116 1.1 erh libname=`dirname $f`
117 1.1 erh libname=`basename $libname`
118 1.1 erh if ! echo $libname | grep -q "^lib" ; then
119 1.1 erh libname="lib$libname"
120 1.1 erh fi
121 1.1 erh else
122 1.1 erh libname="$LIBNAME"
123 1.1 erh fi
124 1.1 erh
125 1.1 erh if [ -e $TMP/$libname ] ; then
126 1.1 erh echo "Warning: $libname sources encountered multiple times."
127 1.1 erh echo " Previous location: `cat $TMP/$libname`"
128 1.1 erh echo " Current location: `dirname $f`"
129 1.1 erh fi
130 1.1 erh echo "`dirname $f`" > $TMP/$libname
131 1.1 erh
132 1.1 erh done
133 1.1 erh
134 1.1 erh exit 0
135