From 1c9ec236bdfcb94f2363bbbb9276fe04dbc295ea Mon Sep 17 00:00:00 2001 From: hzy Date: Thu, 20 Apr 2023 01:50:04 +0800 Subject: [PATCH] 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. --- .../kernel/postinst.d/xx-initramfs-cleanup | 27 ------------------- .../kernel/postrm.d/initramfs-remove-uInitrd | 20 ++++++++++++++ .../etc/kernel/postrm.d/xx-initramfs-cleanup | 27 ------------------- 3 files changed, 20 insertions(+), 54 deletions(-) delete mode 100755 packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup create mode 100755 packages/bsp/common/etc/kernel/postrm.d/initramfs-remove-uInitrd delete mode 100755 packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup diff --git a/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup deleted file mode 100755 index 657ef30ec5..0000000000 --- a/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup +++ /dev/null @@ -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 diff --git a/packages/bsp/common/etc/kernel/postrm.d/initramfs-remove-uInitrd b/packages/bsp/common/etc/kernel/postrm.d/initramfs-remove-uInitrd new file mode 100755 index 0000000000..4fe2093dd1 --- /dev/null +++ b/packages/bsp/common/etc/kernel/postrm.d/initramfs-remove-uInitrd @@ -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 diff --git a/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup deleted file mode 100755 index 0aabf4cd3e..0000000000 --- a/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup +++ /dev/null @@ -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