1
0
Files
linux/debian/templates/image.postrm.in
2025-05-29 17:14:07 +03:00

63 lines
1.5 KiB
Bash

#!/bin/sh
set -e
version='@abiname@@localversion@'
image_path="/boot/@image-stem@-${version}"
have_cmd() { command -v "$1" >/dev/null || return 1 ; }
rm -f "/lib/modules/${version}/.fresh-install"
if [ "$1" != upgrade ] && have_cmd linux-update-symlinks ; then
linux-update-symlinks remove "${version}" "${image_path}"
fi
if have_cmd linux-run-hooks ; then
## linux-base (>= 4.12~)
linux-run-hooks image postrm "${version}" "${image_path}" -- "$@"
else
if [ -d /etc/kernel/postrm.d ] ; then
DEB_MAINT_PARAMS="$*" \
run-parts --report --exit-on-error \
"--arg=${version}" \
"--arg=${image_path}" \
/etc/kernel/postrm.d
fi
fi
if [ "$1" = purge ]; then
for extra_file in \
'modules.*.bin' \
modules.alias \
modules.builtin.ranges \
modules.ccwmap \
modules.dep \
modules.devname \
modules.generic_string \
modules.ieee1394map \
modules.inputmap \
modules.isapnpmap \
modules.ofmap \
modules.parportmap \
modules.pcimap \
modules.pnpbiosmap \
modules.seriomap \
modules.softdep \
modules.symbols \
modules.usbmap \
modules.weakdep \
; do
case "${extra_file}" in
*\** | *\?* )
find "/lib/modules/${version}/" -mindepth 1 -maxdepth 1 -name "${extra_file}" -exec rm -f {} +
;;
* )
rm -f "/lib/modules/${version}/${extra_file}"
;;
esac
done
rmdir "/lib/modules/${version}" || :
fi
exit 0