The nightly-refkit builder on the Yocto Project autobuilder is sourcing the oe-init-build-env from a parent directory of the refkit repository clone, like so: . ./refkit/oe-init-build-env This seems to work fine on some versions of GNU Bash but not on others, i.e. with Bash 4.3.48(1) on Ubuntu 16.04 this fails[1][2] but with Bash 4.2.46(1) on CentOS 7 it works[3][4]. This appears to be related to the use of BASH_SOURCE to determine the location of the oe-init-build-env. I've created a simple reproducer: $ cat test/test.sh #!/usr/bin/env sh if [ -n "$BASH_SOURCE" ]; then THIS_SCRIPT=$BASH_SOURCE elif [ -n "$ZSH_NAME" ]; then THIS_SCRIPT=$0 else THIS_SCRIPT="$(pwd)/oe-init-build-env" fi echo BASH_SOURCE=$BASH_SOURCE echo THIS_SCRIPT=$THIS_SCRIPT on a machine with a version of bash working as the script assumes: $ sh test/test.sh BASH_SOURCE=test/test.sh THIS_SCRIPT=test/test.sh whereas on a machine with a version of bash that doesn't seem to work as expected: BASH_SOURCE= THIS_SCRIPT=/home/joshuagl/test.sh The location of the script is /home/joshuagl/test/test.sh 1. https://autobuilder.yoctoproject.org/main/builders/nightly-refkit/builds/10 2. https://autobuilder.yoctoproject.org/main/builders/nightly-refkit/builds/10/steps/RunPreamble/logs/stdio 3. https://autobuilder.yoctoproject.org/main/builders/nightly-refkit/builds/11 4. https://autobuilder.yoctoproject.org/main/builders/nightly-refkit/builds/11/steps/RunPreamble/logs/stdio
(In reply to comment #0) > on a machine with a version of bash working as the script assumes: > > $ sh test/test.sh > BASH_SOURCE=test/test.sh > THIS_SCRIPT=test/test.sh > > whereas on a machine with a version of bash that doesn't seem to work as > expected: > > BASH_SOURCE= > THIS_SCRIPT=/home/joshuagl/test.sh > > The location of the script is /home/joshuagl/test/test.sh Thanks, I'll take a look. Those lines are originally from oe-core's oe-init-build-env but seems the else branch needs a fix in our case.
https://github.com/intel/intel-iot-refkit/pull/193
It seems that the problem might be in Ubuntu using dash as the default shell. The autobuilder error messages seem to indicate that /bin/sh is used: /bin/sh: 49: .: Can't open /bin/openembedded-core/oe-init-build-env The comments in oe-init-build-env-sh indicate that missing dash sourcing support is a known issue, and a workaround is proposed: https://github.com/openembedded/openembedded-core/blob/master/oe-init-build-env#L24 The best solution might be to use bash for sourcing oe-init-build-env also on Ubuntu autobuilder. This is not really a Refkit issue, moving to autobuilder.
Thanks for the insight Ismo, I'd completely forgotten that Ubuntu use dash for /bin/sh. It's unclear why the ShellCommands in buildbot use /bin/sh rather than the user's configured shell (bash, in our case) but it's clear we need to work around this. I think we'll want to either a) force the shell to bash (although that feels like it could be invasive) b) change the sourcing of the oe-init-build-env script to be sourced from the same directory the script is in and pass the full path to the build directory (a sibling directory, in the case of the refkit builder). If we go with b) we need to be aware of the caveat in oe-init-build-env[1] 'This works in most shells (not dash), but not all of them pass the arguments when being sourced. To workaround the shell limitation use "set <builddir>" prior to sourcing this script.' 1. http://git.openembedded.org/openembedded-core/tree/oe-init-build-env#n21