[bitbake-devel] [PATCH] bitbake: fetch2: try_mirror_url(): Replace old git with mirror

Ernst Sjöstrand ernst.sjostrand at verisure.com
Fri May 10 12:30:22 UTC 2019


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 ]

Signed-off-by: Ernst Sjöstrand <ernst.sjostrand at verisure.com>
---
 bitbake/lib/bb/fetch2/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bitbake/lib/bb/fetch2/__init__.py 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



More information about the bitbake-devel mailing list