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