]> code.ossystems Code Review - openembedded-core.git/commitdiff
utils.bbclass: ensure $0 is correct in wrapper scripts
authorRoss Burton <ross.burton@intel.com>
Thu, 30 May 2013 16:55:10 +0000 (17:55 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 30 May 2013 20:05:57 +0000 (21:05 +0100)
Some packages (eg mesa) will invoke a tool with --version and do string matches
on the output (i.e. mesa does $LEX --version |grep "^flex ").  This doesn't work
with the combination of wrapper scripts and binaries that use $0 as they output
"flex.real".

Luckily bash's exec lets you set $0.  As we want to use this we can't use env,
but using export appears to work just as well.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/utils.bbclass

index be0a25a2b9b81db38ca5165a6909014c8c3a6555..cf8893f5b45aa55937f5ac287f2d10abd5438392 100644 (file)
@@ -261,9 +261,9 @@ create_cmdline_wrapper () {
        mv $cmd $cmd.real
        cmdname=`basename $cmd`.real
        cat <<END >$cmd
-#!/bin/sh
+#!/bin/bash
 realpath=\`readlink -fn \$0\`
-exec \`dirname \$realpath\`/$cmdname $@ "\$@"
+exec -a $cmd \`dirname \$realpath\`/$cmdname $@ "\$@"
 END
        chmod +x $cmd
 }
@@ -284,9 +284,10 @@ create_wrapper () {
        mv $cmd $cmd.real
        cmdname=`basename $cmd`.real
        cat <<END >$cmd
-#!/bin/sh
+#!/bin/bash
 realpath=\`readlink -fn \$0\`
-exec env $@ \`dirname \$realpath\`/$cmdname "\$@"
+export $@
+exec -a $cmd \`dirname \$realpath\`/$cmdname "\$@"
 END
        chmod +x $cmd
 }