
# Set this to enable installpkg to process this installation script prior
# to unpacking the archive.  This enables us to capture the firmware for the
# live Kernel modules before they're wiped by the upgrade process.
# ALWAYS_RUN_INSTALL_SCRIPT
#
# Create an inventory cache during the pre-installation run of this
# package installation script.
# This will silently fail on the 2nd run due to the modules for the running
# Kernel having been removed, however that's fine since we captured the
# firmware inventory at the pre-install phase.
# The direction of output to /dev/null is only to enable the initial upgrade
# to a newer os-initrd-mgr that supports the -O option; otherwise on the
# first upgrade (if kernel-mods is upgraded first), the user will see a
# wall of --help text from os-initrd-mgr.
# This redirection can be removed in the future.
[ -x usr/sbin/os-initrd-mgr ] && chroot . /usr/sbin/os-initrd-mgr -qO > /dev/null 2>&1

# A good idea whenever kernel modules are added or changed.
# However, the modules dependency list is generated by the Kernel package
# build script ('k/kernel.SlackBuild') at build time.  Therefore we'll only
# run depmod if the dependencies list is absent (not sure why that'd happen
# but it's a reasonably sanity check).
if [ -x sbin/depmod ]; then
   [ ! -f lib/modules/6.6.28-armv8/modules.dep ] && chroot . /sbin/depmod -a 6.6.28-armv8 1> /dev/null 2> /dev/null
fi

( cd lib/modules/6.6.28-armv8 ; rm -rf build )
( cd lib/modules/6.6.28-armv8 ; ln -sf ../../../usr/src/linux-6.6.28 build )
( cd lib/modules/6.6.28-armv8 ; rm -rf source )
( cd lib/modules/6.6.28-armv8 ; ln -sf ../../../usr/src/ source )
