mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Bugfix for packages/armbian/builddeb, packages/bsp/common/etc/kernel/preinst.d/initramfs-cleanup (#3511)
* Fix the standard location of dtb files This fix allows standard system scripts from flash-kernel, u-boot-menu packages to search in this location Signed-off-by: The-going <48602507+The-going@users.noreply.github.com> * Bugfix: No need to unmount a separate partition for the /boot These issues should be solved by system scripts. In the future, this check should be removed. * Remove unused generated file 'initrd.img-*' 'uInitrd-*' These files were generated by initramfs-tools script called postinst.d scripts. And should be removed in the postrm.d or postinst.d scripts and should be run after the initramfs-tools script and under the same conditions.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
39
packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup
Executable file
39
packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup
Executable file
@@ -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
|
||||
39
packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup
Executable file
39
packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup
Executable file
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user