Annotation of src/lib/checkoldver, Revision 1.2
1.1 christos 1: #!/bin/sh
1.2 ! christos 2: # $NetBSD: checkoldver,v 1.1 2002/11/15 16:15:20 christos Exp $
1.1 christos 3: #
4: # Copyright (c) 2002 The NetBSD Foundation, Inc.
5: # All rights reserved.
6: #
7: # This code is derived from software contributed to The NetBSD Foundation
8: # by Christos Zoulas.
9: #
10: # Redistribution and use in source and binary forms, with or without
11: # modification, are permitted provided that the following conditions
12: # are met:
13: # 1. Redistributions of source code must retain the above copyright
14: # notice, this list of conditions and the following disclaimer.
15: # 2. Redistributions in binary form must reproduce the above copyright
16: # notice, this list of conditions and the following disclaimer in the
17: # documentation and/or other materials provided with the distribution.
18: # 3. All advertising materials mentioning features or use of this software
19: # must display the following acknowledgement:
20: # This product includes software developed by the NetBSD
21: # Foundation, Inc. and its contributors.
22: # 4. Neither the name of The NetBSD Foundation nor the names of its
23: # contributors may be used to endorse or promote products derived
24: # from this software without specific prior written permission.
25: #
26: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: # POSSIBILITY OF SUCH DAMAGE.
37: #
38: # checkoldver [dir ...]
39: #
40: # Looks in the given directories for old shared libraries and lists them
41: # Useful for: 'checkoldver /usr/lib | xargs rm -f'
42:
43: delete() {
1.2 ! christos 44: obsol="$1.so"
1.1 christos 45: if [ ! -z "$2" ]
46: then
47: obsol="$obsol.$2"
48: fi
49: if [ ! -z "$3" ]
50: then
51: obsol="$obsol.$3"
52: fi
53: if [ ! -z "$4" ]
54: then
55: obsol="$obsol.$4"
56: fi
57: echo $PWD/$obsol
58: }
59:
60: comparelib() {
61: OIFS="$IFS"
62: IFS="$IFS."
63: set -- $1
64: IFS="$OIFS"
65: if [ "$3" = "[0-9]*" ]
66: then
67: return
68: fi
69:
70: if [ -z "$libmajor" ]
71: then
72: libname="$1"
73: libmajor="$3"
74: libminor="$4"
75: libtiny="$5"
76: return
77: fi
78: if [ "$libmajor" -lt "$3" ]
79: then
80: delete "$libname" "$libmajor" "$libminor" "$libtiny"
81: libmajor="$3"
82: libminor="$4"
83: libtiny="$5"
84: return
85: elif [ "$3" -lt "$libmajor" ]
86: then
87: delete "$libname" "$3" "$4" "$5"
88: return
89: fi
90:
91: if [ -z "$libminor" ]
92: then
93: return
94: fi
95: if [ "$libminor" -lt "$4" ]
96: then
97: delete "$libname" "$libmajor" "$libminor" "$libtiny"
98: libmajor="$3"
99: libminor="$4"
100: libtiny="$5"
101: return
102: elif [ "$4" -lt "$libminor" ]
103: then
104: delete "$libname" "$3" "$4" "$5"
105: return
106: fi
107:
108: if [ -z "$libtiny" ]
109: then
110: return
111: fi
112: if [ "$libtiny" -lt "$5" ]
113: then
114: delete "$libname" "$libmajor" "$libminor" "$libtiny"
115: libmajor="$3"
116: libminor="$4"
117: libtiny="$5"
118: return
119: elif [ "$5" -lt "$libminor" ]
120: then
121: delete "$libname" "$3" "$4" "$5"
122: return
123: fi
124: }
125:
126: processonedir() {
127: cd "$1"
128: for lib in lib*.so
129: do
130: lib="${lib#lib}"
131: lib="${lib%.so}"
132:
133: libmajor=
134: libminor=
135: libtiny=
136: for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]*
137: do
138: comparelib "$link"
139: done
140:
141: libmajor=
142: libminor=
143: libtiny=
144: for link in lib$lib.so.[0-9]*.[0-9]*
145: do
146: comparelib "$link"
147: done
148:
149: libmajor=
150: libminor=
151: libtiny=
152: for link in lib$lib.so.[0-9]*
153: do
154: comparelib "$link"
155: done
156: done
157: }
158:
159: for i
160: do
161: processonedir "$i"
162: done
CVSweb <webmaster@jp.NetBSD.org>