From 039ec8ae7a35047cd4af1b08e4fe6367efa39708 Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Tue, 8 Apr 2025 15:14:09 -0400 Subject: [PATCH] Makefiles: real.remove_canary_files-extract_patch_rebuild_what_changed updated so that it wipes things correctly Signed-off-by: Thierry Laurion --- Makefile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Makefile b/Makefile index 271dd4e8..997640b7 100644 --- a/Makefile +++ b/Makefile @@ -906,6 +906,29 @@ define overwrite_canary_if_coreboot_git echo "INFO: Recreating .canary file for 'build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)' with placeholder."; \ echo BOGUS_COMMIT_ID > "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.canary"; \ echo "NOTE: If a patch fails to apply, some files might need to be deleted manually to resolve conflicts."; \ + echo "INFO: Reversing patches dynamically in reverse order."; \ + failed_patches=""; \ + for patch in $(shell ls patches/coreboot-$(CONFIG_COREBOOT_VERSION)/*.patch | sort -r); do \ + echo "INFO: Reversing patch file: $$patch"; \ + if ! ( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < $$patch ); then \ + echo "WARNING: Failed to reverse patch file: $$patch"; \ + failed_patches="$$failed_patches $$patch"; \ + fi; \ + done; \ + if [ -r patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch ]; then \ + echo "INFO: Reversing main patch file patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch."; \ + if ! ( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch ); then \ + echo "WARNING: Failed to reverse main patch file patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch"; \ + failed_patches="$$failed_patches patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch"; \ + fi; \ + fi; \ + if [ -n "$$failed_patches" ]; then \ + echo "WARNING: The following patches failed to reverse: $$failed_patches"; \ + else \ + echo "INFO: All patches reversed successfully."; \ + fi; \ + echo "INFO: Removing .patched file to allow reapplication of patches."; \ + rm -f "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.patched"; \ else \ echo "INFO: Coreboot directory or .git not found, skipping .canary overwrite."; \ fi