<?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>13278</bug_id>
          
          <creation_ts>2019-04-12 11:36:47 +0000</creation_ts>
          <short_desc>If git protocol doesn&apos;t work, you get a tar.gz clone from PREMIRROR which has git protocol origin</short_desc>
          <delta_ts>2023-10-29 09:22:38 +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>2.5.4</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>major</bug_severity>
          <target_milestone>4.1 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ernst Persson">ernstp</reporter>
          <assigned_to name="Pavel Zhukov">pavel</assigned_to>
          <cc>hakan.eriksson</cc>
    
    <cc>pavel</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>83527</commentid>
    <comment_count>0</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-04-12 11:36:47 +0000</bug_when>
    <thetext>1) bitbake tries to clone a git with the git protocol. That fails because it&apos;s blocked in your corporate network. However http works.
2) The poky PREMIRRORS kick in, and bitbake downloads a git2..tar.gz from downloads.yoctoproject.org
3) Everything works, great!
4) Time passes and a recipe is updated to a new SRCREV that you don&apos;t have in your clone, so the git must be fetched again.
5) That fails, and the MIRRORS system gets confused. It looks like do_fetch will clone from using protocol=https from MIRRORS, but do_unpack can&apos;t find it.

WARNING: prelink-native-1.0+gitAUTOINC+05aeafd053-r0 do_fetch: Failed to fetch URL git://git.yoctoproject.org/prelink-cross.git;branch=cross_prelink, attempting MIRRORS if available
(here it actually does the https clone to a different directory, and no symlink is created. Perhaps because the target already exists... )
ERROR: prelink-native-1.0+gitAUTOINC+05aeafd053-r0 do_unpack: Fetcher failure: 
fatal: reference is not a tree: 05aeafd053e56356ec8c62f4bb8f7b95bae192f3


One decent workaround is to remove the default poky PREMIRRORS, best combined with your own premirror of course.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83528</commentid>
    <comment_count>1</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-04-12 11:41:37 +0000</bug_when>
    <thetext>I think this check is involved http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/bitbake/lib/bb/fetch2/__init__.py?id=b1641008f072ecd7b8843d80e0d3de6c0584129e#n1011</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83529</commentid>
    <comment_count>2</comment_count>
      <attachid>4471</attachid>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-04-12 13:18:12 +0000</bug_when>
    <thetext>Created attachment 4471
bitbake: fetch2: try_mirror_url(): Replace old git with  mirror</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83530</commentid>
    <comment_count>3</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-04-12 13:20:51 +0000</bug_when>
    <thetext>Ok so here&apos;s a little patch that solves my immediate issue, but I guess there could be a number of scenarios I haven&apos;t thought of. I tried to limit it to only the git method to minimize side effects.

It looks quite nice in the logs:

WARNING: prelink-native-1.0+gitAUTOINC+05aeafd053-r0 do_fetch: Failed to fetch URL git://git.yoctoproject.org/prelink-cross.git;branch=cross_prelink, attempting MIRRORS if available
WARNING: prelink-native-1.0+gitAUTOINC+05aeafd053-r0 do_fetch: Replacing /home/ernsjo/code/cu1/downloads//git2/git.yoctoproject.org.prelink-cross.git with link to /home/ernsjo/code/cu1/downloads//git2/git.yoctoproject.org.git.prelink-cross.git</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84639</commentid>
    <comment_count>4</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-08-12 15:35:55 +0000</bug_when>
    <thetext>I sent the patch to bitbake-devel a few months ago also:

http://lists.openembedded.org/pipermail/bitbake-devel/2019-May/019998.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84647</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2019-08-12 19:27:15 +0000</bug_when>
    <thetext>Ernst, I&apos;ve asked someone to review the change. Ping the thread in 2 days if you don&apos;t see a reply, please. -- Randy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84722</commentid>
    <comment_count>6</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-08-22 08:34:19 +0000</bug_when>
    <thetext>Extra ping here too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84895</commentid>
    <comment_count>7</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2019-09-06 09:19:17 +0000</bug_when>
    <thetext>Saw that I had use for my patch again today:

WARNING: pseudo-native-1.9.0+gitAUTOINC+3fa7c853e0-r0 do_fetch: Failed to fetch URL git://git.yoctoproject.org/pseudo, attempting MIRRORS if available
WARNING: pseudo-native-1.9.0+gitAUTOINC+3fa7c853e0-r0 do_fetch: Replacing /home/ernsjo/code/cu1/downloads//git2/git.yoctoproject.org.pseudo with link to /home/ernsjo/code/cu1/downloads//git2/git.yoctoproject.org.git.pseudo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87884</commentid>
    <comment_count>8</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2020-08-06 07:30:09 +0000</bug_when>
    <thetext>This is still used by everyone at my company every day (the version that was sent to the mailing list with one extra &quot;if&quot; statement).
And it helps every time you update to a new yocto release.

And to reiterate, it helps when the git protocol is blocked, Yocto fetches a git archive from PREMIRRORS, and then later tries to &quot;git fetch&quot; in that git.

