summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Roth <gaumless@gmail.com>2024-06-18 14:30:09 -0600
committerFelix Held <felix-coreboot@felixheld.de>2024-06-27 14:03:44 +0000
commit754fa0ebc678bf6c8ab503006ecc0a61ae093569 (patch)
treecaa29b86ca85bc471bd1682da9f8b865f5c917e9
parent63f24372d5f210fc49312cdd3ade9575ab826dd5 (diff)
Makefile: Update symlink target
This almost completely replaces the original symlink target for creating symbolic links from site-local into the coreboot tree. Changes include: - A comment about the format of the symlink.txt file - Verify that there are symlink.txt files before doing anything. - Note that symbolic links that already exist are being skipped. - Only use the first line of the symlink.txt file - Make sure the symbolic link to be created is inside the coreboot dir. - Output errors to STDERR - echo -e isn't supported by posix shells, so replace /t with two spaces Signed-off-by: Martin Roth <gaumless@gmail.com> Change-Id: I9b0d1b5bc19556bc41ca98519390e69ea104bd1b Reviewed-on: https://review.coreboot.org/c/coreboot/+/83122 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-by: Eric Lai <ericllai@google.com>
-rw-r--r--Makefile34
1 files changed, 25 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index fddcc5c55d..f7be19c8e6 100644
--- a/Makefile
+++ b/Makefile
@@ -487,19 +487,35 @@ sphinx:
sphinx-lint:
$(MAKE) SPHINXOPTS=-W -C Documentation sphinx
+# Look at all of the files in the SYMLINK_LIST and create the symbolic links
+# into the coreboot tree. Each symlink.txt file in site-local should be in the
+# directory linked from and have a single line with the path to the location to
+# link to. The path must be relative to the top of the coreboot directory.
symlink:
- @echo "Creating Symbolic Links.."; \
+ if [ -z "$(SYMLINK_LIST)" ]; then \
+ echo "No site-local symbolic links to create."; \
+ exit 0; \
+ fi; \
+ echo "Creating symbolic links.."; \
for link in $(SYMLINK_LIST); do \
- SYMLINK=`cat $$link`; \
- REALPATH=`realpath $$link`; \
- if [ -L "$$SYMLINK" ]; then \
+ LINKTO="$(top)/$$(head -n 1 "$${link}")"; \
+ LINKFROM=$$(dirname "$$(realpath "$${link}")"); \
+ if [ -L "$${LINKTO}" ]; then \
+ echo " $${LINKTO} exists - skipping"; \
continue; \
- elif [ ! -e "$$SYMLINK" ]; then \
- echo -e "\tLINK $$SYMLINK -> $$(dirname $$REALPATH)"; \
- ln -s $$(dirname $$REALPATH) $$SYMLINK; \
+ fi; \
+ LINKTO="$$(realpath -m "$${LINKTO}")" 2>/dev/null; \
+ if [ "$${LINKTO}" = "$$(echo "$${LINKTO}" | sed "s|^$(top)||" )" ]; then \
+ echo " FAILED: $${LINKTO} is outside of current directory." >&2; \
+ continue; \
+ fi; \
+ if [ ! -e "$${LINKTO}" ]; then \
+ echo " LINK $${LINKTO} -> $${LINKFROM}"; \
+ ln -s "$${LINKFROM}" "$${LINKTO}" || \
+ echo "FAILED: Could not create link." >&2; \
else \
- echo -e "\tFAILED: $$SYMLINK exists"; \
- fi \
+ echo " FAILED: $${LINKTO} exists as a file or directory." >&2; \
+ fi; \
done
clean-symlink: