From: Tobias Hagelborn <tobias.hagelborn@axis.com>
To: "bitbake-devel@lists.openembedded.org"
<bitbake-devel@lists.openembedded.org>
Subject: [PATCH] BB_NO_NETWORK: Fallback to local source for git lsremote
Date: Mon, 8 Aug 2016 08:34:41 +0000 [thread overview]
Message-ID: <1470645281559.73326@axis.com> (raw)
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
next reply other threads:[~2016-08-08 8:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 8:34 Tobias Hagelborn [this message]
2016-08-08 9:55 ` [PATCH] BB_NO_NETWORK: Fallback to local source for git lsremote 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470645281559.73326@axis.com \
--to=tobias.hagelborn@axis.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.