From c51f412df87e9d074c9fd882511c634719fbfe8e Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Wed, 22 Nov 2023 17:40:07 +0530 Subject: [PATCH] Flash-kernel: Add workaround for broken upgrade --- extensions/flash-kernel.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/extensions/flash-kernel.sh b/extensions/flash-kernel.sh index f264b86548..c8d99b2243 100644 --- a/extensions/flash-kernel.sh +++ b/extensions/flash-kernel.sh @@ -64,6 +64,41 @@ post_family_tweaks_bsp__remove_uboot_flash_kernel() { find "$destination" -type f | grep -e "uboot" -e "u-boot" | xargs rm } +# Make sure we don't try to install or remove /boot/dtb-$kvers directory +post_family_tweaks_bsp__add_workaround_to_handle_upgrade() { + run_host_command_logged mkdir -p "${destination}"/etc/kernel/post{inst,rm}.d + + # Make sure flash kernel doesn't try to remove or install symlink at /boot/dtb-$kvers + # as linux-dtb package uses the same. + run_host_command_logged cat <<- '00_fix_boot_dtb_kvers' > "${destination}"/etc/kernel/postinst.d/00-fix-flash-kernel + #!/bin/sh + + grep /boot/dtb- /usr/share/flash-kernel/functions | grep -vq '^#' + + if [ $? -eq 0 ] ; then + sed -i '/\/boot\/dtb-/s/^/#/g' /usr/share/flash-kernel/functions + fi + 00_fix_boot_dtb_kvers + + # Now that flash-kernel is done running, remove the comment so that flash-kernel package + # won't report the file as modified + run_host_command_logged cat <<- 'zzz_revert_fix_boot_dtb_kvers' > "${destination}"/etc/kernel/postinst.d/zzz-fix-flash-kernel + #!/bin/sh + + grep /boot/dtb- /usr/share/flash-kernel/functions | grep -q '^#' + + if [ $? -eq 0 ] ; then + sed -i '/\/boot\/dtb-/s/^#//g' /usr/share/flash-kernel/functions + fi + zzz_revert_fix_boot_dtb_kvers + + run_host_command_logged cp "${destination}"/etc/kernel/post{inst,rm}.d/00-fix-flash-kernel + run_host_command_logged chmod a+rx "${destination}"/etc/kernel/post{inst,rm}.d/00-fix-flash-kernel + + run_host_command_logged cp "${destination}"/etc/kernel/post{inst,rm}.d/zzz-fix-flash-kernel + run_host_command_logged chmod a+rx "${destination}"/etc/kernel/post{inst,rm}.d/zzz-fix-flash-kernel +} + pre_umount_final_image__remove_uboot_initramfs_hook_flash_kernel() { # even if BSP still contained this (cached .deb), make sure by removing from ${MOUNT} [[ -f "$MOUNT"/etc/initramfs/post-update.d/99-uboot ]] && rm -v "$MOUNT"/etc/initramfs/post-update.d/99-uboot