checkvers revision 1.2
11.1Serh#!/bin/ksh 21.1Serh# 31.1Serh# Copyright (c) 1998 The NetBSD Foundation, Inc. 41.1Serh# All rights reserved. 51.1Serh# 61.1Serh# This code is derived from software contributed to The NetBSD Foundation 71.1Serh# by Eric Haszlakiewicz. 81.1Serh# 91.1Serh# Redistribution and use in source and binary forms, with or without 101.1Serh# modification, are permitted provided that the following conditions 111.1Serh# are met: 121.1Serh# 1. Redistributions of source code must retain the above copyright 131.1Serh# notice, this list of conditions and the following disclaimer. 141.1Serh# 2. Redistributions in binary form must reproduce the above copyright 151.1Serh# notice, this list of conditions and the following disclaimer in the 161.1Serh# documentation and/or other materials provided with the distribution. 171.1Serh# 3. All advertising materials mentioning features or use of this software 181.1Serh# must display the following acknowledgement: 191.1Serh# This product includes software developed by the NetBSD 201.1Serh# Foundation, Inc. and its contributors. 211.1Serh# 4. Neither the name of The NetBSD Foundation nor the names of its 221.1Serh# contributors may be used to endorse or promote products derived 231.1Serh# from this software without specific prior written permission. 241.1Serh# 251.1Serh# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 261.1Serh# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Serh# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Serh# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 291.1Serh# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Serh# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Serh# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Serh# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Serh# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Serh# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Serh# POSSIBILITY OF SUCH DAMAGE. 361.1Serh# 371.1Serh 381.1Serh#--------------------------------------------------------------------# 391.1Serh# checkvers [-q] [systemlibdir [library name]] 401.1Serh# 411.1Serh# This is a wrapper script around checkver. It will find 421.1Serh# all directories withing the current directory containing 431.1Serh# a shlib_version file and call checkver for each. 441.1Serh# 451.1Serh# As with checkver, a list of directories of installed libraries 461.1Serh# may be specified. This will replace the default of "/usr/lib" 471.1Serh# and search there instead. 481.1Serh# 491.1Serh# A library name may also be specified. However, this script 501.1Serh# will not work correctly if it finds shlib_version files 511.1Serh# corresponding to a different library. 521.1Serh# 531.1Serh# This script produces no output if all library version are ok. 541.1Serh# If the versions aren't ok the header will be displayed once 551.1Serh# followed by a list of problematic libraries. 561.1Serh# 571.1Serh 581.2Serh# checkvers: 591.2Serh# if "-s", build list, pass with -f to checkver. 601.2Serh# if "-d", build list, pass with -f to checkver. 611.2Serh# if "-f", pass with -f to checkver. 621.2Serh 631.1Serh 641.1Serh# Cleanup on exit. 651.2SerhTMP=/tmp/checkvers.$$ 661.2Serhtrap "exit 2" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 671.1Serhtrap "rm -rf $TMP" 0 681.1Serh 691.1SerhUsage ( ) { 701.2Serh echo "Usage: $1 [-q] -d [installedlibdir [library name]]" 711.2Serh echo " $1 [-q] -s [setlistdir [library name]]" 721.2Serh echo " $1 [-q] -f liblistfile [library name]" 731.1Serh} 741.1Serh 751.2Serhbasedir=/usr/src 761.2Serhsetsdir=$basedir/distrib/sets/lists 771.2Serhlibdir=/usr/lib 781.2Serh 791.2Serherror=0 801.2Serhquiet=0 811.2Serhusedir=0 821.2Serhusefile=0 831.2Serhusesets=0 841.2SerhCWD=`pwd` 851.2Serhargs=`getopt "df:shq" "$@"` 861.2Serhif [ $? -ne 0 ] ; then 871.1Serh Usage $0 881.1Serh exit 0 891.1Serhfi 901.1Serh 911.2Serhset -- $args 921.2Serh 931.2Serhwhile . ; do 941.2Serh case "$1" in 951.2Serh -d) usedir=1 ; shift 961.2Serh if [ $usefile -eq 1 -o $usesets -eq 1 ]; then 971.2Serh Usage $0 ; exit 2 981.2Serh fi;; 991.2Serh -f) usefile=1 ; arg1=$2 ; shift ; shift 1001.2Serh if [ $usedir -eq 1 -o $usesets -eq 1 ]; then 1011.2Serh Usage $0 ; exit 2 1021.2Serh fi;; 1031.2Serh -s) usesets=1 ; shift 1041.2Serh if [ $usedir -eq 1 -o $usefile -eq 1 ]; then 1051.2Serh Usage $0 ; exit 2 1061.2Serh fi;; 1071.2Serh -h) Usage $0 ; exit 0;; 1081.2Serh -q) quiet=1 ; shift;; 1091.2Serh --) shift ; break;; 1101.2Serh esac 1111.2Serhdone 1121.2Serh 1131.2Serhif [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ] ; then 1141.2Serh Usage $0 ; exit 2 1151.2Serhfi 1161.2Serhif [ $usefile -eq 0 -a $# -gt 2 ] ; then 1171.2Serh Usage $0 ; exit 2 1181.2Serhfi 1191.2Serhif [ $usefile -eq 1 -a $# -gt 1 ] ; then 1201.2Serh Usage $0 ; exit 2 1211.2Serhfi 1221.2Serh 1231.2Serh#-------------------------# 1241.2Serh 1251.2SerhQUIET= 1261.2SerhLIBNAME= 1271.2Serh 1281.2Serh# Supress header. 1291.2Serhif [ quiet -eq 1 ] ; then 1301.1Serh QUIET="-q" 1311.2Serhfi 1321.2Serh 1331.2Serhif ! mkdir -m 700 $TMP ; then 1341.2Serh echo "$0: Unable to create temp directory." 1351.2Serh exit 2 1361.2Serhfi 1371.2Serh 1381.2Serhif [ $usefile -eq 1 ] ; then 1391.2Serh # Just pass the file name to checkver. 1401.2Serh LIBLIST="$arg1" 1411.1Serhelse 1421.2Serh LIBLIST=$TMP/libs.lst 1431.2Serhfi 1441.2Serh 1451.2Serh# Build list from the installed libraries. 1461.2Serhif [ $usedir -eq 1 ] ; then 1471.2Serh if [ "X$1" != "X" ] ; then 1481.2Serh libdir="$1" 1491.2Serh fi 1501.2Serh find $libdir -name 'lib*.so.*.*' > $LIBLIST 1511.1Serhfi 1521.1Serh 1531.2Serh# Build list from set lists. Parameter may be either 1541.2Serh# the "lists" directory or the top of the source tree. 1551.2Serhif [ $usesets -eq 1 ] ; then 1561.2Serh if [ "X$1" != "X" ] ; then 1571.2Serh setsdir="$1" 1581.2Serh if [ -d "$setsdir/distrib/sets/lists" ] ; then 1591.2Serh setsdir="$setsdir/distrib/sets/lists" 1601.2Serh fi 1611.2Serh fi 1621.2Serh (cd $setsdir ; 1631.2Serh cat */[a-z]* | grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' \ 1641.2Serh | sort -u > $LIBLIST 1651.2Serh ) 1661.1Serhfi 1671.2Serh 1681.1Serhif [ "X$2" != "X" ] ; then 1691.1Serh LIBNAME="$2" 1701.1Serhfi 1711.1Serh 1721.1SerhEXECDIR=`eval "(cd \`dirname $0\` ; pwd)"` 1731.1Serh 1741.1SerhCWD=`pwd` 1751.1SerhVERFILES=`find $CWD -name shlib_version -print` 1761.1Serh 1771.1Serhfor f in $VERFILES ; do 1781.2Serh # Call checkver. We always have a list of libraries 1791.2Serh # here, whether given to us or built, so always 1801.2Serh # pass the -f flag. 1811.1Serh (cd `dirname $f` ; 1821.2Serh "$EXECDIR"/checkver $QUIET -f "$LIBLIST" "$LIBNAME" ; 1831.1Serh exit $?) 1841.2Serh ERR=$? 1851.2Serh if [ $ERR -eq 2 ] ; then 1861.2Serh echo "$0: checkver failed. LIBLIST=$LIBLIST $LIBNAME=$LIBNAME" 1871.2Serh exit 2 1881.2Serh fi 1891.2Serh if [ $ERR -ne 0 ] ; then 1901.1Serh QUIET="-q" 1911.1Serh error=1 1921.1Serh fi 1931.1Serh 1941.1Serh if [ "X$LIBNAME" = "X" ] ; then 1951.1Serh # Build the library name from the directory it's in. 1961.1Serh libname=`dirname $f` 1971.1Serh libname=`basename $libname` 1981.1Serh if ! echo $libname | grep -q "^lib" ; then 1991.1Serh libname="lib$libname" 2001.1Serh fi 2011.1Serh else 2021.1Serh libname="$LIBNAME" 2031.1Serh fi 2041.1Serh 2051.1Serh if [ -e $TMP/$libname ] ; then 2061.1Serh echo "Warning: $libname sources encountered multiple times." 2071.1Serh echo " Previous location: `cat $TMP/$libname`" 2081.1Serh echo " Current location: `dirname $f`" 2091.1Serh fi 2101.1Serh echo "`dirname $f`" > $TMP/$libname 2111.1Serh 2121.1Serhdone 2131.1Serh 2141.2Serhexit $error 215