diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 50 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 3 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 27 | ||||
-rw-r--r-- | bitbake/lib/toaster/tests/builds/buildtest.py | 2 |
5 files changed, 64 insertions, 25 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 2de4f4f8c0..0ad987c596 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -1117,7 +1117,10 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): | |||
1117 | origud.method.build_mirror_data(origud, ld) | 1117 | origud.method.build_mirror_data(origud, ld) |
1118 | return origud.localpath | 1118 | return origud.localpath |
1119 | # Otherwise the result is a local file:// and we symlink to it | 1119 | # Otherwise the result is a local file:// and we symlink to it |
1120 | ensure_symlink(ud.localpath, origud.localpath) | 1120 | # This may also be a link to a shallow archive |
1121 | # When using shallow mode, add a symlink to the original fullshallow | ||
1122 | # path to ensure a valid symlink even in the `PREMIRRORS` case | ||
1123 | origud.method.update_mirror_links(ud, origud) | ||
1121 | update_stamp(origud, ld) | 1124 | update_stamp(origud, ld) |
1122 | return ud.localpath | 1125 | return ud.localpath |
1123 | 1126 | ||
@@ -1151,25 +1154,6 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): | |||
1151 | if ud.lockfile and ud.lockfile != origud.lockfile: | 1154 | if ud.lockfile and ud.lockfile != origud.lockfile: |
1152 | bb.utils.unlockfile(lf) | 1155 | bb.utils.unlockfile(lf) |
1153 | 1156 | ||
1154 | |||
1155 | def ensure_symlink(target, link_name): | ||
1156 | if not os.path.exists(link_name): | ||
1157 | dirname = os.path.dirname(link_name) | ||
1158 | bb.utils.mkdirhier(dirname) | ||
1159 | if os.path.islink(link_name): | ||
1160 | # Broken symbolic link | ||
1161 | os.unlink(link_name) | ||
1162 | |||
1163 | # In case this is executing without any file locks held (as is | ||
1164 | # the case for file:// URLs), two tasks may end up here at the | ||
1165 | # same time, in which case we do not want the second task to | ||
1166 | # fail when the link has already been created by the first task. | ||
1167 | try: | ||
1168 | os.symlink(target, link_name) | ||
1169 | except FileExistsError: | ||
1170 | pass | ||
1171 | |||
1172 | |||
1173 | def try_mirrors(fetch, d, origud, mirrors, check = False): | 1157 | def try_mirrors(fetch, d, origud, mirrors, check = False): |
1174 | """ | 1158 | """ |
1175 | Try to use a mirrored version of the sources. | 1159 | Try to use a mirrored version of the sources. |
@@ -1589,11 +1573,11 @@ class FetchMethod(object): | |||
1589 | datafile = None | 1573 | datafile = None |
1590 | if output: | 1574 | if output: |
1591 | for line in output.decode().splitlines(): | 1575 | for line in output.decode().splitlines(): |
1592 | if line.startswith('data.tar.'): | 1576 | if line.startswith('data.tar.') or line == 'data.tar': |
1593 | datafile = line | 1577 | datafile = line |
1594 | break | 1578 | break |
1595 | else: | 1579 | else: |
1596 | raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) | 1580 | raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar* file", urldata.url) |
1597 | else: | 1581 | else: |
1598 | raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) | 1582 | raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) |
1599 | cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile) | 1583 | cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile) |
@@ -1655,6 +1639,28 @@ class FetchMethod(object): | |||
1655 | """ | 1639 | """ |
1656 | bb.utils.remove(urldata.localpath) | 1640 | bb.utils.remove(urldata.localpath) |
1657 | 1641 | ||
1642 | def ensure_symlink(self, target, link_name): | ||
1643 | if not os.path.exists(link_name): | ||
1644 | dirname = os.path.dirname(link_name) | ||
1645 | bb.utils.mkdirhier(dirname) | ||
1646 | if os.path.islink(link_name): | ||
1647 | # Broken symbolic link | ||
1648 | os.unlink(link_name) | ||
1649 | |||
1650 | # In case this is executing without any file locks held (as is | ||
1651 | # the case for file:// URLs), two tasks may end up here at the | ||
1652 | # same time, in which case we do not want the second task to | ||
1653 | # fail when the link has already been created by the first task. | ||
1654 | try: | ||
1655 | os.symlink(target, link_name) | ||
1656 | except FileExistsError: | ||
1657 | pass | ||
1658 | |||
1659 | def update_mirror_links(self, ud, origud): | ||
1660 | # For local file:// results, create a symlink to them | ||
1661 | # This may also be a link to a shallow archive | ||
1662 | self.ensure_symlink(ud.localpath, origud.localpath) | ||
1663 | |||
1658 | def try_premirror(self, urldata, d): | 1664 | def try_premirror(self, urldata, d): |
1659 | """ | 1665 | """ |
1660 | Should premirrors be used? | 1666 | Should premirrors be used? |
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 784a45bda2..55dd084abc 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -348,6 +348,13 @@ class Git(FetchMethod): | |||
348 | def tarball_need_update(self, ud): | 348 | def tarball_need_update(self, ud): |
349 | return ud.write_tarballs and not os.path.exists(ud.fullmirror) | 349 | return ud.write_tarballs and not os.path.exists(ud.fullmirror) |
350 | 350 | ||
351 | def update_mirror_links(self, ud, origud): | ||
352 | super().update_mirror_links(ud, origud) | ||
353 | # When using shallow mode, add a symlink to the original fullshallow | ||
354 | # path to ensure a valid symlink even in the `PREMIRRORS` case | ||
355 | if ud.shallow and not os.path.exists(origud.fullshallow): | ||
356 | self.ensure_symlink(ud.localpath, origud.fullshallow) | ||
357 | |||
351 | def try_premirror(self, ud, d): | 358 | def try_premirror(self, ud, d): |
352 | # If we don't do this, updating an existing checkout with only premirrors | 359 | # If we don't do this, updating an existing checkout with only premirrors |
353 | # is not possible | 360 | # is not possible |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 8fadc8338e..80f3d3282f 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -3034,14 +3034,13 @@ def build_scenequeue_data(sqdata, rqdata, sqrq): | |||
3034 | rqdata.init_progress_reporter.next_stage(len(rqdata.runtaskentries)) | 3034 | rqdata.init_progress_reporter.next_stage(len(rqdata.runtaskentries)) |
3035 | 3035 | ||
3036 | # Sanity check all dependencies could be changed to setscene task references | 3036 | # Sanity check all dependencies could be changed to setscene task references |
3037 | for taskcounter, tid in enumerate(rqdata.runtaskentries): | 3037 | for tid in rqdata.runtaskentries: |
3038 | if tid in rqdata.runq_setscene_tids: | 3038 | if tid in rqdata.runq_setscene_tids: |
3039 | pass | 3039 | pass |
3040 | elif sq_revdeps_squash[tid]: | 3040 | elif sq_revdeps_squash[tid]: |
3041 | bb.msg.fatal("RunQueue", "Something went badly wrong during scenequeue generation, halting. Please report this problem.") | 3041 | bb.msg.fatal("RunQueue", "Something went badly wrong during scenequeue generation, halting. Please report this problem.") |
3042 | else: | 3042 | else: |
3043 | del sq_revdeps_squash[tid] | 3043 | del sq_revdeps_squash[tid] |
3044 | rqdata.init_progress_reporter.update(taskcounter) | ||
3045 | 3044 | ||
3046 | rqdata.init_progress_reporter.next_stage() | 3045 | rqdata.init_progress_reporter.next_stage() |
3047 | 3046 | ||
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 3f42332588..077472b8b3 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2238,6 +2238,33 @@ class GitShallowTest(FetcherTest): | |||
2238 | self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0]) | 2238 | self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0]) |
2239 | 2239 | ||
2240 | @skipIfNoNetwork() | 2240 | @skipIfNoNetwork() |
2241 | def test_git_shallow_fetch_premirrors(self): | ||
2242 | url = "git://git.openembedded.org/bitbake;branch=master;protocol=https" | ||
2243 | |||
2244 | # Create a separate premirror directory within tempdir | ||
2245 | premirror = os.path.join(self.tempdir, "premirror") | ||
2246 | os.mkdir(premirror) | ||
2247 | |||
2248 | # Fetch a non-shallow clone into the premirror subdir | ||
2249 | self.d.setVar('BB_GIT_SHALLOW', '0') | ||
2250 | self.d.setVar("DL_DIR", premirror) | ||
2251 | fetcher, ud = self.fetch(url) | ||
2252 | |||
2253 | # Fetch a shallow clone from the premirror subdir with unpacking | ||
2254 | # using the original recipe URL and the premirror mapping | ||
2255 | self.d.setVar('BB_GIT_SHALLOW', '1') | ||
2256 | self.d.setVar("DL_DIR", self.dldir) | ||
2257 | self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') | ||
2258 | self.d.setVar('BB_NO_NETWORK', '1') | ||
2259 | self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0') | ||
2260 | self.d.setVar("PREMIRRORS", "git://.*/.* git://{0};protocol=file".format(premirror + "/git2/" + ud.host + ud.path.replace("/", "."))) | ||
2261 | fetcher = self.fetch_and_unpack(url) | ||
2262 | |||
2263 | # Verify that the unpacked sources are shallow clones | ||
2264 | self.assertRevCount(1) | ||
2265 | assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')) | ||
2266 | |||
2267 | @skipIfNoNetwork() | ||
2241 | def test_bitbake(self): | 2268 | def test_bitbake(self): |
2242 | self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcdir) | 2269 | self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcdir) |
2243 | self.git('config core.bare true', cwd=self.srcdir) | 2270 | self.git('config core.bare true', cwd=self.srcdir) |
diff --git a/bitbake/lib/toaster/tests/builds/buildtest.py b/bitbake/lib/toaster/tests/builds/buildtest.py index cacfccd4d3..e54d561334 100644 --- a/bitbake/lib/toaster/tests/builds/buildtest.py +++ b/bitbake/lib/toaster/tests/builds/buildtest.py | |||
@@ -128,7 +128,7 @@ class BuildTest(unittest.TestCase): | |||
128 | if os.environ.get("TOASTER_TEST_USE_SSTATE_MIRROR"): | 128 | if os.environ.get("TOASTER_TEST_USE_SSTATE_MIRROR"): |
129 | ProjectVariable.objects.get_or_create( | 129 | ProjectVariable.objects.get_or_create( |
130 | name="SSTATE_MIRRORS", | 130 | name="SSTATE_MIRRORS", |
131 | value="file://.* http://cdn.jsdelivr.net/yocto/sstate/all/PATH;downloadfilename=PATH", | 131 | value="file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH", |
132 | project=project) | 132 | project=project) |
133 | 133 | ||
134 | ProjectTarget.objects.create(project=project, | 134 | ProjectTarget.objects.create(project=project, |