aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Akhlaghi <mohammad@akhlaghi.org>2020-07-01 18:14:44 +0100
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2020-07-01 18:18:53 +0100
commitdeba07c43ebddc31ecdbcf520e2bbaf57e6f8027 (patch)
tree351857cdc8c2af6b28e3deb5f8757e5763f83fdc
parentaee6d612073ce9be8aef4183c5ac7688ed4733e8 (diff)
Properly accounting for space characters in host's PATH
Until now, when reading the host's PATH environment variable we weren't accounting for directory names with a space character. This was most prominently visible in the 'low-level-links' step where we put links to some core system components into the project's build directory (mainly for prorietary systems like macOS). To address the problem, double quotations have been placed around the part that we extract 'ccache' from the PATH, and the part where we make the symbolic link. In the process the comments above 'makelink' were made more clear and 'low-level-links' now depends on 'grep' (which is the highest-level program it uses). This bug was reported by Mahdieh Navabi.
-rw-r--r--reproduce/software/make/basic.mk32
1 files changed, 20 insertions, 12 deletions
diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk
index 453eddb..2c7401e 100644
--- a/reproduce/software/make/basic.mk
+++ b/reproduce/software/make/basic.mk
@@ -130,9 +130,17 @@ backupservers = $(filter-out $(topbackupserver),$(backupservers_all))
# Low-level (not built) programs
# ------------------------------
#
-# For the time being, some components of the project on some systems, so we
-# are simply making a symbolic link to the system's files here. We'll do
-# this after building GNU Coreutils to have trustable elements.
+# For the time being, some components of the project aren't being built on
+# some systems (primarily on proprietary operating systems). So we are
+# simply making a symbolic link to the system's programs/libraries in the
+# build directory.
+#
+# The logical position of this rule is irrelevant in this Makefile (because
+# programs being built here have full access to the system's PATH
+# already). This is done for the high-level programs installed in
+# 'high-level.mk', 'xorg.mk' or 'python.mk'. So this step is done after
+# building our own GNU Grep (which is the highest-level program used in
+# 'makelink') to have trustable elements.
#
# About ccache: ccache acts like a wrapper over the C compiler and is made
# to avoid/speed-up compiling of identical files in a system (it is
@@ -142,19 +150,19 @@ backupservers = $(filter-out $(topbackupserver),$(backupservers_all))
# thus remove any part of PATH of that has `ccache' in it before making
# symbolic links to the programs we are not building ourselves.
#
-# We'll need the system's PATH for making links to low-level programs we
-# won't be building ourselves.
+# The double quotations after the starting 'export PATH' are necessary in
+# case the user's PATH has space-characters in it.
syspath := $(PATH)
makelink = origpath="$$PATH"; \
- export PATH=$$(echo $(syspath) \
- | tr : '\n' \
- | grep -v ccache \
- | tr '\n' :); \
+ export PATH="$$(echo $(syspath) \
+ | tr : '\n' \
+ | grep -v ccache \
+ | tr '\n' :)"; \
if type $(1) > /dev/null 2> /dev/null; then \
if [ x$(3) = x ]; then \
- ln -sf $$(which $(1)) $(ibdir)/$(1); \
+ ln -sf "$$(which $(1))" $(ibdir)/$(1); \
else \
- ln -sf $$(which $(1)) $(ibdir)/$(3); \
+ ln -sf "$$(which $(1))" $(ibdir)/$(3); \
fi; \
else \
if [ "x$(strip $(2))" = xmandatory ]; then \
@@ -166,7 +174,7 @@ makelink = origpath="$$PATH"; \
export PATH="$$origpath"
$(ibdir) $(ildir):; mkdir $@
-$(ibidir)/low-level-links: $(ibidir)/coreutils-$(coreutils-version) \
+$(ibidir)/low-level-links: $(ibidir)/grep-$(grep-version) \
| $(ibdir) $(ildir)
# Not-installed (but necessary in some cases) compilers.