Skip to content

Commit d87a8aa

Browse files
mcpratynezz
authored andcommitted
treewide: add ORIG_PATH variable
Add a variable that stores the original value of $PATH in the host system's shell, before Make alters it. This can be useful for when it is necessary to ignore symlinks and programs made by the build system. Define this new variable before all instances of 'export PATH:=' or similar. Signed-off-by: Michael Pratt <mcpratt@pm.me>
1 parent 1bad93c commit d87a8aa

File tree

7 files changed

+9
-0
lines changed

7 files changed

+9
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
1515
world:
1616

1717
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
18+
19+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
1820
export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
1921

2022
ifneq ($(OPENWRT_BUILD),1)

include/scan.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
1111
FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
1212
OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
1313

14+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
1415
export PATH:=$(STAGING_DIR_HOST)/bin:$(PATH)
1516

1617
define feedname

include/toplevel.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ space:= $(empty) $(empty)
5050
path:=$(subst :,$(space),$(PATH))
5151
path:=$(filter-out .%,$(path))
5252
path:=$(subst $(space),:,$(path))
53+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
5354
export PATH:=$(path)
5455
export STAGING_DIR_HOST:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host),$(TOPDIR)/staging_dir/host)
5556

rules.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ else
227227
endif
228228
endif
229229

230+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
230231
export PATH:=$(TARGET_PATH)
231232
export STAGING_DIR STAGING_DIR_HOST STAGING_DIR_HOSTPKG
232233
export SH_FUNC:=. $(INCLUDE_DIR)/shell.sh;

target/imagebuilder/files/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export TOPDIR LC_ALL LANG
1313
export OPENWRT_VERBOSE=s
1414
all: help
1515

16+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
1617
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
1718

1819
ifneq ($(OPENWRT_BUILD),1)

target/sdk/files/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export TOPDIR LC_ALL LANG SDK
1515
world:
1616

1717
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
18+
19+
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
1820
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
1921

2022
ifneq ($(OPENWRT_BUILD),1)

target/toolchain/files/wrapper.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ TOOLCHAIN_BIN_DIR="$REALNAME_DIR/"
4343

4444
# Set the PATH so that our run-time location is first
4545
# (get_feature is run from the path, so this has to be set)
46+
export ORIG_PATH=${ORIG_PATH:-$PATH}
4647
export PATH="$TOOLCHAIN_BIN_DIR":$PATH
4748
export GCC_HONOUR_COPTS
4849

0 commit comments

Comments
 (0)