diff --git a/packages/armbian/builddeb b/packages/armbian/builddeb index 20849e6362..0163d401a5 100755 --- a/packages/armbian/builddeb +++ b/packages/armbian/builddeb @@ -249,7 +249,7 @@ cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path" if is_enabled CONFIG_OF_EARLY_FLATTREE; then # Only some architectures with OF support have this target if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then - $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install + $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/linux-image-$version" dtbs_install fi fi @@ -330,7 +330,7 @@ cat >> $tmpdir/DEBIAN/preinst <<- EOT # exit if we are running chroot if [ "\$(stat -c %d:%i /)" != "\$(stat -c %d:%i /proc/1/root/.)" ]; then exit 0; fi - check_and_unmount (){ + check_boot_dev (){ boot_device=\$(mountpoint -d /boot) for file in /dev/* ; do @@ -343,11 +343,10 @@ cat >> $tmpdir/DEBIAN/preinst <<- EOT bootfstype=\$(blkid -s TYPE -o value \$boot_partition) if [ "\$bootfstype" = "vfat" ]; then - umount /boot rm -f /boot/System.map* /boot/config* /boot/vmlinuz* /boot/$image_name /boot/uImage fi } - mountpoint -q /boot && check_and_unmount + mountpoint -q /boot && check_boot_dev exit 0 EOT diff --git a/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup new file mode 100755 index 0000000000..8269927c9e --- /dev/null +++ b/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup @@ -0,0 +1,39 @@ +#!/bin/sh + +version="$1" + +[ -x /usr/sbin/update-initramfs ] || exit 0 + +# passing the kernel version is required +if [ -z "$version" ]; then + echo >&2 "W: initramfs-tools: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number" + exit 0 +fi + +# 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 + +MOD_DIR=/lib/modules/ + +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=$(df -h | awk '/boot$/{print $4}') + 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/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup new file mode 100755 index 0000000000..c4c94725b2 --- /dev/null +++ b/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup @@ -0,0 +1,39 @@ +#!/bin/sh + +version="$1" + +[ -x /usr/sbin/update-initramfs ] || exit 0 + +# passing the kernel version is required +if [ -z "$version" ]; then + echo >&2 "W: initramfs-tools: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number" + exit 0 +fi + +# 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 + +MOD_DIR=/lib/modules/ + +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=$(df -h | awk '/boot$/{print $4}') + 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/preinst.d/initramfs-cleanup b/packages/bsp/common/etc/kernel/preinst.d/initramfs-cleanup deleted file mode 100755 index 553ce96dc7..0000000000 --- a/packages/bsp/common/etc/kernel/preinst.d/initramfs-cleanup +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -version="$1" - -[ -x /usr/sbin/update-initramfs ] || exit 0 - -# passing the kernel version is required -if [ -z "$version" ]; then - echo >&2 "W: initramfs-tools: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number" - exit 0 -fi - -# avoid running multiple times -if [ -n "$DEB_MAINT_PARAMS" ]; then - eval set -- "$DEB_MAINT_PARAMS" - if [ -z "$1" ] || [ "$1" != "upgrade" ]; then - exit 0 - fi -fi - -STATEDIR=/var/lib/initramfs-tools - -version_list="$(ls -1 "$STATEDIR" | linux-version sort --reverse)" - -for v in $version_list; do - if ! linux-version compare $v eq $version; then - # try to delete delete old initrd images via update-initramfs - INITRAMFS_TOOLS_KERNEL_HOOK=y update-initramfs -d -k $v 2>/dev/null - # delete unused state files - find $STATEDIR -type f ! -name "$version" -printf "Removing obsolete file %f\n" -delete - # delete unused initrd images - find /boot -name "initrd.img*" -o -name "uInitrd-*" ! -name "*$version" -printf "Removing obsolete file %f\n" -delete - fi -done - -exit 0