From a not yet released release of slackpkg, a piterpunk's merge

Checks if a critical package were upgraded by Slackpkg.
The /var/run/needs_restarting file contains the list of upgraded
packages.

The file only is created if /var/run filesystem type is tmpfs so
the reboot will clean it
This commit is contained in:
Matteo Rossini 2022-01-14 19:29:55 +01:00
parent 45204d0eb2
commit 75ef6ead71

View file

@ -107,6 +107,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
# function internal_blacklist() # function internal_blacklist()
# function applyblacklist() # function applyblacklist()
# function cleanup() # function cleanup()
# function needs_restarting()
# function handle_event() # function handle_event()
# function remove_pkg() # function remove_pkg()
# function installpkg() // if DOWNLOADONLY=on override /sbin/installpkg # function installpkg() // if DOWNLOADONLY=on override /sbin/installpkg
@ -182,6 +183,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
This may happen when you upgrade from slackware 14.2 to slackware 15.0 This may happen when you upgrade from slackware 14.2 to slackware 15.0
" >> $TMPDIR/info.log " >> $TMPDIR/info.log
fi fi
needs_restarting
if [ "$CMD" == "info" ];then if [ "$CMD" == "info" ];then
DETAILED_INFO=${DETAILED_INFO:-none} DETAILED_INFO=${DETAILED_INFO:-none}
@ -258,6 +260,39 @@ if [ "$SLACKPKGPLUS" = "on" ];then
exit $retval exit $retval
} # END function cleanup() } # END function cleanup()
# From slackpkg (with some improving)
#
# Checks if a critical package were upgraded by Slackpkg.
# The /var/run/needs_restarting file contains the list of upgraded
# packages.
#
# The file only is created if /var/run filesystem type is tmpfs so
# the reboot will clean it
function needs_restarting() {
NEED_RESTART="$(
find $ROOT/var/log/packages/ -cnewer $TMPDIR/timestamp -type f \( \
-name "kernel-generic-[0-9]*" -o \
-name "kernel-huge-[0-9]*" -o \
-name "openssl-solibs-[0-9]*" -o \
-name "openssl-[0-9]*" -o \
-name "glibc-[0-9]*" -o \
-name "aaa_glibc-solibs-[0-9]*" -o \
-name "eudev-[0-9]*" -o \
-name "rzip-[0-9]*" -o \
-name "elogind-[0-9]*" -o \
-name "dbus-[0-9]*" \) | \
awk -F/ '{ print $NF }'
)"
if [ ! -z "$NEED_RESTART" ];then
echo "NOTE: Some installed or upgraded package may need reboot: " >> $TMPDIR/info.log
echo "$NEED_RESTART"|sed 's/^/ /' >> $TMPDIR/info.log
if [ "$(stat -f -c %T /var/run/)" = "tmpfs" ]; then
echo "$NEED_RESTART" >> $ROOT/var/run/needs_restarting
echo "See /var/run/needs_restarting for details" >> $TMPDIR/info.log
fi
fi
}
# -- handle the event $1 that occured on packages $SHOWLIST # -- handle the event $1 that occured on packages $SHOWLIST
# #
# $1 the event that occurs, which can be install, upgrade, remove # $1 the event that occurs, which can be install, upgrade, remove