Skip to contentSkip to conversation

archiver.bbclass: Handle gitsm URLs in the mirror archiver

PATCH New Paul Barker 1 participant 1 message Feb 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 archiver.bbclass: Handle gitsm URLs in the mirror archiver

To fully archive a gitsm:// entry in SRC_URI we need to also capture the submodules recursively.

---
 meta/classes/archiver.bbclass | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
meta/classes/archiver.bbclass +17 -4
index 013195df7d..a823708771 100644
@@ -337,12 +337,10 @@ python do_ar_mirror() {
 
     bb.utils.mkdirhier(destdir)
 
-    fetcher = bb.fetch2.Fetch(src_uri, d)
-
-    for url in fetcher.urls:
+    def archive_url(fetcher, url):
         if is_excluded(url):
             bb.note('Skipping excluded url: %s' % (url))
-            continue
+            return
 
         bb.note('Archiving url: %s' % (url))
         ud = fetcher.ud[url]
@@ -376,6 +374,21 @@ python do_ar_mirror() {
         bb.note('Copying source mirror')
         cmd = 'cp -fpPRH %s %s' % (localpath, destdir)
         subprocess.check_call(cmd, shell=True)
+
+        if url.startswith('gitsm://'):
+            def archive_submodule(ud, url, module, modpath, d):
+                url += ";bareclone=1;nobranch=1"
+                newfetch = bb.fetch2.Fetch([url], d, cache=False)
+
+                for url in newfetch.urls:
+                    archive_url(newfetch, url)
+
+            ud.method.process_submodules(ud, ud.clonedir, archive_submodule, d)
+
+    fetcher = bb.fetch2.Fetch(src_uri, d, cache=False)
+
+    for url in fetcher.urls:
+        archive_url(fetcher, url)
 }
 
 def exclude_useless_paths(tarinfo):
Signature · 1 line
2.20.1