bitbake: fetch2: try_mirror_url(): Replace old git with mirror
PATCH 1/1 bitbake: fetch2: try_mirror_url(): Replace old git with mirror
If we're trying to fetch a git, we're in try_mirror_url and origud.localpath is a directory, that means the original clone is broken for some reason but we found a mirror that works.
Remove the original clone and replace it with a symlink, like what would hopefully be done on a fresh fetch.
[ Yocto # 13278 ]
--- bitbake/lib/bb/fetch2/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/lib/bb/fetch2/__init__.py +6 -0
@@ -33,6 +33,7 @@ if 'git' not in urllib.parse.uses_netloc: urllib.parse.uses_netloc.append('git') import operator import collections +import shutil import subprocess import pickle import errno
@@ -1015,6 +1016,11 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): if hasattr(origud.method, "build_mirror_data"): origud.method.build_mirror_data(origud, ld) return origud.localpath + if isinstance(ud.method, git.Git) and os.path.isdir(origud.localpath) and origud.localpath != ud.localpath: + logger.warning("Replacing %s with link to %s", origud.localpath, ud.localpath) + # We have an old git clone here which is broken for some reason, + # remove it and replace is with a symlink. + shutil.rmtree(origud.localpath) # Otherwise the result is a local file:// and we symlink to it if not os.path.exists(origud.localpath): if os.path.islink(origud.localpath):
Signature · 1 line
2.17.1
fre 2019-05-10 klockan 12:30 +0000 skrev Ernst Sjöstrand:
Quoted 42 lines
If we're trying to fetch a git, we're in
try_mirror_urland origud.localpath is a directory, that means the original clone is broken
for some reason but we found a mirror that works. Remove the original clone and replace it with a symlink, like what would
hopefully be done on a fresh fetch.[ Yocto # 13278 ]
Signed-off-by Ernst Sjöstrand <[email protected]>--- bitbake/lib/bb/fetch2/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+)bitbake/lib/bb/fetch2/__init__.py +1
-0@@ -33,6 +33,7 @@ if 'git' not in urllib.parse.uses_netloc: urllib.parse.uses_netloc.append('git') import operator import collections +import shutil import subprocess import pickle import errno@@ -1015,6 +1016,11 @@ def try_mirror_url(fetch, origud, ud, ld,check = False):
ifhasattr(origud.method, "build_mirror_data"):
origud.method.build_mirror_data(origud, ld)
return origud.localpath
+ ifisinstance(ud.method, git.Git)andos.path.isdir(origud.localpath)and origud.localpath != ud.localpath:
+ logger.warning("Replacing %s with link to %s",
origud.localpath, ud.localpath)
+ # We have an old git clone here which is broken for some
reason,bitbake/lib/bb/fetch2/__init__.py +2
-0+ # remove it and replace is with a symlink. + shutil.rmtree(origud.localpath) # Otherwise the result is a local file:// and we symlink to
Quoted 6 lines
it
if notos.path.exists(origud.localpath):
ifos.path.islink(origud.localpath):Signature · 1 line
2.17.1
Ping. I could write a longer explanation for why you might end up in this situation in the commit message, though that's available in the bug report.
Regards
//Ernst
Ping!
fre 2019-08-16 klockan 08:48 +0000 skrev Ernst Sjöstrand:
fre 2019-05-10 klockan 12:30 +0000 skrev Ernst Sjöstrand:
If we're trying to fetch a git, we're in try_mirror_url and
origud.localpath is a directory, that means the original clone is
broken
for some reason but we found a mirror that works.
Remove the original clone and replace it with a symlink, like what
would
hopefully be done on a fresh fetch.
[ Yocto # 13278 ]
<mailto:[email protected]>
Quoted 1 line
---
bitbake/lib/bb/fetch2/__init__.py | 6 ++++++
1 file changed, 6 insertions(+)
(quoted diff) +0 -0
b/bitbake/lib/bb/fetch2/__init__.py
index 72d6092deb..be1228d6d5 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -33,6 +33,7 @@ if 'git' not in urllib.parse.uses_netloc:
urllib.parse.uses_netloc.append('git')
import operator
import collections
+import shutil
import subprocess
import pickle
import errno
@@ -1015,6 +1016,11 @@ def try_mirror_url(fetch, origud, ud, ld,
check = False):
if hasattr(origud.method, "build_mirror_data"):
origud.method.build_mirror_data(origud, ld)
return origud.localpath
+ if isinstance(ud.method, git.Git) and
os.path.isdir(origud.localpath) and origud.localpath != ud.localpath:
+ logger.warning("Replacing %s with link to %s",
origud.localpath, ud.localpath)
+ # We have an old git clone here which is broken for some
reason,
+ # remove it and replace is with a symlink.
+ shutil.rmtree(origud.localpath)
# Otherwise the result is a local file:// and we symlink to
it
if not os.path.exists(origud.localpath):
if os.path.islink(origud.localpath):
--
2.17.1
Ping. I could write a longer explanation for why you might end up in
this situation in the commit message, though that's available in the
bug report.
Regards
//Ernst