[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6068/8267] bitbake: fetch/gitsm: add support for shallow mirror tarballs



commit f5308b8cc167e2fbb25406da074c334960902b20
Author: Christopher Larson <kergoth gmail com>
Date:   Sat May 13 02:46:31 2017 +0500

    bitbake: fetch/gitsm: add support for shallow mirror tarballs
    
    When we're building from a shallow mirror tarball, we don't want to do
    anything with ud.clonedir, as it's not being used when we unpack. As such,
    disable updating the submodules in that case. Also include the repositories in
    .git/modules in the shallow tarball. It does not actually make the submodule
    repositories shallow at this time.
    
    (Bitbake rev: 6c0613f1f2f9d4f009545f82a9173e80396f9d34)
    
    Signed-off-by: Christopher Larson <chris_larson mentor com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/lib/bb/fetch2/gitsm.py |   17 +++++++++++------
 bitbake/lib/bb/tests/fetch.py  |   31 +++++++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 10 deletions(-)
---
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index a95584c..0aff100 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -117,14 +117,19 @@ class GitSM(Git):
     def download(self, ud, d):
         Git.download(self, ud, d)
 
-        submodules = self.uses_submodules(ud, d, ud.clonedir)
-        if submodules:
-            self.update_submodules(ud, d)
+        if not ud.shallow or ud.localpath != ud.fullshallow:
+            submodules = self.uses_submodules(ud, d, ud.clonedir)
+            if submodules:
+                self.update_submodules(ud, d)
+
+    def clone_shallow_local(self, ud, dest, d):
+        super(GitSM, self).clone_shallow_local(ud, dest, d)
+
+        runfetchcmd('cp -fpPRH "%s/modules" "%s/"' % (ud.clonedir, os.path.join(dest, '.git')), d)
 
     def unpack(self, ud, destdir, d):
         Git.unpack(self, ud, destdir, d)
-        
-        submodules = self.uses_submodules(ud, d, ud.destdir)
-        if submodules:
+
+        if self.uses_submodules(ud, d, ud.destdir):
             runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir)
             runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 3e2ce53..2a9019b 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -1027,12 +1027,14 @@ class GitShallowTest(FetcherTest):
             cwd = self.gitdir
         return bb.process.run(cmd, cwd=cwd)[0]
 
-    def add_empty_file(self, path, msg=None):
+    def add_empty_file(self, path, cwd=None, msg=None):
         if msg is None:
             msg = path
-        open(os.path.join(self.srcdir, path), 'w').close()
-        self.git(['add', path], self.srcdir)
-        self.git(['commit', '-m', msg, path], self.srcdir)
+        if cwd is None:
+            cwd = self.srcdir
+        open(os.path.join(cwd, path), 'w').close()
+        self.git(['add', path], cwd)
+        self.git(['commit', '-m', msg, path], cwd)
 
     def fetch(self, uri=None):
         if uri is None:
@@ -1211,6 +1213,27 @@ class GitShallowTest(FetcherTest):
         self.assertRefs(['master', 'origin/master'])
         self.assertRevCount(1)
 
+    def test_shallow_submodules(self):
+        self.add_empty_file('a')
+        self.add_empty_file('b')
+
+        smdir = os.path.join(self.tempdir, 'gitsubmodule')
+        bb.utils.mkdirhier(smdir)
+        self.git('init', cwd=smdir)
+        self.add_empty_file('asub', cwd=smdir)
+
+        self.git('submodule init', cwd=self.srcdir)
+        self.git('submodule add file://%s' % smdir, cwd=self.srcdir)
+        self.git('submodule update', cwd=self.srcdir)
+        self.git('commit -m submodule -a', cwd=self.srcdir)
+
+        uri = 'gitsm://%s;protocol=file;subdir=${S}' % self.srcdir
+        fetcher, ud = self.fetch_shallow(uri)
+
+        self.assertRevCount(1)
+        assert './.git/modules/' in bb.process.run('tar -tzf %s' % os.path.join(self.dldir, 
ud.mirrortarballs[0]))[0]
+        assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule'))
+
     def test_shallow_multi_one_uri(self):
         # Create initial git repo
         self.add_empty_file('a')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]