11949be05Schristos#!/bin/sh 2*11a6dbe7Smartin# $NetBSD: checkoldver,v 1.3 2008/04/30 13:10:50 martin Exp $ 31949be05Schristos# 41949be05Schristos# Copyright (c) 2002 The NetBSD Foundation, Inc. 51949be05Schristos# All rights reserved. 61949be05Schristos# 71949be05Schristos# This code is derived from software contributed to The NetBSD Foundation 81949be05Schristos# by Christos Zoulas. 91949be05Schristos# 101949be05Schristos# Redistribution and use in source and binary forms, with or without 111949be05Schristos# modification, are permitted provided that the following conditions 121949be05Schristos# are met: 131949be05Schristos# 1. Redistributions of source code must retain the above copyright 141949be05Schristos# notice, this list of conditions and the following disclaimer. 151949be05Schristos# 2. Redistributions in binary form must reproduce the above copyright 161949be05Schristos# notice, this list of conditions and the following disclaimer in the 171949be05Schristos# documentation and/or other materials provided with the distribution. 181949be05Schristos# 191949be05Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201949be05Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211949be05Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221949be05Schristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231949be05Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241949be05Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251949be05Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261949be05Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271949be05Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281949be05Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291949be05Schristos# POSSIBILITY OF SUCH DAMAGE. 301949be05Schristos# 311949be05Schristos# checkoldver [dir ...] 321949be05Schristos# 331949be05Schristos# Looks in the given directories for old shared libraries and lists them 341949be05Schristos# Useful for: 'checkoldver /usr/lib | xargs rm -f' 351949be05Schristos 361949be05Schristosdelete() { 37075b8347Schristos obsol="$1.so" 381949be05Schristos if [ ! -z "$2" ] 391949be05Schristos then 401949be05Schristos obsol="$obsol.$2" 411949be05Schristos fi 421949be05Schristos if [ ! -z "$3" ] 431949be05Schristos then 441949be05Schristos obsol="$obsol.$3" 451949be05Schristos fi 461949be05Schristos if [ ! -z "$4" ] 471949be05Schristos then 481949be05Schristos obsol="$obsol.$4" 491949be05Schristos fi 501949be05Schristos echo $PWD/$obsol 511949be05Schristos} 521949be05Schristos 531949be05Schristoscomparelib() { 541949be05Schristos OIFS="$IFS" 551949be05Schristos IFS="$IFS." 561949be05Schristos set -- $1 571949be05Schristos IFS="$OIFS" 581949be05Schristos if [ "$3" = "[0-9]*" ] 591949be05Schristos then 601949be05Schristos return 611949be05Schristos fi 621949be05Schristos 631949be05Schristos if [ -z "$libmajor" ] 641949be05Schristos then 651949be05Schristos libname="$1" 661949be05Schristos libmajor="$3" 671949be05Schristos libminor="$4" 681949be05Schristos libtiny="$5" 691949be05Schristos return 701949be05Schristos fi 711949be05Schristos if [ "$libmajor" -lt "$3" ] 721949be05Schristos then 731949be05Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 741949be05Schristos libmajor="$3" 751949be05Schristos libminor="$4" 761949be05Schristos libtiny="$5" 771949be05Schristos return 781949be05Schristos elif [ "$3" -lt "$libmajor" ] 791949be05Schristos then 801949be05Schristos delete "$libname" "$3" "$4" "$5" 811949be05Schristos return 821949be05Schristos fi 831949be05Schristos 841949be05Schristos if [ -z "$libminor" ] 851949be05Schristos then 861949be05Schristos return 871949be05Schristos fi 881949be05Schristos if [ "$libminor" -lt "$4" ] 891949be05Schristos then 901949be05Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 911949be05Schristos libmajor="$3" 921949be05Schristos libminor="$4" 931949be05Schristos libtiny="$5" 941949be05Schristos return 951949be05Schristos elif [ "$4" -lt "$libminor" ] 961949be05Schristos then 971949be05Schristos delete "$libname" "$3" "$4" "$5" 981949be05Schristos return 991949be05Schristos fi 1001949be05Schristos 1011949be05Schristos if [ -z "$libtiny" ] 1021949be05Schristos then 1031949be05Schristos return 1041949be05Schristos fi 1051949be05Schristos if [ "$libtiny" -lt "$5" ] 1061949be05Schristos then 1071949be05Schristos delete "$libname" "$libmajor" "$libminor" "$libtiny" 1081949be05Schristos libmajor="$3" 1091949be05Schristos libminor="$4" 1101949be05Schristos libtiny="$5" 1111949be05Schristos return 1121949be05Schristos elif [ "$5" -lt "$libminor" ] 1131949be05Schristos then 1141949be05Schristos delete "$libname" "$3" "$4" "$5" 1151949be05Schristos return 1161949be05Schristos fi 1171949be05Schristos} 1181949be05Schristos 1191949be05Schristosprocessonedir() { 1201949be05Schristos cd "$1" 1211949be05Schristos for lib in lib*.so 1221949be05Schristos do 1231949be05Schristos lib="${lib#lib}" 1241949be05Schristos lib="${lib%.so}" 1251949be05Schristos 1261949be05Schristos libmajor= 1271949be05Schristos libminor= 1281949be05Schristos libtiny= 1291949be05Schristos for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]* 1301949be05Schristos do 1311949be05Schristos comparelib "$link" 1321949be05Schristos done 1331949be05Schristos 1341949be05Schristos libmajor= 1351949be05Schristos libminor= 1361949be05Schristos libtiny= 1371949be05Schristos for link in lib$lib.so.[0-9]*.[0-9]* 1381949be05Schristos do 1391949be05Schristos comparelib "$link" 1401949be05Schristos done 1411949be05Schristos 1421949be05Schristos libmajor= 1431949be05Schristos libminor= 1441949be05Schristos libtiny= 1451949be05Schristos for link in lib$lib.so.[0-9]* 1461949be05Schristos do 1471949be05Schristos comparelib "$link" 1481949be05Schristos done 1491949be05Schristos done 1501949be05Schristos} 1511949be05Schristos 1521949be05Schristosfor i 1531949be05Schristosdo 1541949be05Schristos processonedir "$i" 1551949be05Schristosdone 156