summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-20 13:15:12 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-21 10:20:13 +0000
commit453eb5432d3341a304c1ff5b94de7e567d321aa3 (patch)
tree197a62288534ea36da4c03c281d5fca236617aab /bitbake
parent721d3d6e0a55c767001a32e9fbc9a999f5fd1a66 (diff)
downloadpoky-453eb5432d3341a304c1ff5b94de7e567d321aa3.tar.gz
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 <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py20
-rw-r--r--bitbake/lib/bb/tests/fetch.py15
2 files changed, 29 insertions, 6 deletions
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):
867 c) None if not specified 867 c) None if not specified
868 """ 868 """
869 869
870 if 'rev' in ud.parm:
871 return ud.parm['rev']
872
873 if 'tag' in ud.parm:
874 return ud.parm['tag']
875
876 srcrev = None 870 srcrev = None
877 pn = d.getVar("PN", True) 871 pn = d.getVar("PN", True)
878 attempts = [] 872 attempts = []
@@ -889,6 +883,20 @@ def srcrev_internal_helper(ud, d, name):
889 if srcrev and srcrev != "INVALID": 883 if srcrev and srcrev != "INVALID":
890 break 884 break
891 885
886 if 'rev' in ud.parm and 'tag' in ud.parm:
887 raise FetchError("Please specify a ;rev= parameter or a ;tag= parameter in the url %s but not both." % (ud.url))
888
889 if 'rev' in ud.parm or 'tag' in ud.parm:
890 if 'rev' in ud.parm:
891 parmrev = ud.parm['rev']
892 else:
893 parmrev = ud.parm['tag']
894 if srcrev == "INVALID" or not srcrev:
895 return parmrev
896 if srcrev != parmrev:
897 raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please spcify one valid value" % (srcrev, parmrev))
898 return parmrev
899
892 rev = srcrev 900 rev = srcrev
893 if rev == "INVALID" or not rev: 901 if rev == "INVALID" or not rev:
894 var = "SRCREV_pn-%s" % pn 902 var = "SRCREV_pn-%s" % pn
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index e134a31f12..deb1d3733b 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -382,6 +382,21 @@ class FetcherNetworkTest(FetcherTest):
382 url1 = url2 = "git://git.openembedded.org/bitbake" 382 url1 = url2 = "git://git.openembedded.org/bitbake"
383 self.gitfetcher(url1, url2) 383 self.gitfetcher(url1, url2)
384 384
385 def test_gitfetch_goodsrcrev(self):
386 # SRCREV is set but matches rev= parameter
387 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
388 self.gitfetcher(url1, url2)
389
390 def test_gitfetch_badsrcrev(self):
391 # SRCREV is set but does not match rev= parameter
392 url1 = url2 = "git://git.openembedded.org/bitbake;rev=dead05b0b4ba0959fe0624d2a4885d7b70426da5"
393 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
394
395 def test_gitfetch_tagandrev(self):
396 # SRCREV is set but does not match rev= parameter
397 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5;tag=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
398 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
399
385 def test_gitfetch_premirror(self): 400 def test_gitfetch_premirror(self):
386 url1 = "git://git.openembedded.org/bitbake" 401 url1 = "git://git.openembedded.org/bitbake"
387 url2 = "git://someserver.org/bitbake" 402 url2 = "git://someserver.org/bitbake"