From ebf6b3c187684afbdb018fe7b07925679ce0aa07 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Tue, 18 Jun 2024 14:50:23 -0600 Subject: Makefile: update clean-symlink target This almost completely replaces the original clean-symlink target to remove links from site-local into the coreboot tree. Changes include: - Symbolic links removed are based on the EXTERNAL_SYMLINKS value of symlink.txt files under site-local. - Verify that there are site-local symlink.txt files to work on before doing anything. - Verify that the symlink.txt files reference links inside the coreboot directory. - Print out whether or not there are remaining symbolic links in the tree. Signed-off-by: Martin Roth Change-Id: Ife0e7cf1b856b7394cd5e1de9b35856bd984663c Reviewed-on: https://review.coreboot.org/c/coreboot/+/83124 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Elyes Haouas --- Makefile | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 60570a0571..2dddaabc89 100644 --- a/Makefile +++ b/Makefile @@ -519,11 +519,35 @@ symlink: done clean-symlink: - @echo "Deleting symbolic link";\ - EXISTING_SYMLINKS=`find -L ./src -xtype l | grep -v 3rdparty`; \ - for link in $$EXISTING_SYMLINKS; do \ - echo -e "\tUNLINK $$link"; \ - rm "$$link"; \ + if [ -z "$(SYMLINK_LIST)" ]; then \ + echo "No site-local symbolic links to clean."; \ + exit 0; \ + fi; \ + echo "Removing site-local symbolic links from tree.."; \ + for link in $(SYMLINK_LIST); do \ + SYMLINK="$(top)/$$(head -n 1 "$${link}")"; \ + if [ "$${SYMLINK}" = "$$(echo "$${SYMLINK}" | sed "s|^$(top)||")" ]; then \ + echo " FAILED: $${SYMLINK} is outside of current directory." >&2; \ + continue; \ + elif [ ! -L "$${SYMLINK}" ]; then \ + echo " $${SYMLINK} does not exist - skipping"; \ + continue; \ + fi; \ + if [ -L "$${SYMLINK}" ]; then \ + REALDIR="$$(realpath "$${link}")"; \ + echo " UNLINK $${link} (linked from $${REALDIR})"; \ + rm "$${SYMLINK}"; \ + fi; \ + done; \ + EXISTING_SYMLINKS="$$(find $(top) -type l | grep -v "3rdparty\|crossgcc" )"; \ + if [ -z "$${EXISTING_SYMLINKS}" ]; then \ + echo " No remaining symbolic links found in tree."; \ + else \ + echo " Remaining symbolic links found:"; \ + for link in $${EXISTING_SYMLINKS}; do \ + echo " $${link}"; \ + done; \ + fi cleanall-symlink: echo "Deleting all symbolic links in the coreboot tree (excluding 3rdparty & crossgcc)"; \ -- cgit v1.2.3