<?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>4634</bug_id>
          
          <creation_ts>2013-06-10 18:42:54 +0000</creation_ts>
          <short_desc>BitBake default &apos;dirs&apos; in exec_func (${B}) causes build failures</short_desc>
          <delta_ts>2016-08-12 20:25:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>2.2 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Christopher Larson">kergoth</reporter>
          <assigned_to name="Ross Burton">ross.burton</assigned_to>
          <cc>alexandru.c.georgescu</cc>
    
    <cc>jose.perez.carranza</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
    
    <cc>sgw</cc>
          
          <qa_contact name="Jose Perez C">jose.perez.carranza</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>33731</commentid>
    <comment_count>0</comment_count>
    <who name="Christopher Larson">kergoth</who>
    <bug_when>2013-06-10 18:42:54 +0000</bug_when>
    <thetext>lib/bb/build.py:exec_func reads:
162:    if dirs:
[...]
166:    else
167:        adir = data.getVar(&apos;B&apos;, d, 1)
168:        bb.utils.mkdirhier(adir)

This means that execution of any function which does not have the &apos;dirs&apos; flag set will cause ${B} to be used, and created. This can cause unforeseen complications.

So far, at Mentor, we&apos;ve seen two different build failures caused by this.

First, copyleft_compliance&apos;s task can run before do_unpack, causing ${B}, which is ${S} by default, to be created ahead of time, and the git unpack can fail if the destination already exists.

Second, do_rootfs currently adds ${S} to its cleandirs (unnecessarily, as it doesn&apos;t use it), and sstate_create_package doesn&apos;t have a &apos;dirs&apos; flag set. As a result, it&apos;s possible for these two tasks to race, and sstate_create_package can try to cd into a path which do_rootfs&apos;s cleandirs is removing. One workaround is to set dirs for sstate_create_package, another is to remove ${S} from do_rootfs cleandirs.

BitBake should not have any knowledge of ${S} or ${B}, so this default in exec_func is questionable at best. I believe that we should pursue removing this logic, but we will have to be careful about breaking any functions which could be relying on this default.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52195</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-07-07 20:24:24 +0000</bug_when>
    <thetext>Discovered that this (via buildhistory_commit) is the reason that a do_unpack causes $(S) to be created.

Decided to comment out the mkdir of ${B} to see what broke.

BOOM.

The assignment to adir of $(B) means that every Python function is chdir()&apos;d into $(B), which doesn&apos;t exist.  Comment out the assignment and stuff is building now... although how much of those Python functions are making an assumption about cwd I don&apos;t know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52471</commentid>
    <comment_count>2</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-07-17 16:35:13 +0000</bug_when>
    <thetext>Status: poky-contrib:ross/dirs has a patch to bitbake to stop his behaviour, and fixes for the problems it causes are in oe-core as they&apos;re found.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58661</commentid>
    <comment_count>3</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-02-05 16:31:56 +0000</bug_when>
    <thetext>Too much fallout for M2 this late, moving to 2.2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62955</commentid>
    <comment_count>4</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-06-14 13:02:17 +0000</bug_when>
    <thetext>Fixup patches for oe-core sent, the bitbake patch just needs an AB run.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62956</commentid>
    <comment_count>5</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-06-14 13:34:36 +0000</bug_when>
    <thetext>poky-contrib:ross/dirs has some fixes to oe-core and a bitbake patch to solve this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63012</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-06-16 10:19:36 +0000</bug_when>
    <thetext>bitbake watchdog -c populate_lic
bitbake watchdog -c clean
bitbake watchdog

Errors since the current working directory no longer exists.

ERROR: watchdog-5.15-r0 do_populate_lic_setscene: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: &apos;exec_python_func() autogenerated&apos;, lineno: 2, function: &lt;module&gt;
     0001:
 *** 0002:do_populate_lic_setscene(d)
     0003:
File: &apos;/media/build1/poky/meta/classes/license.bbclass&apos;, lineno: 674, function: do_populate_lic_setscene
     0670:
     0671:do_populate_lic_setscene[dirs] = &quot;${LICSSTATEDIR}/${PN}&quot;
     0672:do_populate_lic_setscene[cleandirs] = &quot;${LICSSTATEDIR}&quot;
     0673:python do_populate_lic_setscene () {
 *** 0674:    sstate_setscene(d)
     0675:}
     0676:addtask do_populate_lic_setscene
File: &apos;/media/build1/poky/meta/classes/sstate.bbclass&apos;, lineno: 642, function: sstate_setscene
     0638:            break
     0639:
     0640:def sstate_setscene(d):
     0641:    shared_state = sstate_state_fromvars(d)
 *** 0642:    accelerate = sstate_installpkg(shared_state, d)
     0643:    if not accelerate:
     0644:        raise bb.build.FuncFailed(&quot;No suitable staging package found&quot;)
     0645:
     0646:python sstate_task_prefunc () {
File: &apos;/media/build1/poky/meta/classes/sstate.bbclass&apos;, lineno: 320, function: sstate_installpkg
     0316:
     0317:    for state in ss[&apos;dirs&apos;]:
     0318:        prepdir(state[1])
     0319:        os.rename(sstateinst + state[0], state[1])
 *** 0320:    sstate_install(ss, d)
     0321:
     0322:    for plain in ss[&apos;plaindirs&apos;]:
     0323:        workdir = d.getVar(&apos;WORKDIR&apos;, True)
     0324:        src = sstateinst + &quot;/&quot; + plain.replace(workdir, &apos;&apos;)
File: &apos;/media/build1/poky/meta/classes/sstate.bbclass&apos;, lineno: 272, function: sstate_install
     0268:            oe.path.copyhardlinktree(state[1], state[2])
     0269:
     0270:    for postinst in (d.getVar(&apos;SSTATEPOSTINSTFUNCS&apos;, True) or &apos;&apos;).split():
     0271:        # All hooks should run in the SSTATE_INSTDIR
 *** 0272:        bb.build.exec_func(postinst, d, (sstateinst,))
     0273:
     0274:    for lock in locks:
     0275:        bb.utils.unlockfile(lock)
     0276:
File: &apos;/media/build1/poky/bitbake/lib/bb/build.py&apos;, lineno: 171, function: exec_func
     0167:#
     0168:def exec_func(func, d, dirs = None, pythonexception=False):
     0169:    &quot;&quot;&quot;Execute a BB &apos;function&apos;&quot;&quot;&quot;
     0170:
 *** 0171:    oldcwd = os.getcwd()
     0172:    body = d.getVar(func, False)
     0173:    if not body:
     0174:        if body is None:
     0175:            logger.warning(&quot;Function %s doesn&apos;t exist&quot;, func)
Exception: FileNotFoundError: [Errno 2] No such file or directory

ERROR: watchdog-5.15-r0 do_populate_lic_setscene: Function failed: do_populate_lic_setscene
ERROR: Logfile of failure stored in: /media/build1/poky/build/tmp6/work/core2-64-poky-linux-musl/watchdog/5.15-r0/temp/log.do_populate_lic_setscene.71045</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64219</commentid>
    <comment_count>7</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-07-20 13:40:24 +0000</bug_when>
    <thetext>Merged in bitbake 67a7b8b021badc17d8fdf447c250e79d291e75f7.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65149</commentid>
    <comment_count>8</comment_count>
    <who name="Jose Perez C">jose.perez.carranza</who>
    <bug_when>2016-08-12 20:25:30 +0000</bug_when>
    <thetext>Verified on master commit: 6b66e9317f4ec3a69f98f29836aafa35b52f3fc7</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>