remove files in /boot at preinst when bootfs is vfat (#4886)

* remove files in /boot at preinst when bootfs is vfat

* use findmnt to get /boot source device
This commit is contained in:
Jianfeng Liu 2023-03-01 20:42:09 +08:00 committed by GitHub
parent 755479f407
commit 6c758e68b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -235,6 +235,19 @@ function kernel_package_callback_linux_image() {
test -d ${debian_kernel_hook_dir}/${script}.d && run-parts --arg="${kernel_version_family}" --arg="/${installed_image_path}" ${debian_kernel_hook_dir}/${script}.d
KERNEL_HOOK_DELEGATION
if [[ "${script}" == "preinst" ]]; then
cat <<- HOOK_FOR_REMOVE_VFAT_BOOT_FILES
check_boot_dev (){
boot_partition=\$(findmnt -n -o SOURCE /boot)
bootfstype=\$(blkid -s TYPE -o value \$boot_partition)
if [ "\$bootfstype" = "vfat" ]; then
rm -f /boot/System.map* /boot/config* /boot/vmlinuz* /boot/$image_name /boot/uImage
fi
}
mountpoint -q /boot && check_boot_dev
HOOK_FOR_REMOVE_VFAT_BOOT_FILES
fi
# @TODO: only if u-boot, only for postinst. Gotta find a hook scheme for these...
if [[ "${script}" == "postinst" ]]; then
cat <<- HOOK_FOR_LINK_TO_LAST_INSTALLED_KERNEL