summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoey Degges <jdegges@gmail.com>2020-12-14 08:30:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-08 10:11:42 +0000
commit10c69538c0cb8708c7eff9e8dc05ca7c669cb61c (patch)
tree6efa926c6f8b49a1bb123322fe2f67facd65a3d3 /bitbake
parent41ed881feaca7248426b60053aef41a2ce0eb39e (diff)
downloadpoky-10c69538c0cb8708c7eff9e8dc05ca7c669cb61c.tar.gz
bitbake: fetch/git: Fix usehead for non-default names
The usehead url parameter for git repositories causes bitbake to use whatever commit the repository HEAD is pointing to if the repository happens to have the name 'default'. This is the default name so in many cases it works just fine, but if a different name is specified with the url parameter 'name=newName' then it will fail to parse the recipe with an error along the lines of: ERROR: ExpansionError during parsing /path/to/my/recipe.bb Traceback (most recent call last): File "/path/to/poky/bitbake/lib/bb/fetch2/git.py", line 235, in Git.urldata_init: > ud.setup_revisions(d) File "/path/to/poky/bitbake/lib/bb/fetch2/__init__.py", line 1302, in FetchData.setup_revisions: for name in self.names: > self.revisions[name] = srcrev_internal_helper(self, d, name) File "/path/to/poky/bitbake/lib/bb/fetch2/__init__.py", line 1167, in srcrev_internal_helper(name='newName'): if srcrev == "AUTOINC": > srcrev = ud.method.latest_revision(ud, d, name) File "/path/to/poky/bitbake/lib/bb/fetch2/__init__.py", line 1562, in Git.latest_revision(name='newName'): except KeyError: > revs[key] = rev = self._latest_revision(ud, d, name) return rev File "/path/to/poky/bitbake/lib/bb/fetch2/git.py", line 650, in Git._latest_revision(name='newName'): raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output for %s" % \ > (ud.unresolvedrev[name], ud.host+ud.path)) bb.data_smart.ExpansionError: Failure expanding variable SRCPV, expression was ${@bb.fetch2.get_srcrev(d)} which triggered exception FetchError: Fetcher failure: Unable to resolve 'master' in upstream git repository in git ls-remote output for /path/to/local/git/repo Let's fix this by setting the unresolved rev of _all_ repository names to 'HEAD' when the usehead url parameter is specified. Update the currently failing test, test_local_gitfetch_usehead_withname, to now expect success. This change preserves existing behavior that allows usehead to be overridden by a valid looking revision if one happens to be specified instead of AUTOREV. (Bitbake rev: 01e901c44ab0f496606b1d45c8953dc54970204c) Signed-off-by: Joey Degges <jdegges@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/git.py7
-rw-r--r--bitbake/lib/bb/tests/fetch.py8
2 files changed, 7 insertions, 8 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 490d57fbbf..df9538a60d 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -220,7 +220,12 @@ class Git(FetchMethod):
220 ud.shallow = False 220 ud.shallow = False
221 221
222 if ud.usehead: 222 if ud.usehead:
223 ud.unresolvedrev['default'] = 'HEAD' 223 # When usehead is set let's associate 'HEAD' with the unresolved
224 # rev of this repository. This will get resolved into a revision
225 # later. If an actual revision happens to have also been provided
226 # then this setting will be overridden.
227 for name in ud.names:
228 ud.unresolvedrev[name] = 'HEAD'
224 229
225 ud.basecmd = d.getVar("FETCHCMD_git") or "git -c core.fsyncobjectfiles=0" 230 ud.basecmd = d.getVar("FETCHCMD_git") or "git -c core.fsyncobjectfiles=0"
226 231
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 64cc9fa76b..1452d76151 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -698,13 +698,7 @@ class FetcherLocalTest(FetcherTest):
698 # Fetch and check revision 698 # Fetch and check revision
699 self.d.setVar("SRCREV", "AUTOINC") 699 self.d.setVar("SRCREV", "AUTOINC")
700 url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName" 700 url = "git://" + src_dir + ";protocol=file;usehead=1;name=newName"
701 try: 701 fetcher = bb.fetch.Fetch([url], self.d)
702 fetcher = bb.fetch.Fetch([url], self.d)
703 except Exception:
704 # TODO: We currently expect this test to fail. Drop the try and
705 # assert when usehead has been fixed.
706 return
707 self.assertEqual(1, 0)
708 fetcher.download() 702 fetcher.download()
709 fetcher.unpack(self.unpackdir) 703 fetcher.unpack(self.unpackdir)
710 stdout = bb.process.run("git rev-parse HEAD", 704 stdout = bb.process.run("git rev-parse HEAD",