Compare commits

...

3 Commits

Author SHA1 Message Date
hzy
809b8cda9f Copy instand of move the boot files for symbolic-unsupported /boot filesystem
Just for keeping them
2023-05-28 23:37:12 +08:00
hzy
ad81c77110 Not to remove files under /boot when install kernel.
`System.map-*`, `config-*` and `vmlinuz-*` will be removed by apt.
`$image_name` or `uImage` will be overrided by `postinst` script.

So we don't need to do any clean in here.

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

This reverts commit 6c758e68b4.
2023-05-28 23:37:12 +08:00
hzy
1c9ec236bd Only remove the special uInitrd when remove kernel
`initrd.img-${version}` will be remove by command `update-initramfs -d -k "${version}"`,
so we don't need to care about it.
2023-05-28 23:37:12 +08:00
5 changed files with 30 additions and 68 deletions

View File

@@ -274,21 +274,14 @@ 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
if is_boot_dev_vfat; then
rm -f /boot/System.map* /boot/config* /boot/vmlinuz* /boot/$image_name /boot/uImage
fi
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 # image_name="${NAME_KERNEL}", above
touch /boot/.next
if is_boot_dev_vfat; then
echo "Armbian: FAT32 /boot: move last-installed kernel to '$image_name'..."
mv -v /${installed_image_path} /boot/${image_name}
echo "Armbian: FAT32 /boot: copy last-installed kernel to '$image_name'..."
cp -vf "/${installed_image_path}" "/boot/${image_name}.new"
mv -vf "/boot/${image_name}.new" "/boot/${image_name}"
else
echo "Armbian: update last-installed kernel symlink to '$image_name'..."
ln -sfv $(basename "${installed_image_path}") /boot/$image_name
@@ -346,8 +339,10 @@ function kernel_package_callback_linux_dtb() {
echo "Armbian: DTB: symlinking /boot/dtb to /boot/dtb-${kernel_version_family}..."
ln -sfTv "dtb-${kernel_version_family}" dtb
else
echo "Armbian: DTB: FAT32: moving /boot/dtb-${kernel_version_family} to /boot/dtb ..."
mv -v "dtb-${kernel_version_family}" dtb
echo "Armbian: DTB: FAT32: copying /boot/dtb-${kernel_version_family} to /boot/dtb ..."
rm -rf "dtb.new"
cp -r "dtb-${kernel_version_family}" "dtb.new"
mv "dtb.new" "dtb"
fi
EOT
)

View File

@@ -8,8 +8,9 @@ mkimage -A $INITRD_ARCH -O linux -T ramdisk -C gzip -n uInitrd -d $2 $tempname
echo "update-initramfs: Armbian: Symlinking ${tempname} to /boot/uInitrd" >&2
ln -sfv $(basename $tempname) /boot/uInitrd || {
echo "update-initramfs: Symlink failed, moving ${tempname} to /boot/uInitrd" >&2
mv -v $tempname /boot/uInitrd
echo "update-initramfs: Symlink failed, copying ${tempname} to /boot/uInitrd" >&2
cp -vf "$tempname" "/boot/uInitrd.new"
mv -vf "/boot/uInitrd.new" "/boot/uInitrd"
}
echo "update-initramfs: Armbian: done." >&2

View File

@@ -1,27 +0,0 @@
#!/bin/sh
# echo "DEBUG: postinst: initramfs-clean: cmd: $@" >&2
# avoid running multiple times
# This script should be run after the initramfs-tools script
# and under the same conditions.
if [ -n "$DEB_MAINT_PARAMS" ]; then
eval set -- "$DEB_MAINT_PARAMS"
if [ -z "$1" ] || [ "$1" != "configure" ]; then
exit 0
fi
fi
files="$(find /boot -maxdepth 1 -name 'initrd.img-*' -o -name 'uInitrd-*')"
for f in $files; do
if [ ! -d /lib/modules/"${f#*-}" ]; then
echo "Remove unused generated file: $f"; rm $f
fi
done
check_boot_dev (){
available_size_boot_device=$(findmnt --noheadings --output AVAIL --target /boot)
echo "Free space after deleting the package $DPKG_MAINTSCRIPT_PACKAGE in /boot: $available_size_boot_device" >&2
}
mountpoint -q /boot && check_boot_dev
exit 0

View File

@@ -0,0 +1,20 @@
#!/bin/sh
# Remove /boot/uInitrd-${version} created by /etc/initramfs/post-update.d/99-uboot
# Unfortunately, `update-initramfs` only support `post-update.d`, doesn't have something like `post-delete.d`
# So let's clean it when we remove a kernel.
version="$1"
# avoid running multiple times
# Use the same conditions as `initramfs-tools`.
if [ -n "$DEB_MAINT_PARAMS" ]; then
eval set -- "$DEB_MAINT_PARAMS"
if [ -z "$1" ] || [ "$1" != "remove" ]; then
exit 0
fi
fi
rm -f "/boot/uInitrd-${version}"
exit 0

View File

@@ -1,27 +0,0 @@
#!/bin/sh
# echo "DEBUG: POSTRM: initramfs-clean: cmd: $@" >&2
# avoid running multiple times
# This script should be run after the initramfs-tools script
# and under the same conditions.
if [ -n "$DEB_MAINT_PARAMS" ]; then
eval set -- "$DEB_MAINT_PARAMS"
if [ -z "$1" ] || [ "$1" != "remove" ]; then
exit 0
fi
fi
files="$(find /boot -maxdepth 1 -name 'initrd.img-*' -o -name 'uInitrd-*')"
for f in $files; do
if [ ! -d /lib/modules/"${f#*-}" ]; then
echo "Remove unused generated file: $f"; rm $f
fi
done
check_boot_dev (){
available_size_boot_device=$(findmnt --noheadings --output AVAIL --target /boot)
echo "Free space after deleting the package $DPKG_MAINTSCRIPT_PACKAGE in /boot: $available_size_boot_device" >&2
}
mountpoint -q /boot && check_boot_dev
exit 0