Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/5] utils: Avoid need to relocate wrapper scripts
@ 2017-01-31  0:14 Richard Purdie
  2017-01-31  0:14 ` [PATCH 2/5] relocatable: Make native .pc files relocatable Richard Purdie
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Richard Purdie @ 2017-01-31  0:14 UTC (permalink / raw)
  To: openembedded-core

Whilst the path to the executable is dynamically determined, the passed in
environment variables or parameters are not relocatable and rely on the sstate
remapping code. In the recipe specific sysroot case this has become more costly.

This patch translates such paths into relocatable entries which means that
a sed replacement at final installation isn't needed.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/utils.bbclass | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index 549e4b8..16f42b4 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -264,10 +264,14 @@ create_cmdline_wrapper () {
 
 	mv $cmd $cmd.real
 	cmdname=`basename $cmd`
+	dirname=`dirname $cmd`
+	relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+	cmdoptions=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
 	cat <<END >$cmd
 #!/bin/bash
 realpath=\`readlink -fn \$0\`
-exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real $@ "\$@"
+realdir=\`dirname \$realpath\`
+exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real $cmdoptions "\$@"
 END
 	chmod +x $cmd
 }
@@ -287,10 +291,14 @@ create_wrapper () {
 
 	mv $cmd $cmd.real
 	cmdname=`basename $cmd`
+	dirname=`dirname $cmd`
+	relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+	exportstring=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
 	cat <<END >$cmd
 #!/bin/bash
 realpath=\`readlink -fn \$0\`
-export $@
+realdir=\`dirname \$realpath\`
+export $exportstring
 exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real "\$@"
 END
 	chmod +x $cmd
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-31  2:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-31  0:14 [PATCH 1/5] utils: Avoid need to relocate wrapper scripts Richard Purdie
2017-01-31  0:14 ` [PATCH 2/5] relocatable: Make native .pc files relocatable Richard Purdie
2017-01-31  0:14 ` [PATCH 3/5] distro/defaultsetup: Enable removal of libtool .la files by default Richard Purdie
2017-01-31  0:14 ` [PATCH 4/5] binutils-cross: Remove exec_prefix from the linker search path Richard Purdie
2017-01-31  0:14 ` [PATCH 5/5] xmlto: Don't hardcode the path to tail Richard Purdie
2017-01-31  0:23 ` ✗ patchtest: failure for "utils: Avoid need to relocate ..." and 4 more Patchwork
2017-01-31  2:37 ` [PATCH 1/5] utils: Avoid need to relocate wrapper scripts Christopher Larson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox