checkvers revision 1.1
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
58TMP=/tmp/check.$$
59error=0
60
61# Cleanup on exit.
62trap "exit 1" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
63trap "rm -rf $TMP" 0
64
65Usage ( ) {
66    echo "$1 [-q] [installedlibdir [library name]]"
67}
68
69if echo "$*" |
70   egrep -q '([[:space:]]|^)-h([[:space:]]|$)|([[:space:]]|^)--help*' ; then
71    Usage $0
72    exit 0
73fi
74
75if [ "X$1" = "X-q" ] ; then
76    # Supress header.
77    QUIET="-q"
78    shift
79else
80    QUIET=
81fi
82
83if [ "X$1" != "X" ] ; then
84    LIBDIR="$1"
85else
86    LIBDIR="/usr/lib"
87fi
88if [ "X$2" != "X" ] ; then
89    LIBNAME="$2"
90else
91    LIBNAME=
92fi
93
94if ! mkdir -m 700 $TMP ; then
95    echo "Unable to create temp directory."
96    exit 1
97fi
98
99EXECDIR=`eval "(cd \`dirname $0\` ; pwd)"`
100
101CWD=`pwd`
102VERFILES=`find $CWD -name shlib_version -print`
103
104for f in $VERFILES ; do
105
106    (cd `dirname $f` ;
107    "$EXECDIR"/checkver $QUIET "$LIBDIR" "$LIBNAME" ;
108    exit $?)
109    if [ $? -ne 0 ] ; then
110	QUIET="-q"
111	error=1
112    fi
113
114    if [ "X$LIBNAME" = "X" ] ; then
115	# Build the library name from the directory it's in.
116	libname=`dirname $f`
117	libname=`basename $libname`
118	if ! echo $libname | grep -q "^lib" ; then
119	    libname="lib$libname"
120	fi
121    else
122	libname="$LIBNAME"
123    fi
124
125    if [ -e $TMP/$libname ] ; then
126	echo "Warning: $libname sources encountered multiple times."
127	echo "         Previous location: `cat $TMP/$libname`"
128	echo "         Current location: `dirname $f`"
129    fi
130    echo "`dirname $f`" > $TMP/$libname
131
132done
133
134exit 0
135