<?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>14325</bug_id>
          
          <creation_ts>2021-03-25 05:47:10 +0000</creation_ts>
          <short_desc>externalsrc bbclass expansion error when the repo has a submodule and the externalsrc is in a subfolder</short_desc>
          <delta_ts>2021-03-29 22:56:10 +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>OE-Core</product>
          <component>core</component>
          <version>3.1.6</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>3.1.7</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmed Hossam">Ahmed.Hossam</reporter>
          <assigned_to name="Steve Sakoman">steve</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</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>89734</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmed Hossam">Ahmed.Hossam</who>
    <bug_when>2021-03-25 05:47:10 +0000</bug_when>
    <thetext>The externalsrc bbclass tries to track changes to submodules but assumes that the external source directory is at the root of the repo, assuming a code repo that looks like this:
.
└── repo
    ├── myapp1
    ├── myapp2
    └── myapp3
        └── submodule
This line http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/externalsrc.bbclass?h=dunfell#n221 tries to append the submodule directory (myapp3/submodule) to the source directory s_dir (repo/myapp1) resulting in an unexisting path (repo/myapp1/myapp3/submodule), it should instead append it to the git directory git_dir to get the right path (repo/myapp3/submodule). perhaps it should also ignore it in case the submodule is not under the app directory s_dir?



Error resulting from current bug:

ERROR: ExpansionError during parsing /path/to/poky/../meta-mylayer/recipes-myapp1/myapp1.bb

Traceback (most recent call last):
  File &quot;Var &lt;do_compile[file-checksums]&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/path/to/poky/meta/classes/externalsrc.bbclass&quot;, line 222, in srctree_hash_files(d=&lt;bb.data_smart.DataSmart object at 0x7f3144edb438&gt;, srcdir=None):
                     module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])
    &gt;                proc = subprocess.Popen([&apos;git&apos;, &apos;add&apos;, &apos;-A&apos;, &apos;.&apos;], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                     proc.communicate()
  File &quot;/usr/lib/python3.6/subprocess.py&quot;, line 729, in Popen.__init__(args=[&apos;git&apos;, &apos;add&apos;, &apos;-A&apos;, &apos;.&apos;], bufsize=-1, executable=None, stdin=None, stdout=-3, stderr=-3, preexec_fn=None, close_fds=True, shell=False, cwd=&apos;/path/to/poky/../meta-mylayer/recipes-myrecipe/../../my-code-repo/myapp1/myapp3/submodule&apos;, env={&apos;MACHINE&apos;: &apos;qemux86&apos;, &apos;USER&apos;: &apos;user&apos;, &apos;PWD&apos;: &apos;/path/to/my-code-repo&apos;, &apos;HOME&apos;: &apos;/home/user&apos;, &apos;BBPATH&apos;: &apos;/path/to/build&apos;, &apos;BB_ENV_EXTRAWHITE&apos;: &apos;ALL_PROXY BBPATH_EXTRA BB_LOGCONFIG BB_NO_NETWORK BB_NUMBER_THREADS BB_SETSCENE_ENFORCE BB_SRCREV_POLICY DISTRO FTPS_PROXY FTP_PROXY GIT_PROXY_COMMAND HTTPS_PROXY HTTP_PROXY MACHINE NO_PROXY PARALLEL_MAKE SCREENDIR SDKMACHINE SOCKS5_PASSWD SOCKS5_USER SSH_AGENT_PID SSH_AUTH_SOCK STAMPS_DIR TCLIBC TCMODE all_proxy ftp_proxy ftps_proxy http_proxy https_proxy no_proxy  MACHINE&apos;, &apos;TERM&apos;: &apos;xterm-256color&apos;, &apos;SHELL&apos;: &apos;/bin/bash&apos;, &apos;LOGNAME&apos;: &apos;user&apos;, &apos;PATH&apos;: &apos;/path/to/poky/scripts:/path/to/poky/bitbake/bin:/path/to/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin&apos;, &apos;LC_ALL&apos;: &apos;en_US.UTF-8&apos;, &apos;GIT_INDEX_FILE&apos;: &apos;/tmp/oe-devtool-indexbm0ky5kz&apos;}, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=(), encoding=None, errors=None):
                                     errread, errwrite,
    &gt;                                restore_signals, start_new_session)
             except:
  File &quot;/usr/lib/python3.6/subprocess.py&quot;, line 1364, in Popen._execute_child(args=[&apos;git&apos;, &apos;add&apos;, &apos;-A&apos;, &apos;.&apos;], executable=b&apos;git&apos;, preexec_fn=None, close_fds=True, pass_fds=(), cwd=&apos;/path/to/poky/../meta-mylayer/recipes-myrecipe/../../my-code-repo/myapp1/myapp3/submodule&apos;, env={&apos;MACHINE&apos;: &apos;qemux86&apos;, &apos;USER&apos;: &apos;user&apos;, &apos;PWD&apos;: &apos;/path/to/my-code-repo&apos;, &apos;HOME&apos;: &apos;/home/user&apos;, &apos;BBPATH&apos;: &apos;/path/to/build&apos;, &apos;BB_ENV_EXTRAWHITE&apos;: &apos;ALL_PROXY BBPATH_EXTRA BB_LOGCONFIG BB_NO_NETWORK BB_NUMBER_THREADS BB_SETSCENE_ENFORCE BB_SRCREV_POLICY DISTRO FTPS_PROXY FTP_PROXY GIT_PROXY_COMMAND HTTPS_PROXY HTTP_PROXY MACHINE NO_PROXY PARALLEL_MAKE SCREENDIR SDKMACHINE SOCKS5_PASSWD SOCKS5_USER SSH_AGENT_PID SSH_AUTH_SOCK STAMPS_DIR TCLIBC TCMODE all_proxy ftp_proxy ftps_proxy http_proxy https_proxy no_proxy  MACHINE&apos;, &apos;TERM&apos;: &apos;xterm-256color&apos;, &apos;SHELL&apos;: &apos;/bin/bash&apos;, &apos;LOGNAME&apos;: &apos;user&apos;, &apos;PATH&apos;: &apos;/path/to/poky/scripts:/path/to/poky/bitbake/bin:/path/to/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin&apos;, &apos;LC_ALL&apos;: &apos;en_US.UTF-8&apos;, &apos;GIT_INDEX_FILE&apos;: &apos;/tmp/oe-devtool-indexbm0ky5kz&apos;}, startupinfo=None, creationflags=0, shell=False, p2cread=-1, p2cwrite=-1, c2pread=-1, c2pwrite=31, errread=-1, errwrite=31, restore_signals=True, start_new_session=False):
                                 err_msg += &apos;: &apos; + repr(err_filename)
    &gt;                    raise child_exception_type(errno_num, err_msg, err_filename)
                     raise child_exception_type(err_msg)
