#!/bin/sh # $Id: clean-usr-lib.sh,v 1.8 2006/12/29 21:07:07 dm Exp $ # # Copyright (c) 2001,2002 # by Dirk Meyer, All rights reserved. # Im Grund 4, 34317 Habichtswald, Germany # Email: dirk.meyer@dinoex.sub.org # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the author nor the names of any co-contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ------------------------------------------------------------------------- # # Synopsis: # clean /usr/lib after installworld # # Problem: # after installword, you have out of date libs which causes # problems in buiding new applications. # # My solution: # move old libs to comapt, so old applications keep running, # but new applications can only link to up-to-date libs. # # Problems: # if a shlib reaches version 10 the old one will not be moved. # the date of the last installation is assumed to be the # date of the file "/usr/lib/crti.o" # if you install without touching the date this won't work. # # Updates: # http://people.freebsd.org/~dinoex/batch/clean-usr-lib.sh # if test $# = 0 then echo >&2 echo "Usage: ${0##*/} [ 1 | 2 ]" >&2 echo >&2 sed 's/^X//' >&2 << 'EOF' X clean /usr/lib after installworld X X 1 = pass1, move shared libs to compat if a higher version exists. X X 2 = pass2, move all shared libs and links to compat if a date does X not match installation of /usr/lib/crti.o. X This pass can be dangerous ... cancel if you see libm moved. X EOF exit 64 fi case "$1" in 1) echo "pass1: move shared libs to compat if a new version is there" for i in /usr/lib/*.so.[0-9] /lib/*.so.[0-9] do j="${i%.*}" wc="$(ls ${j}.*| wc -w)" if test "${wc}" -lt 2 then continue fi old="$(ls ${j}.* | head -1)" echo \ mv -i "${old}" /usr/lib/compat/ mv -i "${old}" /usr/lib/compat/ done ;; 2) echo "pass2: move libs that are not updated" for i in /usr/lib/lib* do if test ! -f "${i}" then continue fi if test -L "${i}" then continue fi if test "${i}" -nt /usr/lib/crti.o then continue fi case "${i}" in *.so.[0-9]) echo \ mv -i "${i}" /usr/lib/compat/ mv -i "${i}" /usr/lib/compat/ continue ;; *.a) echo \ mv -i "${i}" /usr/lib/compat/ mv -i "${i}" /usr/lib/compat/ continue ;; esac echo "# unknown: ${i}" done echo "pass2: move links that are obsolete" for i in /usr/lib/lib* do if test ! -L "${i}" then continue fi if test "${i}" -nt /usr/lib/crti.o then continue fi case "${i}" in *.so.[0-9]) continue ;; *.so) echo \ mv -i "${i}" /usr/lib/compat/ mv -i "${i}" /usr/lib/compat/ continue ;; *.a) echo \ mv -i "${i}" /usr/lib/compat/ mv -i "${i}" /usr/lib/compat/ continue ;; esac echo "# unknown: ${i}" done esac # update hints ldconfig -R # # eof