All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] BB_NO_NETWORK: Fallback to local source for git lsremote
@ 2016-08-08  8:34 Tobias Hagelborn
  2016-08-08  9:55 ` Richard Purdie
  0 siblings, 1 reply; 20+ messages in thread
From: Tobias Hagelborn @ 2016-08-08  8:34 UTC (permalink / raw)
  To: bitbake-devel@lists.openembedded.org


Change made to enable building offline also with git tag references
in SRC_URI.

If BB_NO_NETWORK is set, fallback to search for tags and revisions
in local DL_DIR / GITDIR in order to avoid network access.

Signed-off-by: Tobias Hagelborn <tobiasha@axis.com>
---
 bitbake/lib/bb/fetch2/git.py | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 9bd87ad..0c08a3c 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -131,12 +131,6 @@ class Git(FetchMethod):
 
         ud.setup_revisons(d)
 
-        for name in ud.names:
-            # Ensure anything that doesn't look like a sha256 checksum/revision is translated into one
-            if not ud.revisions[name] or len(ud.revisions[name]) != 40  or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
-                if ud.revisions[name]:
-                    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('*', '.'))
         if gitsrcname.startswith('.'):
@@ -156,6 +150,13 @@ class Git(FetchMethod):
 
         ud.localfile = ud.clonedir
 
+        for name in ud.names:
+            # Ensure anything that doesn't look like a sha256 checksum/revision is translated into one
+            if not ud.revisions[name] or len(ud.revisions[name]) != 40  or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
+                if ud.revisions[name]:
+                    ud.unresolvedrev[name] = ud.revisions[name]
+                ud.revisions[name] = self.latest_revision(ud, d, name)
+
     def localpath(self, ud, d):
         return ud.clonedir
 
@@ -345,12 +346,23 @@ class Git(FetchMethod):
         repourl = self._get_repo_url(ud)
         cmd = "%s ls-remote %s %s" % \
               (ud.basecmd, repourl, search)
-        if ud.proto.lower() != 'file':
-            bb.fetch2.check_network_access(d, cmd)
-        output = runfetchcmd(cmd, d, True)
-        if not output:
-            raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
-        return output
+        try:
+            if ud.proto.lower() != 'file':
+                bb.fetch2.check_network_access(d, cmd)
+            output = runfetchcmd(cmd, d, True)
+            if not output:
+                raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
+            return output
+        except bb.fetch2.NetworkAccess as exc:
+            # Fallback to local DL_DIR/GITDIR if BB_NO_NETWORK is set
+            cmd = "%s ls-remote %s://%s %s" % \
+                  (ud.basecmd, 'file', self.localpath(ud, d), search)
+            output = runfetchcmd(cmd, d, True)
+            if output.split() == []:
+                bb.warn('failed: ', cmd)
+            if not output:
+                raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
+            return output
 
     def _latest_revision(self, ud, d, name):
         """
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread
[parent not found: <801c8b3c-a6f7-6b96-a527-d61c70a4a574@smile.fr>]

end of thread, other threads:[~2016-08-10  8:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-08  8:34 [PATCH] BB_NO_NETWORK: Fallback to local source for git lsremote Tobias Hagelborn
2016-08-08  9:55 ` Richard Purdie
2016-08-08 11:24   ` Jérémy Rosen
2016-08-08 15:35     ` Khem Raj
2016-08-08 15:58       ` Jérémy Rosen
2016-08-08 16:25         ` Khem Raj
2016-08-08 16:39       ` Olof Johansson
2016-08-08 17:22         ` Khem Raj
2016-08-09  9:36           ` Olof Johansson
2016-08-09 10:50             ` Barros Pena, Belen
2016-08-09 14:34             ` Khem Raj
2016-08-09 15:09               ` Olof Johansson
2016-08-09 15:54                 ` Khem Raj
2016-08-09 16:26                   ` Olof Johansson
2016-08-10  8:54                     ` Richard Purdie
2016-08-09  3:22       ` Paul Eggleton
2016-08-09  8:15         ` Jérémy Rosen
2016-08-09  9:49         ` Tobias Hagelborn
2016-08-08 12:54   ` Tobias Hagelborn
     [not found] <801c8b3c-a6f7-6b96-a527-d61c70a4a574@smile.fr>
2016-08-10  8:28 ` Jérémy Rosen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.