bb.data_smart.ExpansionError: Failure expanding variable do_compile[file-checksums], expression was ${@srctree_hash_files(d)} which triggered exception FileNotFoundError: [Errno 2] No such file or directory: &apos;/path/to/poky/../meta-mylayer/recipes-myrecipe/../../my-code-repo/myapp1/myapp3/submodule&apos;: &apos;/path/to/poky/../meta-mylayer/recipes-myrecipe/../../my-code-repo/myapp1/myapp3/submodule&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89760</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-03-25 15:11:45 +0000</bug_when>
    <thetext>Does this happen on the master branch as well ? 
Ahmed, it would be good if you could test that and let Steve know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89789</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmed Hossam">Ahmed.Hossam</who>
    <bug_when>2021-03-26 11:28:44 +0000</bug_when>
    <thetext>I tested master today and the issue doesn&apos;t happen, it was fixed by the commit: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/meta/classes/externalsrc.bbclass?h=42c86799ce265101b821030525ec568d34670430</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89794</commentid>
    <comment_count>3</comment_count>
    <who name="Steve Sakoman">steve</who>
    <bug_when>2021-03-26 14:26:15 +0000</bug_when>
    <thetext>The patch that fixes this has been backported from master and is in this week&apos;s set of patches out for review:

https://lists.openembedded.org/g/openembedded-core/message/149885

It should be merged within the next few days.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89823</commentid>
    <comment_count>4</comment_count>
    <who name="Steve Sakoman">steve</who>
    <bug_when>2021-03-29 22:56:10 +0000</bug_when>
    <thetext>Fix is now merged:

https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=dunfell&amp;id=97d92eb0e87b0cca026335b8ae74f1c1dc469d8b</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>