Skip to contentSkip to conversation

infra/pkg-generic: ensure absolute paths in config-script fixups

PATCH New Yann E. MORIN 2 participants 2 messages Nov 28, 2018 – Nov 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infra/pkg-generic: ensure absolute paths in config-script fixups

In case a config script is called from a relative path, the $(dirnale $0) would return a relative path too.

Those paths are usually parts of includes or libraries search directories, and the packagfes buildsystems may chdir() anywhere, and thus the relative path will no longer be valid. For example:

  $ ./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/net-snmp-config --cflags
  [...] -I./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../.././bin/../powerpc-buildroot-linux-uclibc/sysroot/usr/include/libnl3 [...]

Canonicalise the path to be sure we use absolute paths.

Cc Thomas Petazzoni <[email protected]>
---
 package/pkg-generic.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
package/pkg-generic.mk +2 -2
index 887dc838a4..649a7ad187 100644
@@ -280,8 +280,8 @@ $(BUILD_DIR)/%/.stamp_staging_installed:
 				-e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
 				-e "s,-I/usr/,-I at STAGING_DIR@/usr/,g" \
 				-e "s,-L/usr/,-L at STAGING_DIR@/usr/,g" \
-				-e 's, at STAGING_DIR@,$$(dirname $$0)/../..,g' \
-				-e 's, at HOST_DIR@,$$(dirname $$0)/../../../..,g' \
+				-e 's, at STAGING_DIR@,$$(dirname $$(realpath -e $$0))/../..,g' \
+				-e 's, at HOST_DIR@,$$(dirname $$(realpath -e $$0))/../../../..,g' \
 				-e "s, at BASE_DIR@,$(BASE_DIR),g" \
 				$(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
 	fi
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 infra/pkg-generic: ensure absolute paths in config-script fixups

Hello,

Quoted 10 lines · Yann E. MORIN

In case a config script is called from a relative path, the $(dirnale $0) would return a relative path too.

Those paths are usually parts of includes or libraries search directories, and the packagfes buildsystems may chdir() anywhere, and thus the relative path will no longer be valid. For example:

  $ ./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/net-snmp-config --cflags
  [...] -I./host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../.././bin/../powerpc-buildroot-linux-uclibc/sysroot/usr/include/libnl3 [...]
Quoted 7 lines

Canonicalise the path to be sure we use absolute paths.

Cc Thomas Petazzoni <[email protected]>
---
 package/pkg-generic.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to next, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com