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