checkvers revision 1.8
11.1Serh#!/bin/ksh 21.8Sandvar# $NetBSD: checkvers,v 1.8 2021/12/03 13:27:37 andvar Exp $ 31.1Serh# 41.1Serh# Copyright (c) 1998 The NetBSD Foundation, Inc. 51.1Serh# All rights reserved. 61.1Serh# 71.1Serh# This code is derived from software contributed to The NetBSD Foundation 81.1Serh# by Eric Haszlakiewicz. 91.1Serh# 101.1Serh# Redistribution and use in source and binary forms, with or without 111.1Serh# modification, are permitted provided that the following conditions 121.1Serh# are met: 131.1Serh# 1. Redistributions of source code must retain the above copyright 141.1Serh# notice, this list of conditions and the following disclaimer. 151.1Serh# 2. Redistributions in binary form must reproduce the above copyright 161.1Serh# notice, this list of conditions and the following disclaimer in the 171.1Serh# documentation and/or other materials provided with the distribution. 181.1Serh# 191.1Serh# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Serh# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Serh# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Serh# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Serh# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Serh# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Serh# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Serh# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Serh# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Serh# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Serh# POSSIBILITY OF SUCH DAMAGE. 301.1Serh# 311.1Serh 321.1Serh#--------------------------------------------------------------------# 331.1Serh# checkvers [-q] [systemlibdir [library name]] 341.1Serh# 351.1Serh# This is a wrapper script around checkver. It will find 361.8Sandvar# all directories within the current directory containing 371.1Serh# a shlib_version file and call checkver for each. 381.1Serh# 391.1Serh# As with checkver, a list of directories of installed libraries 401.1Serh# may be specified. This will replace the default of "/usr/lib" 411.1Serh# and search there instead. 421.4Ssimonb# 431.1Serh# A library name may also be specified. However, this script 441.1Serh# will not work correctly if it finds shlib_version files 451.1Serh# corresponding to a different library. 461.1Serh# 471.8Sandvar# This script produces no output if all library versions are ok. 481.1Serh# If the versions aren't ok the header will be displayed once 491.1Serh# followed by a list of problematic libraries. 501.1Serh# 511.1Serh 521.2Serh# checkvers: 531.2Serh# if "-s", build list, pass with -f to checkver. 541.2Serh# if "-d", build list, pass with -f to checkver. 551.2Serh# if "-f", pass with -f to checkver. 561.2Serh 571.1Serh 581.1Serh# Cleanup on exit. 591.2SerhTMP=/tmp/checkvers.$$ 601.2Serhtrap "exit 2" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 611.1Serhtrap "rm -rf $TMP" 0 621.1Serh 631.1SerhUsage ( ) { 641.2Serh echo "Usage: $1 [-q] -d [installedlibdir [library name]]" 651.2Serh echo " $1 [-q] -s [setlistdir [library name]]" 661.2Serh echo " $1 [-q] -f liblistfile [library name]" 671.1Serh} 681.1Serh 691.2Serhbasedir=/usr/src 701.2Serhsetsdir=$basedir/distrib/sets/lists 711.2Serhlibdir=/usr/lib 721.2Serh 731.2Serherror=0 741.2Serhquiet=0 751.2Serhusedir=0 761.2Serhusefile=0 771.2Serhusesets=0 781.2SerhCWD=`pwd` 791.2Serhargs=`getopt "df:shq" "$@"` 801.2Serhif [ $? -ne 0 ] ; then 811.1Serh Usage $0 821.1Serh exit 0 831.1Serhfi 841.1Serh 851.2Serhset -- $args 861.2Serh 871.2Serhwhile . ; do 881.2Serh case "$1" in 891.2Serh -d) usedir=1 ; shift 901.2Serh if [ $usefile -eq 1 -o $usesets -eq 1 ]; then 911.2Serh Usage $0 ; exit 2 921.2Serh fi;; 931.2Serh -f) usefile=1 ; arg1=$2 ; shift ; shift 941.2Serh if [ $usedir -eq 1 -o $usesets -eq 1 ]; then 951.2Serh Usage $0 ; exit 2 961.2Serh fi;; 971.2Serh -s) usesets=1 ; shift 981.2Serh if [ $usedir -eq 1 -o $usefile -eq 1 ]; then 991.2Serh Usage $0 ; exit 2 1001.2Serh fi;; 1011.2Serh -h) Usage $0 ; exit 0;; 1021.2Serh -q) quiet=1 ; shift;; 1031.2Serh --) shift ; break;; 1041.2Serh esac 1051.2Serhdone 1061.2Serh 1071.2Serhif [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ] ; then 1081.2Serh Usage $0 ; exit 2 1091.2Serhfi 1101.2Serhif [ $usefile -eq 0 -a $# -gt 2 ] ; then 1111.2Serh Usage $0 ; exit 2 1121.2Serhfi 1131.2Serhif [ $usefile -eq 1 -a $# -gt 1 ] ; then 1141.2Serh Usage $0 ; exit 2 1151.2Serhfi 1161.2Serh 1171.2Serh#-------------------------# 1181.2Serh 1191.2SerhQUIET= 1201.2SerhLIBNAME= 1211.2Serh 1221.2Serh# Supress header. 1231.2Serhif [ quiet -eq 1 ] ; then 1241.1Serh QUIET="-q" 1251.2Serhfi 1261.2Serh 1271.2Serhif ! mkdir -m 700 $TMP ; then 1281.2Serh echo "$0: Unable to create temp directory." 1291.2Serh exit 2 1301.2Serhfi 1311.2Serh 1321.2Serhif [ $usefile -eq 1 ] ; then 1331.2Serh # Just pass the file name to checkver. 1341.2Serh LIBLIST="$arg1" 1351.1Serhelse 1361.2Serh LIBLIST=$TMP/libs.lst 1371.2Serhfi 1381.2Serh 1391.2Serh# Build list from the installed libraries. 1401.2Serhif [ $usedir -eq 1 ] ; then 1411.2Serh if [ "X$1" != "X" ] ; then 1421.2Serh libdir="$1" 1431.2Serh fi 1441.3Serh for f in $libdir ; do 1451.3Serh ls $f/lib*.so.*.* 1461.5Serh done > $LIBLIST 2> /dev/null 1471.1Serhfi 1481.1Serh 1491.2Serh# Build list from set lists. Parameter may be either 1501.2Serh# the "lists" directory or the top of the source tree. 1511.2Serhif [ $usesets -eq 1 ] ; then 1521.2Serh if [ "X$1" != "X" ] ; then 1531.2Serh setsdir="$1" 1541.2Serh if [ -d "$setsdir/distrib/sets/lists" ] ; then 1551.2Serh setsdir="$setsdir/distrib/sets/lists" 1561.2Serh fi 1571.2Serh fi 1581.2Serh (cd $setsdir ; 1591.2Serh cat */[a-z]* | grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' \ 1601.2Serh | sort -u > $LIBLIST 1611.2Serh ) 1621.1Serhfi 1631.2Serh 1641.1Serhif [ "X$2" != "X" ] ; then 1651.1Serh LIBNAME="$2" 1661.1Serhfi 1671.1Serh 1681.1SerhEXECDIR=`eval "(cd \`dirname $0\` ; pwd)"` 1691.1Serh 1701.1SerhCWD=`pwd` 1711.1SerhVERFILES=`find $CWD -name shlib_version -print` 1721.1Serh 1731.1Serhfor f in $VERFILES ; do 1741.2Serh # Call checkver. We always have a list of libraries 1751.2Serh # here, whether given to us or built, so always 1761.2Serh # pass the -f flag. 1771.1Serh (cd `dirname $f` ; 1781.6Sgmcgarry "sh $EXECDIR"/checkver $QUIET -f "$LIBLIST" "$LIBNAME" ; 1791.1Serh exit $?) 1801.2Serh ERR=$? 1811.2Serh if [ $ERR -eq 2 ] ; then 1821.2Serh echo "$0: checkver failed. LIBLIST=$LIBLIST $LIBNAME=$LIBNAME" 1831.2Serh exit 2 1841.2Serh fi 1851.2Serh if [ $ERR -ne 0 ] ; then 1861.1Serh QUIET="-q" 1871.1Serh error=1 1881.1Serh fi 1891.1Serh 1901.1Serh if [ "X$LIBNAME" = "X" ] ; then 1911.1Serh # Build the library name from the directory it's in. 1921.1Serh libname=`dirname $f` 1931.1Serh libname=`basename $libname` 1941.1Serh if ! echo $libname | grep -q "^lib" ; then 1951.1Serh libname="lib$libname" 1961.1Serh fi 1971.1Serh else 1981.1Serh libname="$LIBNAME" 1991.1Serh fi 2001.1Serh 2011.1Serh if [ -e $TMP/$libname ] ; then 2021.1Serh echo "Warning: $libname sources encountered multiple times." 2031.1Serh echo " Previous location: `cat $TMP/$libname`" 2041.1Serh echo " Current location: `dirname $f`" 2051.1Serh fi 2061.1Serh echo "`dirname $f`" > $TMP/$libname 2071.1Serh 2081.1Serhdone 2091.1Serh 2101.2Serhexit $error 211