Skip to contentSkip to conversation

fetch2: Add get_mirrorname()

PATCH New Robert Yang 1 participant 2 messages Mar 22, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover fetch2: Add get_mirrorname()

* V2
- Use mirrorname as 'MIRRORNAME' if it is defined in origud.

* V1
- Initial version

// Robert

The following changes since commit 2187d06166ed6819a1d07c3f8a3be7a256fab18c:

goarch: Add riscv64 (2019-03-21 16:19:23 +0000)

are available in the Git repository at:

git://git.pokylinux.org/poky-contrib rbt/mirror
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=rbt/mirror

Robert Yang (1):
fetch2: Add get_mirrorname()

 bitbake/lib/bb/fetch2/__init__.py | 8 +++++++-
 bitbake/lib/bb/fetch2/git.py      | 4 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/1 fetch2: Add get_mirrorname()

Then it can be used by both __init__.py and git.py, and use mirrorname as 'MIRRORNAME' if it is defined in origud.

---
 bitbake/lib/bb/fetch2/__init__.py | 8 +++++++-
 bitbake/lib/bb/fetch2/git.py      | 4 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +7 -1
index 5c2a1c76c4..eee9b8e35e 100644
@@ -889,6 +889,9 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None):
 
     return output
 
+def get_mirrorname(ud):
+    return ud.host.replace(':','.') + ud.path.replace('/', '.').replace('*', '.')
+
 def check_network_access(d, info, url):
     """
     log remote network access, and error if BB_NO_NETWORK is set or the given
@@ -910,7 +913,10 @@ def build_mirroruris(origud, mirrors, ld):
     replacements["HOST"] = origud.host
     replacements["PATH"] = origud.path
     replacements["BASENAME"] = origud.path.split("/")[-1]
-    replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.').replace('*', '.')
+    if hasattr(origud, "mirrorname"):
+        replacements["MIRRORNAME"] = origud.mirrorname
+    else:
+        replacements["MIRRORNAME"] = get_mirrorname(origud)
 
     def adduri(ud, uris, uds, mirrors, tarballs):
         for line in mirrors:
bitbake/lib/bb/fetch2/git.py +3 -1
index 1a8ebe3da8..48c12bb9c8 100644
@@ -248,10 +248,12 @@ class Git(FetchMethod):
                     ud.unresolvedrev[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud, d, name)
 
-        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.'))
+        gitsrcname = bb.fetch2.get_mirrorname(ud)
         if gitsrcname.startswith('.'):
             gitsrcname = gitsrcname[1:]
 
+        ud.mirrorname = gitsrcname
+
         # for rebaseable git repo, it is necessary to keep mirror tar ball
         # per revision, so that even the revision disappears from the
         # upstream repo in the future, the mirror will remain intact and still
Signature · 1 line
2.21.0