There are only a few projects that use the git protocol and not git over http.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89942</commentid>
    <comment_count>9</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-04-15 13:21:04 +0000</bug_when>
    <thetext>Sorry about the delays in review on this. I understand the problem but the fix in this form will regress some behaviours.

In particular, if you specify an invalid SRCREV it will wipe out the local checkout of the repo and pull mirror tarballs before failing which is a pain when the repo is large (e.g. a kernel)

What I think would make sense is to download the mirror tarball and extract it, then check if the revision is there, only then replacing the other repo when we know we&apos;ll be successful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89945</commentid>
    <comment_count>10</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2021-04-15 13:45:42 +0000</bug_when>
    <thetext>The important details is the subtle difference between the two names you get anyway.
git.yoctoproject.org.pseudo
git.yoctoproject.org.git.pseudo

So an even longer and more accurate description would be:

1) bitbake tries to clone a git with the git protocol. That fails because it&apos;s blocked in your corporate network. However http works.
2) The poky PREMIRRORS kick in, and bitbake downloads a git2..tar.gz from downloads.yoctoproject.org
3) Everything works, great!
4) Time passes and a recipe is updated to a new SRCREV that you don&apos;t have in your clone, so the git must be fetched again.
5) git fetch fails, as expected because the git protocol is still blocked.
6) The mirror system kicks in successfully and downloads a new tarball of the git archive
7) However this doesn&apos;t get used because of the confusion between git.yoctoproject.org.pseudo and git.yoctoproject.org.git.pseudo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93917</commentid>
    <comment_count>11</comment_count>
    <who name="Pavel Zhukov">pavel</who>
    <bug_when>2022-08-25 18:04:50 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; The important details is the subtle difference between the two names you get
&gt; anyway.
&gt; git.yoctoproject.org.pseudo
&gt; git.yoctoproject.org.git.pseudo
&gt; 
&gt; So an even longer and more accurate description would be:
&gt; 
&gt; 1) bitbake tries to clone a git with the git protocol. That fails because
&gt; it&apos;s blocked in your corporate network. However http works.
&gt; 2) The poky PREMIRRORS kick in, and bitbake downloads a git2..tar.gz from
&gt; downloads.yoctoproject.org
&gt; 3) Everything works, great!
&gt; 4) Time passes and a recipe is updated to a new SRCREV that you don&apos;t have
&gt; in your clone, so the git must be fetched again.
&gt; 5) git fetch fails, as expected because the git protocol is still blocked.
&gt; 6) The mirror system kicks in successfully and downloads a new tarball of
&gt; the git archive
&gt; 7) However this doesn&apos;t get used because of the confusion between
&gt; git.yoctoproject.org.pseudo and git.yoctoproject.org.git.pseudo


Hello,

There were few fixes in git fetcher and broken tarballs handling to properly handle premirrors and mirror functionality so this issue is fixed most likely.

To verify this I&apos;ve tried to reproduce it with:

1) Block outgoing connections to git port
2) tried to build pseudo
WARNING: pseudo-1.9.0+gitAUTOINC+2b4b88eb51-r0 do_fetch: Failed to fetch URL git://git.yoctoproject.org/pseudo;branch=oe-core, attempting MIRRORS if available

3) premirrors kicked in.
DEBUG: pseudo-1.9.0+gitAUTOINC+2b4b88eb51-r0 do_fetch: Fetcher accessed the network with the command /usr/bin/env wget -t 2 -T 30 --passive-ftp -O /mnt/builds/yocto/build/build/download/git2_git.yoctoproject.org.pseudo.tar.gz.tmp -P /mnt/builds/yocto/build/build/download &apos;http://downloads.yoctoproject.org/mirror/sources/git2_git.yoctoproject.org.pseudo.tar.gz&apos;

4) pseudo is built

5) delete SRCREV from the mirror and tarball.

6) Tried to build pseudo

7) revision not found:
[...] git -c core.fsyncobjectfiles=0 -c gc.autoDetach=false -c core.pager=cat branch --contains 2b4b88eb513335b0ece55fe51854693d9b20de35 --list oe-core 2&gt; /dev/null | wc -l&apos; in /mnt/builds/yocto/build/build/download/git2/git.yoctoproject.org.pseudo

8) git fetch tried to download revision but failed as expected:

WARNING: pseudo-1.9.0+gitAUTOINC+2b4b88eb51-r0 do_fetch: Failed to fetch URL git://git.yoctoproject.org/pseudo;branch=oe-core, attempting MIRRORS if available

9) wget fetcher kicked in to redownload the mirror tarball:
DEBUG: pseudo-1.9.0+gitAUTOINC+2b4b88eb51-r0 do_fetch: Fetching http://downloads.yoctoproject.org/mirror/sources/git2_git.yoctoproject.org.pseudo.tar.gz using command &apos;/usr/bin/env wget -t 2 -T 30 --passive-ftp -O /mnt/builds/yocto/build/build/download/git2_git.yoctoproject.org.pseudo.tar.gz.tmp -P /mnt/builds/yocto/build/build/download &apos;http://downloads.yoctoproject.org/mirror/sources/git2_git.yoctoproject.org.pseudo.tar.gz&apos;&apos;

