[bitbake-devel] [PATCH] BB_NO_NETWORK: Fallback to local source for git lsremote
Tobias Hagelborn
tobias.hagelborn at axis.com
Mon Aug 8 08:34:41 UTC 2016
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 at 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
More information about the bitbake-devel
mailing list