checkoldver revision 1.2
11.1Schristos#!/bin/sh 21.2Schristos# $NetBSD: checkoldver,v 1.2 2003/10/25 07:53:12 christos Exp $ 31.1Schristos# 41.1Schristos# Copyright (c) 2002 The NetBSD Foundation, Inc. 51.1Schristos# All rights reserved. 61.1Schristos# 71.1Schristos# This code is derived from software contributed to The NetBSD Foundation 81.1Schristos# by Christos Zoulas. 91.1Schristos# 101.1Schristos# Redistribution and use in source and binary forms, with or without 111.1Schristos# modification, are permitted provided that the following conditions 121.1Schristos# are met: 131.1Schristos# 1. Redistributions of source code must retain the above copyright 141.1Schristos# notice, this list of conditions and the following disclaimer. 151.1Schristos# 2. Redistributions in binary form must reproduce the above copyright 161.1Schristos# notice, this list of conditions and the following disclaimer in the 171.1Schristos# documentation and/or other materials provided with the distribution. 181.1Schristos# 3. All advertising materials mentioning features or use of this software 191.1Schristos# must display the following acknowledgement: 201.1Schristos# This product includes software developed by the NetBSD 211.1Schristos# Foundation, Inc. and its contributors. 221.1Schristos# 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Schristos# contributors may be used to endorse or promote products derived 241.1Schristos# from this software without specific prior written permission. 251.1Schristos# 261.1Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Schristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Schristos# POSSIBILITY OF SUCH DAMAGE. 371.1Schristos# 381.1Schristos# checkoldver [dir ...] 391.1Schristos# 401.1Schristos# Looks in the given directories for old shared libraries and lists them 411.1Schristos# Useful for: 'checkoldver /usr/lib | xargs rm -f' 421.1Schristos 431.1Schristosdelete() { 441.2Schristos obsol="$1.so" 451.1Schristos if [ ! -z "$2" ] 461.1Schristos then 471.1Schristos obsol="$obsol.$2" 481.1Schristos fi 491.1Schristos if [ ! -z "$3" ] 501.1Schristos then 511.1Schristos obsol="$obsol.$3" 521.1Schristos fi 531.1Schristos if [ ! -z "$4" ] 541.1Schristos then 551.1Schristos obsol="$obsol.$4" 561.1Schristos fi 571.1Schristos echo $PWD/$obsol 581.1Schristos} 591.1Schristos 601.1Schristoscomparelib() { 611.1Schristos OIFS="$IFS" 621.1Schristos IFS="$IFS." 631.1Schristos set -- $1 641.1Schristos IFS="$OIFS" 651.1Schristos if [ "$3" = "[0-9]*" ] 661.1Schristos then 671.1Schristos return 681.1Schristos fi 691.1Schristos 701.1Schristos if [ -z "$libmajor" ] 711.1Schristos then 721.1Schristos libname="$1" 731.1Schristos libmajor="$3" 741.1Schristos libminor="$4" 751.1Schristos libtiny="$5" 761.1Schristos return 771.1Schristos fi 781.1Schristos if [ "$libmajor" -lt "$3" ] 791.1Schristos then 801.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 811.1Schristos libmajor="$3" 821.1Schristos libminor="$4" 831.1Schristos libtiny="$5" 841.1Schristos return 851.1Schristos elif [ "$3" -lt "$libmajor" ] 861.1Schristos then 871.1Schristos delete "$libname" "$3" "$4" "$5" 881.1Schristos return 891.1Schristos fi 901.1Schristos 911.1Schristos if [ -z "$libminor" ] 921.1Schristos then 931.1Schristos return 941.1Schristos fi 951.1Schristos if [ "$libminor" -lt "$4" ] 961.1Schristos then 971.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 981.1Schristos libmajor="$3" 991.1Schristos libminor="$4" 1001.1Schristos libtiny="$5" 1011.1Schristos return 1021.1Schristos elif [ "$4" -lt "$libminor" ] 1031.1Schristos then 1041.1Schristos delete "$libname" "$3" "$4" "$5" 1051.1Schristos return 1061.1Schristos fi 1071.1Schristos 1081.1Schristos if [ -z "$libtiny" ] 1091.1Schristos then 1101.1Schristos return 1111.1Schristos fi 1121.1Schristos if [ "$libtiny" -lt "$5" ] 1131.1Schristos then 1141.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 1151.1Schristos libmajor="$3" 1161.1Schristos libminor="$4" 1171.1Schristos libtiny="$5" 1181.1Schristos return 1191.1Schristos elif [ "$5" -lt "$libminor" ] 1201.1Schristos then 1211.1Schristos delete "$libname" "$3" "$4" "$5" 1221.1Schristos return 1231.1Schristos fi 1241.1Schristos} 1251.1Schristos 1261.1Schristosprocessonedir() { 1271.1Schristos cd "$1" 1281.1Schristos for lib in lib*.so 1291.1Schristos do 1301.1Schristos lib="${lib#lib}" 1311.1Schristos lib="${lib%.so}" 1321.1Schristos 1331.1Schristos libmajor= 1341.1Schristos libminor= 1351.1Schristos libtiny= 1361.1Schristos for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]* 1371.1Schristos do 1381.1Schristos comparelib "$link" 1391.1Schristos done 1401.1Schristos 1411.1Schristos libmajor= 1421.1Schristos libminor= 1431.1Schristos libtiny= 1441.1Schristos for link in lib$lib.so.[0-9]*.[0-9]* 1451.1Schristos do 1461.1Schristos comparelib "$link" 1471.1Schristos done 1481.1Schristos 1491.1Schristos libmajor= 1501.1Schristos libminor= 1511.1Schristos libtiny= 1521.1Schristos for link in lib$lib.so.[0-9]* 1531.1Schristos do 1541.1Schristos comparelib "$link" 1551.1Schristos done 1561.1Schristos done 1571.1Schristos} 1581.1Schristos 1591.1Schristosfor i 1601.1Schristosdo 1611.1Schristos processonedir "$i" 1621.1Schristosdone 163