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 <gaumless@gmail.com>
Change-Id: Ife0e7cf1b856b7394cd5e1de9b35856bd984663c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83124
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <ericllai@google.com>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
Martin Roth 2024-06-18 14:50:23 -06:00 committed by Felix Held
parent f7f9fc9271
commit ebf6b3c187

View File

@ -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)"; \