<?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>14707</bug_id>
          
          <creation_ts>2022-01-28 15:48:17 +0000</creation_ts>
          <short_desc>do_unpack may access network in FetchMethod.latest_revision</short_desc>
          <delta_ts>2022-02-22 17:26:18 +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>5.99</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>High</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.0 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Hoyes">Peter.Hoyes</reporter>
          <assigned_to name="Pavel Zhukov">pavel</assigned_to>
          <cc>pavel</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.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>92423</commentid>
    <comment_count>0</comment_count>
    <who name="Peter Hoyes">Peter.Hoyes</who>
    <bug_when>2022-01-28 15:48:17 +0000</bug_when>
    <thetext>With the latest master (where network access is disabled in do_unpack):

Reproduction steps:
 * Create a recipe whose SRCREV is *not* a SHA (e.g. a Git tag)
 * Build the recipe
 * Make a change to the recipe, such that do_unpack is re-triggered but do_fetch is not
 * Build the recipe again. do_unpack fails as it tries to run `git ls-remote` to resolve the tag.

The offending function call is at https://git.yoctoproject.org/poky/tree/bitbake/lib/bb/fetch2/git.py#n256

I understand that it is best practice to use a SHA in the SRCREV so that no `ls-remote` is necessary, but this does not seem to be mandatory at the moment.

Could do_unpack fetch the latest revision from the clone in the downloads directory instead?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92457</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-02-03 15:40:08 +0000</bug_when>
    <thetext>Pavel will take this once this he gets a BZ account.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92481</commentid>
    <comment_count>2</comment_count>
    <who name="Pavel Zhukov">pavel</who>
    <bug_when>2022-02-05 09:08:51 +0000</bug_when>
    <thetext>Hello,

Thank you for reporting this issue. 
Bitbake caches srcrev information in PERSISTENT_DIR and it should persist between builds (according to https://www.yoctoproject.org/docs/2.0.3/bitbake-user-manual/bitbake-user-manual.html ). In fact this behavior is controlled by BB_SRCREV_POLICY and the default policy is &quot;clean&quot; that means the cache is being cleaned each time (https://git.openembedded.org/bitbake/tree/lib/bb/fetch2/__init__.py#n511)

To mitigate the issue BB_SRCREV_POLICY can be set to &quot;cache&quot; in local.conf. In that case bitbake uses URI_HEADREVS store to resolve revisions and the issue doesn&apos;t occur. 

latest_revisions() for git fetcher can be improved a bit to use rev-parse in case if network is not available but this will not work in all cases (rebasesable repos for example).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92627</commentid>
    <comment_count>3</comment_count>
    <who name="Pavel Zhukov">pavel</who>
    <bug_when>2022-02-22 17:26:18 +0000</bug_when>
    <thetext>This is fixed in https://git.openembedded.org/bitbake/commit/?id=4b5eed1626709ef3dc06b32fd55d40a2a6edd179
Closing</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>