[bitbake-devel] [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag
Zhenhua Luo
zhenhua.luo at freescale.com
Tue Dec 24 08:06:32 UTC 2013
The change add the sanity check for SHA valididy when tag is defined in SRC_URI,
the check is useful for rebased git tree in which the referred commit is not valid
in branch and is saved in tag.
Signed-off-by: Zhenhua Luo <zhenhua.luo at freescale.com>
---
lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index bd107db..1c2d5d3 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -116,6 +116,15 @@ class Git(FetchMethod):
ud.branches[name] = branch
ud.unresolvedrev[name] = branch
+ tags = ud.parm.get("tag", "").split(',')
+ if len(tags) != len(ud.names):
+ raise bb.fetch2.ParameterError("The number of name and tag parameters is not balanced", ud.url)
+ ud.tags = {}
+ for name in ud.names:
+ tag = tags[ud.names.index(name)]
+ ud.tags[name] = tag
+ ud.unresolvedrev[name] = tag
+
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
@@ -218,7 +227,10 @@ class Git(FetchMethod):
os.chdir(ud.clonedir)
for name in ud.names:
if not self._contains_ref(ud, d, name):
- raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
+ if ud.tags[name]:
+ raise bb.fetch2.FetchError("Unable to find revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))
+ else:
+ raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
def build_mirror_data(self, ud, d):
# Generate a mirror tarball if needed
@@ -288,6 +300,18 @@ class Git(FetchMethod):
return True
def _contains_ref(self, ud, d, name):
+ if len(ud.tags[name]) != 0:
+ cmd = "%s tag --contains %s --list %s 2> /dev/null | wc -l" % (
+ ud.basecmd, ud.revisions[name], ud.tags[name])
+ try:
+ output = runfetchcmd(cmd, d, quiet=True)
+ except bb.fetch2.FetchError:
+ return False
+ if len(output.split()) > 1:
+ raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
+ else:
+ return output.split()[0] != "0"
+
cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
ud.basecmd, ud.revisions[name], ud.branches[name])
try:
@@ -296,7 +320,8 @@ class Git(FetchMethod):
return False
if len(output.split()) > 1:
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
- return output.split()[0] != "0"
+ else:
+ return output.split()[0] != "0"
def _revision_key(self, ud, d, name):
"""
--
1.8.4.2
More information about the bitbake-devel
mailing list