Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / lib / checkoldver
blob549d24023fda9a955036006381dbe689965aad5a
1 #!/bin/sh
2 # $NetBSD: checkoldver,v 1.2 2003/10/25 07:53:12 christos Exp $
4 # Copyright (c) 2002 The NetBSD Foundation, Inc.
5 # All rights reserved.
7 # This code is derived from software contributed to The NetBSD Foundation
8 # by Christos Zoulas.
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.
19 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
31 # checkoldver [dir ...]
33 # Looks in the given directories for old shared libraries and lists them
34 # Useful for: 'checkoldver /usr/lib | xargs rm -f'
36 delete() {
37 obsol="$1.so"
38 if [ ! -z "$2" ]
39 then
40 obsol="$obsol.$2"
42 if [ ! -z "$3" ]
43 then
44 obsol="$obsol.$3"
46 if [ ! -z "$4" ]
47 then
48 obsol="$obsol.$4"
50 echo $PWD/$obsol
53 comparelib() {
54 OIFS="$IFS"
55 IFS="$IFS."
56 set -- $1
57 IFS="$OIFS"
58 if [ "$3" = "[0-9]*" ]
59 then
60 return
63 if [ -z "$libmajor" ]
64 then
65 libname="$1"
66 libmajor="$3"
67 libminor="$4"
68 libtiny="$5"
69 return
71 if [ "$libmajor" -lt "$3" ]
72 then
73 delete "$libname" "$libmajor" "$libminor" "$libtiny"
74 libmajor="$3"
75 libminor="$4"
76 libtiny="$5"
77 return
78 elif [ "$3" -lt "$libmajor" ]
79 then
80 delete "$libname" "$3" "$4" "$5"
81 return
84 if [ -z "$libminor" ]
85 then
86 return
88 if [ "$libminor" -lt "$4" ]
89 then
90 delete "$libname" "$libmajor" "$libminor" "$libtiny"
91 libmajor="$3"
92 libminor="$4"
93 libtiny="$5"
94 return
95 elif [ "$4" -lt "$libminor" ]
96 then
97 delete "$libname" "$3" "$4" "$5"
98 return
101 if [ -z "$libtiny" ]
102 then
103 return
105 if [ "$libtiny" -lt "$5" ]
106 then
107 delete "$libname" "$libmajor" "$libminor" "$libtiny"
108 libmajor="$3"
109 libminor="$4"
110 libtiny="$5"
111 return
112 elif [ "$5" -lt "$libminor" ]
113 then
114 delete "$libname" "$3" "$4" "$5"
115 return
119 processonedir() {
120 cd "$1"
121 for lib in lib*.so
123 lib="${lib#lib}"
124 lib="${lib%.so}"
126 libmajor=
127 libminor=
128 libtiny=
129 for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]*
131 comparelib "$link"
132 done
134 libmajor=
135 libminor=
136 libtiny=
137 for link in lib$lib.so.[0-9]*.[0-9]*
139 comparelib "$link"
140 done
142 libmajor=
143 libminor=
144 libtiny=
145 for link in lib$lib.so.[0-9]*
147 comparelib "$link"
148 done
149 done
152 for i
154 processonedir "$i"
155 done