10) Revision is in place. We&apos;re good to go:
git -c core.fsyncobjectfiles=0 -c gc.autoDetach=false -c core.pager=cat grep lfs oe-core:.gitattributes | wc -l&apos; in /mnt/builds/yocto/build/build/download/git2/git.yoctoproject.org.pseudo

Please let me know if the issue is still exists in master or close this bug report.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93928</commentid>
    <comment_count>12</comment_count>
    <who name="Ernst Persson">ernstp</who>
    <bug_when>2022-08-26 10:45:15 +0000</bug_when>
    <thetext>Yeah this seems to be fixed now!
The symlink I mentioned seem to have been completely removed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93935</commentid>
    <comment_count>13</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-08-29 12:49:06 +0000</bug_when>
    <thetext>Thanks for testing and confirming everyone, nice to have this resolved! :)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4471</attachid>
            <date>2019-04-12 13:18:12 +0000</date>
            <delta_ts>2023-10-29 09:22:38 +0000</delta_ts>
            <desc>bitbake: fetch2: try_mirror_url(): Replace old git with  mirror</desc>
            <filename>0001-bitbake-fetch2-try_mirror_url-Replace-old-git-with-m.patch</filename>
            <type>text/plain</type>
            <size>1998</size>
            <attacher name="Ernst Persson">ernstp</attacher>
            
              <data encoding="base64">RnJvbSAzOGQ1NWMwNzk5MTM5NDlkNzY2ODhlNmQxYjc4ZjM2YjgyNTY2ODdmIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiA9P1VURi04P3E/RXJuc3Q9MjBTaj1DMz1CNnN0cmFuZD89IDxl
cm5zdC5zam9zdHJhbmRAdmVyaXN1cmUuY29tPgpEYXRlOiBGcmksIDEyIEFwciAyMDE5IDEzOjU0
OjE2ICswMjAwClN1YmplY3Q6IFtQQVRDSF0gYml0YmFrZTogZmV0Y2gyOiB0cnlfbWlycm9yX3Vy
bCgpOiBSZXBsYWNlIG9sZCBnaXQgd2l0aAogbWlycm9yCk1JTUUtVmVyc2lvbjogMS4wCkNvbnRl
bnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29k
aW5nOiA4Yml0CgpJZiB3ZSdyZSB0cnlpbmcgdG8gZmV0Y2ggYSBnaXQsIHdlJ3JlIGluIHRyeV9t
aXJyb3JfdXJsIGFuZApvcmlndWQubG9jYWxwYXRoIGlzIGEgZGlyZWN0b3J5LCB0aGF0IG1lYW5z
IHRoZSBvcmlnaW5hbCBjbG9uZSBpcyBicm9rZW4KZm9yIHNvbWUgcmVhc29uIGJ1dCB3ZSBmb3Vu
ZCBhIG1pcnJvciB0aGF0IHdvcmtzLgpSZW1vdmUgdGhlIG9yaWdpbmFsIGNsb25lIGFuZCByZXBs
YWNlIGl0IHdpdGggYSBzeW1saW5rLCBsaWtlIHdoYXQgd291bGQKaG9wZWZ1bGx5IGJlIGRvbmUg
b24gYSBmcmVzaCBmZXRjaC4KClsgWW9jdG8gIyAxMzI3OCBdCgpTaWduZWQtb2ZmLWJ5OiBFcm5z
dCBTasO2c3RyYW5kIDxlcm5zd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kgYW5kIG9zLnBhdGguaXNkaXIob3JpZ3VkLmxvY2FscGF0
aCk6CisgICAgICAgICAgICBsb2dnZXIud2FybmluZygiUmVwbGFjaW5nICVzIHdpdGggbGluayB0
byAlcyIsIG9yaWd1ZC5sb2NhbHBhdGgsIHVkLmxvY2FscGF0aCkKKyAgICAgICAgICAgICMgV2Ug
aGF2ZSBhbiBvbGQgZ2l0IGNsb25lIGhlcmUgd2hpY2ggaXMgYnJva2VuIGZvciBzb21lIHJlYXNv
biwKKyAgICAgICAgICAgICMgcmVtb3ZlIGl0IGFuZCByZXBsYWNlIGlzIHdpdGggYSBzeW1saW5r
LgorICAgICAgICAgICAgc2h1dGlsLnJtdHJlZShvcmlndWQubG9jYWxwYXRoKQogICAgICAgICAj
IE90aGVyd2lzZSB0aGUgcmVzdWx0IGlzIGEgbG9jYWwgZmlsZTovLyBhbmQgd2Ugc3ltbGluayB0
byBpdAogICAgICAgICBpZiBub3Qgb3MucGF0aC5leGlzdHMob3JpZ3VkLmxvY2FscGF0aCk6CiAg
ICAgICAgICAgICBpZiBvcy5wYXRoLmlzbGluayhvcmlndWQubG9jYWxwYXRoKToKLS0gCjIuMTcu
MQoK
</data>

          </attachment>
      

    </bug>

</bugzilla>