<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>11640</bug_id>
          
          <creation_ts>2017-06-09 14:14:27 +0000</creation_ts>
          <short_desc>Autobuilder calls exec on `. ./oe-init-build-env`, which fails on systems with /bin/sh set to dash</short_desc>
          <delta_ts>2017-07-11 15:10:43 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>5</classification_id>
          <classification>Infrastructure</classification>
          <product>AutoBuilder</product>
          <component>autobuilder</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.4 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joshua Lock">joshuagloe</reporter>
          <assigned_to name="Stephano Cetola">stephano</assigned_to>
          <cc>brian.avery</cc>
    
    <cc>infras.ab.watcher</cc>
    
    <cc>Infras.watcher</cc>
    
    <cc>ismo.puustinen</cc>
    
    <cc>pidge</cc>
    
    <cc>stephano</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73943</commentid>
    <comment_count>0</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-06-09 14:14:27 +0000</bug_when>
    <thetext>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&apos;ve created a simple reproducer:

$ cat test/test.sh 
#!/usr/bin/env sh

if [ -n &quot;$BASH_SOURCE&quot; ]; then
    THIS_SCRIPT=$BASH_SOURCE
elif [ -n &quot;$ZSH_NAME&quot; ]; then
    THIS_SCRIPT=$0
else
    THIS_SCRIPT=&quot;$(pwd)/oe-init-build-env&quot;
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&apos;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73979</commentid>
    <comment_count>1</comment_count>
    <who name="Mikko Ylinen">mikko.ylinen</who>
    <bug_when>2017-06-12 11:36:07 +0000</bug_when>
    <thetext>(In reply to comment #0)

&gt; on a machine with a version of bash working as the script assumes:
&gt; 
&gt; $ sh test/test.sh 
&gt; BASH_SOURCE=test/test.sh
&gt; THIS_SCRIPT=test/test.sh
&gt; 
&gt; whereas on a machine with a version of bash that doesn&apos;t seem to work as
&gt; expected:
&gt; 
&gt; BASH_SOURCE=
&gt; THIS_SCRIPT=/home/joshuagl/test.sh
&gt; 
&gt; The location of the script is /home/joshuagl/test/test.sh

Thanks, I&apos;ll take a look. Those lines are originally from oe-core&apos;s oe-init-build-env but seems the else branch needs a fix in our case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74274</commentid>
    <comment_count>2</comment_count>
    <who name="Mikko Ylinen">mikko.ylinen</who>
    <bug_when>2017-06-16 11:30:20 +0000</bug_when>
    <thetext>https://github.com/intel/intel-iot-refkit/pull/193</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74329</commentid>
    <comment_count>3</comment_count>
    <who name="Ismo Puustinen">ismo.puustinen</who>
    <bug_when>2017-06-19 15:52:36 +0000</bug_when>
    <thetext>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&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74388</commentid>
    <comment_count>4</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-06-20 14:11:16 +0000</bug_when>
    <thetext>Thanks for the insight Ismo, I&apos;d completely forgotten that Ubuntu use dash for /bin/sh.

It&apos;s unclear why the ShellCommands in buildbot use /bin/sh rather than the user&apos;s configured shell (bash, in our case) but it&apos;s clear we need to work around this.

I think we&apos;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]

&apos;This works in most shells (not dash), but not all of them pass the arguments when being sourced.  To workaround the shell limitation use &quot;set &lt;builddir&gt;&quot; prior to sourcing this script.&apos;

1. http://git.openembedded.org/openembedded-core/tree/oe-init-build-env#n21</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>