[bitbake-devel] [PATCH 7/7] fetch2/git: provide information about missing sources

Urs Fässler urs.fassler at bbv.ch
Wed Oct 3 12:04:09 UTC 2018


Provide more information in the case the sources are not found in the
unpack step.

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  | 29 +++++++++++++++++++++--------
 lib/bb/tests/fetch.py |  2 ++
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 333b8893..50a58018 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -476,14 +476,27 @@ class Git(FetchMethod):
         if os.path.exists(destdir):
             bb.utils.prunedir(destdir)
 
-        clonedir_is_up_to_date = not self.clonedir_need_update(ud, d)
-        if clonedir_is_up_to_date:
-            runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
-        elif ud.shallow and os.path.exists(ud.fullshallow):
-            bb.utils.mkdirhier(destdir)
-            runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
-        else:
-            bb.fatal("no up to date source found")
+        source_found = False
+        source_error = []
+
+        if not source_found:
+            clonedir_is_up_to_date = not self.clonedir_need_update(ud, d)
+            if clonedir_is_up_to_date:
+                runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
+                source_found = True
+            else:
+                source_error.append("clone directory not available or not up to date: " + ud.clonedir)
+
+        if not source_found:
+            if ud.shallow and os.path.exists(ud.fullshallow):
+                bb.utils.mkdirhier(destdir)
+                runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
+                source_found = True
+            else:
+                source_error.append("shallow clone not enabled or not available: " + ud.fullshallow)
+
+        if not source_found:
+            bb.fatal("no up to date source found: " + "; ".join(source_error))
 
         repourl = self._get_repo_url(ud)
         runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d, workdir=destdir)
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 56c0c0db..b55d1421 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -1593,6 +1593,8 @@ class GitShallowTest(FetcherTest):
                 fetcher.unpack(self.d.getVar('WORKDIR'))
 
             self.assertTrue(logContains("no up to date source found", logs))
+            self.assertTrue(logContains("clone directory not available or not up to date", logs))
+            self.assertTrue(logContains("shallow clone not enabled or not available", logs))
 
     @skipIfNoNetwork()
     def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self):
-- 
2.19.0



More information about the bitbake-devel mailing list