[bitbake-devel] [PATCH 9/9] fetch2/git: name the shallow tarball according to the url specified in the recipe rather than the mirrored url

Urs Fässler urs.fassler at bbv.ch
Mon Jul 23 15:42:59 UTC 2018


Unpacking a git shallow tarball does not work when using mirror rewrite
rules that alter the path of the remote url. With this patch we always
use to remote url from the recipe to generate the local shallow tarball
name.

Signed-off-by: Urs Fässler <urs.fassler at bbv.ch>
Signed-off-by: Pascal Bach <pascal.bach at siemens.com>
---
 lib/bb/fetch2/git.py  |  7 +++++--
 lib/bb/tests/fetch.py | 26 ++++++++++++++++++++------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index f9e31d2b..c1fec614 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -79,7 +79,7 @@ import subprocess
 import tempfile
 import bb
 import bb.progress
-from   bb.fetch2 import FetchMethod
+from   bb.fetch2 import FetchMethod, decodeurl
 from   bb.fetch2 import runfetchcmd
 from   bb.fetch2 import logger
 
@@ -259,7 +259,10 @@ class Git(FetchMethod):
         ud.fullmirror = os.path.join(dl_dir, mirrortarball)
         ud.mirrortarballs = [mirrortarball]
         if ud.shallow:
-            tarballname = gitsrcname
+            _, original_host, original_path, _, _, _ = decodeurl(d.expand(original_url))
+            tarballname = self.__build_git_source_name(original_host, original_path, ud.rebaseable, ud.names,
+                                                       ud.revisions)
+
             if ud.bareclone:
                 tarballname = "%s_bare" % tarballname
 
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index fedc3b73..6b7df874 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -522,7 +522,6 @@ class GitShallowTarballNamingTest(FetcherTest):
         self.__recipe_url = "git://git.openembedded.org/bitbake"
         self.__recipe_tarball = "gitshallow_git.openembedded.org.bitbake_82ea737-1_master.tar.gz"
         self.__mirror_url = "git://github.com/openembedded/bitbake.git"
-        self.__mirror_tarball = "gitshallow_github.com.openembedded.bitbake.git_82ea737-1_master.tar.gz"
 
         self.d.setVar('BB_GIT_SHALLOW', '1')
         self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
@@ -532,7 +531,7 @@ class GitShallowTarballNamingTest(FetcherTest):
         self.d.setVar("PREMIRRORS", self.__recipe_url + " " + self.__mirror_url + " \n")
 
     @skipIfNoNetwork()
-    def test_that_the_tarball_is_named_after_recipe_url_when_no_mirroring_is_used(self):
+    def test_that_the_recipe_tarball_is_created_when_no_mirroring_is_used(self):
         fetcher = bb.fetch.Fetch([self.__recipe_url], self.d)
 
         fetcher.download()
@@ -541,17 +540,17 @@ class GitShallowTarballNamingTest(FetcherTest):
         self.assertIn(self.__recipe_tarball, dir)
 
     @skipIfNoNetwork()
-    def test_that_the_mirror_tarball_is_created_when_mirroring_is_used(self):
+    def test_that_the_recipe_tarball_is_created_when_mirroring_is_used(self):
         self.__setup_mirror_rewrite()
         fetcher = bb.fetch.Fetch([self.__recipe_url], self.d)
 
         fetcher.download()
 
         dir = os.listdir(self.dldir)
-        self.assertIn(self.__mirror_tarball, dir)
+        self.assertIn(self.__recipe_tarball, dir)
 
     @skipIfNoNetwork()
-    def test_that_the_mirror_tarball_still_exists_when_mirroring_is_used_and_the_mirrored_tarball_already_exists(self):
+    def test_that_the_recipe_tarball_is_created_when_mirroring_is_used_and_the_mirrored_tarball_already_exists(self):
         self.__setup_mirror_rewrite()
         fetcher = bb.fetch.Fetch([self.__mirror_url], self.d)
         fetcher.download()
@@ -562,7 +561,7 @@ class GitShallowTarballNamingTest(FetcherTest):
         fetcher.download()
 
         dir = os.listdir(self.dldir)
-        self.assertIn(self.__mirror_tarball, dir)
+        self.assertIn(self.__recipe_tarball, dir)
 
 
 class FetcherLocalTest(FetcherTest):
@@ -1705,3 +1704,18 @@ class GitShallowTest(FetcherTest):
 
         dir = os.listdir(self.unpackdir + "/git/")
         self.assertIn("fstests.doap", dir)
+
+    @skipIfNoNetwork()
+    def test_that_unpack_uses_the_git_shallow_tarball_when_using_mirror_rewrite_rules_and_the_git_clone_does_not_exist(self):
+        self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0')
+        self.d.setVar('BB_GIT_SHALLOW', '1')
+        self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '1')
+        self.d.setVar('PREMIRRORS', 'git://git.yoctoproject.org/.* git://git.yoctoproject.org/git/PATH;protocol=https \n')
+        fetcher = bb.fetch.Fetch(["git://git.yoctoproject.org/fstests"], self.d)
+        fetcher.download()
+        bb.utils.remove(self.dldir + '/git2', recurse=True)
+
+        fetcher.unpack(self.unpackdir)
+
+        dir = os.listdir(self.unpackdir + "/git/")
+        self.assertIn("fstests.doap", dir)
-- 
2.18.0




More information about the bitbake-devel mailing list