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