checkver revision 1.1 1 1.1 erh #!/bin/ksh
2 1.1 erh #
3 1.1 erh # Copyright (c) 1998 The NetBSD Foundation, Inc.
4 1.1 erh # All rights reserved.
5 1.1 erh #
6 1.1 erh # This code is derived from software contributed to The NetBSD Foundation
7 1.1 erh # by Eric Haszlakiewicz.
8 1.1 erh #
9 1.1 erh # Redistribution and use in source and binary forms, with or without
10 1.1 erh # modification, are permitted provided that the following conditions
11 1.1 erh # are met:
12 1.1 erh # 1. Redistributions of source code must retain the above copyright
13 1.1 erh # notice, this list of conditions and the following disclaimer.
14 1.1 erh # 2. Redistributions in binary form must reproduce the above copyright
15 1.1 erh # notice, this list of conditions and the following disclaimer in the
16 1.1 erh # documentation and/or other materials provided with the distribution.
17 1.1 erh # 3. All advertising materials mentioning features or use of this software
18 1.1 erh # must display the following acknowledgement:
19 1.1 erh # This product includes software developed by the NetBSD
20 1.1 erh # Foundation, Inc. and its contributors.
21 1.1 erh # 4. Neither the name of The NetBSD Foundation nor the names of its
22 1.1 erh # contributors may be used to endorse or promote products derived
23 1.1 erh # from this software without specific prior written permission.
24 1.1 erh #
25 1.1 erh # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 1.1 erh # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 erh # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 erh # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 1.1 erh # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 erh # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 erh # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 erh # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 erh # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 erh # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 erh # POSSIBILITY OF SUCH DAMAGE.
36 1.1 erh #
37 1.1 erh
38 1.1 erh #--------------------------------------------------------------------#
39 1.1 erh # checkver [-q] [installedlibdir [library name]]
40 1.1 erh #
41 1.1 erh # This script must be run from a directory in which
42 1.1 erh # a shlib_version file resides.
43 1.1 erh #
44 1.1 erh # If no arguments are passed the name of the current directory
45 1.1 erh # is assumed to be the name of the library. The directory
46 1.1 erh # "/usr/lib" will be searched for problematic libraries.
47 1.1 erh #
48 1.1 erh # A list of directories of installed libraries may be specified.
49 1.1 erh # This will replace the default of "/usr/lib" and search there
50 1.1 erh # instead.
51 1.1 erh #
52 1.1 erh # An explicit library name may be passed. If present, checkver
53 1.1 erh # will use this name when searching the installed libraries.
54 1.1 erh #
55 1.1 erh # This script produces no output if all library version are not
56 1.1 erh # large than the source version. If an installed library with a
57 1.1 erh # version greater than the source is found, checkver prints a
58 1.1 erh # header and a list of the names of the offending installed libraries.
59 1.1 erh #
60 1.1 erh # The header may be supressed by passing "-q" as the first argument.
61 1.1 erh #
62 1.1 erh
63 1.1 erh trap "exit 1" 1 2 3 4 5 6 7 8 10 11 12 13 14 15
64 1.1 erh
65 1.1 erh error=0
66 1.1 erh
67 1.1 erh Usage ( ) {
68 1.1 erh echo "$1 [-q] [installedlibdir [library name]]"
69 1.1 erh }
70 1.1 erh
71 1.1 erh
72 1.1 erh if echo "$*" | egrep -q "[[:space:]]-h[[:space:]]|[[:space:]]--help*" ; then
73 1.1 erh Usage $0
74 1.1 erh exit 0
75 1.1 erh fi
76 1.1 erh
77 1.1 erh if [ "X$1" = "X-q" ] ; then
78 1.1 erh # Supress header.
79 1.1 erh quiet="1"
80 1.1 erh shift
81 1.1 erh else
82 1.1 erh quiet="0"
83 1.1 erh fi
84 1.1 erh
85 1.1 erh if [ "X$1" != "X" ] ; then
86 1.1 erh LIBDIR="$1"
87 1.1 erh else
88 1.1 erh LIBDIR="/usr/lib"
89 1.1 erh fi
90 1.1 erh
91 1.1 erh if [ "X$2" = "X" ] ; then
92 1.1 erh # Assume the library name is the
93 1.1 erh # name of the current directory.
94 1.1 erh libname=`pwd`
95 1.1 erh libname=`basename $libname`
96 1.1 erh else
97 1.1 erh libname="$2"
98 1.1 erh fi
99 1.1 erh if ! echo $libname | grep -q "^lib" ; then
100 1.1 erh libname="lib$libname"
101 1.1 erh fi
102 1.1 erh
103 1.1 erh
104 1.1 erh if [ ! -f ./shlib_version ] ; then
105 1.1 erh echo "$0: unable to find ./shlib_version"
106 1.1 erh exit 1
107 1.1 erh fi
108 1.1 erh
109 1.1 erh # Grab major and minor numbers from the source.
110 1.1 erh . ./shlib_version
111 1.1 erh
112 1.1 erh if [ "X$minor" = "X" -o "X$major" = "X" ] ; then
113 1.1 erh echo "$0: shlib_version doesn't contain the version."
114 1.1 erh exit 1
115 1.1 erh fi
116 1.1 erh
117 1.1 erh # Find every shared object library with the same base name.
118 1.1 erh for instlib in `find $LIBDIR -name "$libname.so.*"` ; do
119 1.1 erh # Grab the major and minor from the installed library.
120 1.1 erh instmajor=`echo $instlib | awk 'BEGIN { FS="." } { print $3 } '`
121 1.1 erh instminor=`echo $instlib | awk 'BEGIN { FS="." } { print $4 } '`
122 1.1 erh
123 1.1 erh # If they're greater than the source, complain.
124 1.1 erh if [ "0$major" -eq "0$instmajor" ] ; then
125 1.1 erh if [ "0$minor" -lt "0$instminor" ] ; then
126 1.1 erh if [ $error -eq 0 -a $quiet = "0"]; then
127 1.1 erh echo -n "The following libraries have versions greater"
128 1.1 erh echo " than the source:"
129 1.1 erh fi
130 1.1 erh echo $instlib > /dev/stderr
131 1.1 erh error=1
132 1.1 erh fi
133 1.1 erh elif [ "0$major" -lt "0$instmajor" ] ; then
134 1.1 erh if [ $error -eq 0 -a $quiet = "0" ] ; then
135 1.1 erh echo -n "The following libraries have versions greater"
136 1.1 erh echo " than the source:"
137 1.1 erh fi
138 1.1 erh echo $instlib > /dev/stderr
139 1.1 erh error=1
140 1.1 erh fi
141 1.1 erh done
142 1.1 erh
143 1.1 erh exit $error
144