]> code.ossystems Code Review - openembedded-core.git/commitdiff
utils: Avoid need to relocate wrapper scripts
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 30 Jan 2017 23:08:11 +0000 (23:08 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 31 Jan 2017 23:47:27 +0000 (23:47 +0000)
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

index 549e4b82f5eea40fae28bc80f2e98214c429e56f..fe75f73a77b4b1d8d60dc24ddbd852c854063042 100644 (file)
@@ -264,10 +264,17 @@ create_cmdline_wrapper () {
 
        mv $cmd $cmd.real
        cmdname=`basename $cmd`
+       dirname=`dirname $cmd`
+       cmdoptions=$@
+       if [ "${base_prefix}" != "" ]; then
+               relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+               cmdoptions=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
+       fi
        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 +294,17 @@ create_wrapper () {
 
        mv $cmd $cmd.real
        cmdname=`basename $cmd`
+       dirname=`dirname $cmd`
+       exportstring=$@
+       if [ "${base_prefix}" != "" ]; then
+               relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+               exportstring=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
+       fi
        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