From 453eb5432d3341a304c1ff5b94de7e567d321aa3 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 20 Jan 2014 13:15:12 +0000 Subject: bitbake: fetch2: Sanity check SRCREV matches rev/tag parameter Add a sanity check so that if some SRCREV is set and a rev parameter is given to the url, the revision given should match. Any tag parameter behaves the same as rev. If both are specified, error to tell the user we're confused rather than do something which may or may not be what they intended. Also add some unittests for this. (Bitbake rev: e82a4ab48991035866da9914c8b75a9bfbc9a7fc) Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'bitbake/lib/bb/fetch2') diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index f4cff03225..8b6c3eed6c 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -867,12 +867,6 @@ def srcrev_internal_helper(ud, d, name): c) None if not specified """ - if 'rev' in ud.parm: - return ud.parm['rev'] - - if 'tag' in ud.parm: - return ud.parm['tag'] - srcrev = None pn = d.getVar("PN", True) attempts = [] @@ -889,6 +883,20 @@ def srcrev_internal_helper(ud, d, name): if srcrev and srcrev != "INVALID": break + if 'rev' in ud.parm and 'tag' in ud.parm: + raise FetchError("Please specify a ;rev= parameter or a ;tag= parameter in the url %s but not both." % (ud.url)) + + if 'rev' in ud.parm or 'tag' in ud.parm: + if 'rev' in ud.parm: + parmrev = ud.parm['rev'] + else: + parmrev = ud.parm['tag'] + if srcrev == "INVALID" or not srcrev: + return parmrev + if srcrev != parmrev: + raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please spcify one valid value" % (srcrev, parmrev)) + return parmrev + rev = srcrev if rev == "INVALID" or not rev: var = "SRCREV_pn-%s" % pn -- cgit v1.2.3-54-g00ecf