Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/postinstall exclude shared libraries that are curre...



details:   https://anonhg.NetBSD.org/src/rev/862a999aec78
branches:  trunk
changeset: 999698:862a999aec78
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 15 13:07:09 2019 +0000

description:
exclude shared libraries that are currently in use from removal.

diffstat:

 usr.sbin/postinstall/postinstall.in |  43 ++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r 9720eeef18aa -r 862a999aec78 usr.sbin/postinstall/postinstall.in
--- a/usr.sbin/postinstall/postinstall.in       Sat Jun 15 08:20:33 2019 +0000
+++ b/usr.sbin/postinstall/postinstall.in       Sat Jun 15 13:07:09 2019 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.4 2019/06/14 14:39:49 christos Exp $
+# $NetBSD: postinstall.in,v 1.5 2019/06/15 13:07:09 christos Exp $
 #
 # Copyright (c) 2002-2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -566,6 +566,37 @@
        _obsolete_libs "/usr/libdata/debug/${dir}"
 }
 
+exclude()
+{
+       local dollar
+       case "$1" in
+       -t)
+               dollar='$'
+               shift
+               ;;
+       *)
+               dollar=
+               ;;
+       esac
+       if [ -z "$*" ]; then
+               cat
+       else
+               eval ${GREP} -v -E "'(^$(echo $* | \
+                   ${SED} -e s/\\./\\\\./g -e 's/ /'${dollar}'|^/'g)${dollar})'"
+       fi
+}
+
+#
+# find all the target symlinks of shared libaries and exclude them
+# from consideration for removal
+#
+exclude_libs() {
+       local target="$(ls -l lib*.so.* \
+           | ${AWK} '{ print $11; }' \
+           | ${SED} -e 's@.*/@@' | ${SORT} -u)"
+       exclude -t ${target}
+}
+
 _obsolete_libs()
 {
        dir="$1"
@@ -622,7 +653,7 @@
                checklib(major, $0, "^lib.*\\.so\\.")
 }
 
-#}'
+#}' | exclude_libs
 
        )
 }
@@ -1437,14 +1468,6 @@
        ${SED} -n -e "/obsolete/s@\.$1$2[[:space:]].*@\1@p" $3
 }
 
-exclude()
-{
-       if [ -z "$*" ]; then
-               cat
-       else
-               eval ${GREP} -v -E "'(^$(echo $* | sed -e 's/ /|^/'g))'"
-       fi
-}
 
 getetcsets()
 {



Home | Main Index | Thread Index | Old Index