checkoldver revision 1.4
11.1Schristos#!/bin/sh 21.4Schristos# $NetBSD: checkoldver,v 1.4 2024/05/28 16:20:34 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# 191.1Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Schristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Schristos# POSSIBILITY OF SUCH DAMAGE. 301.1Schristos# 311.1Schristos# checkoldver [dir ...] 321.1Schristos# 331.1Schristos# Looks in the given directories for old shared libraries and lists them 341.1Schristos# Useful for: 'checkoldver /usr/lib | xargs rm -f' 351.1Schristos 361.1Schristosdelete() { 371.2Schristos obsol="$1.so" 381.1Schristos if [ ! -z "$2" ] 391.1Schristos then 401.1Schristos obsol="$obsol.$2" 411.1Schristos fi 421.1Schristos if [ ! -z "$3" ] 431.1Schristos then 441.1Schristos obsol="$obsol.$3" 451.1Schristos fi 461.1Schristos if [ ! -z "$4" ] 471.1Schristos then 481.1Schristos obsol="$obsol.$4" 491.1Schristos fi 501.1Schristos echo $PWD/$obsol 511.1Schristos} 521.1Schristos 531.1Schristoscomparelib() { 541.4Schristos local name="${1%.so.*}" 551.4Schristos local version=${1#*.so.} 561.1Schristos OIFS="$IFS" 571.1Schristos IFS="$IFS." 581.4Schristos set -- $version 591.1Schristos IFS="$OIFS" 601.1Schristos 611.1Schristos if [ -z "$libmajor" ] 621.1Schristos then 631.4Schristos libname="$name" 641.4Schristos libmajor="$1" 651.4Schristos libminor="$2" 661.4Schristos libtiny="$3" 671.1Schristos return 681.1Schristos fi 691.4Schristos if [ "$libmajor" -lt "$1" ] 701.1Schristos then 711.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 721.4Schristos libmajor="$1" 731.4Schristos libminor="$2" 741.4Schristos libtiny="$3" 751.1Schristos return 761.4Schristos elif [ "$1" -lt "$libmajor" ] 771.1Schristos then 781.4Schristos delete "$libname" "$1" "$2" "$3" 791.1Schristos return 801.1Schristos fi 811.1Schristos 821.1Schristos if [ -z "$libminor" ] 831.1Schristos then 841.1Schristos return 851.1Schristos fi 861.4Schristos if [ "$libminor" -lt "$2" ] 871.1Schristos then 881.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 891.4Schristos libmajor="$1" 901.4Schristos libminor="$2" 911.4Schristos libtiny="$3" 921.1Schristos return 931.4Schristos elif [ "$2" -lt "$libminor" ] 941.1Schristos then 951.4Schristos delete "$libname" "$1" "$2" "$3" 961.1Schristos return 971.1Schristos fi 981.1Schristos 991.1Schristos if [ -z "$libtiny" ] 1001.1Schristos then 1011.1Schristos return 1021.1Schristos fi 1031.4Schristos if [ "$libtiny" -lt "$3" ] 1041.1Schristos then 1051.1Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 1061.4Schristos libmajor="$1" 1071.4Schristos libminor="$2" 1081.4Schristos libtiny="$3" 1091.1Schristos return 1101.1Schristos elif [ "$5" -lt "$libminor" ] 1111.1Schristos then 1121.4Schristos delete "$libname" "$1" "$2" "$3" 1131.1Schristos return 1141.1Schristos fi 1151.1Schristos} 1161.1Schristos 1171.1Schristosprocessonedir() { 1181.1Schristos cd "$1" 1191.1Schristos for lib in lib*.so 1201.1Schristos do 1211.1Schristos lib="${lib#lib}" 1221.1Schristos lib="${lib%.so}" 1231.1Schristos 1241.1Schristos libmajor= 1251.1Schristos libminor= 1261.1Schristos libtiny= 1271.1Schristos for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]* 1281.1Schristos do 1291.1Schristos comparelib "$link" 1301.1Schristos done 1311.1Schristos 1321.1Schristos libmajor= 1331.1Schristos libminor= 1341.1Schristos libtiny= 1351.1Schristos for link in lib$lib.so.[0-9]*.[0-9]* 1361.1Schristos do 1371.1Schristos comparelib "$link" 1381.1Schristos done 1391.1Schristos 1401.1Schristos libmajor= 1411.1Schristos libminor= 1421.1Schristos libtiny= 1431.1Schristos for link in lib$lib.so.[0-9]* 1441.1Schristos do 1451.1Schristos comparelib "$link" 1461.1Schristos done 1471.1Schristos done 1481.1Schristos} 1491.1Schristos 1501.1Schristosfor i 1511.1Schristosdo 1521.1Schristos processonedir "$i" 1531.1Schristosdone 154