[2.18][PATCH 0/7] Patch review
In this series, there is a notable exception to the usual stable patches:
* Work toward automatic upgrade of stable recipes:
* fetch2/git.py: add filter_regex parameter to latest_versionstring
* fetch2/wget.py: add filter_regex parameter to latest_versionstring
* fetch2/crate.py: add filter_regex parameter to latest_versionstring
* fetch2/__init__.py: add filter_regex to default latest_versionstring
* bb/tests/fetch.py: add case for filter_regex parameter in latest_versionstring
Please review this set of changes for wrynose and have comments back by end of day Tuesday, September 22.
Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/valkyrie/?#/builders/29/builds/4761
qemuarm64-armhost failed on 16233 – AB-INT: 502/520 and other errors on yocto gits
retried in https://autobuilder.yoctoproject.org/valkyrie/?#/builders/8/builds/4700
qemux86-64-musl-ptest failed on 16348 – AB-INT PTEST: python3 ptest failure: in test_interrupt
retried in https://autobuilder.yoctoproject.org/valkyrie/?#/builders/110/builds/1211
(master has the fix that I need to backport for this one)
The following changes since commit f0df79b6b56f6a69067adf974978d9405077f246:
tests/fetch: Swap bitbake github mirror for YP one (2026-09-08 14:13:56 +0200)
are available in the Git repository at:
https://git.openembedded.org/bitbake-contrib stable/2.18-nut
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.18-nut
for you to fetch changes up to 84a8d046593840df460c1312365031c817eb8918:
tests/fetch: Drop ftp checkstatus test (2026-09-14 23:00:27 +0200)
----------------------------------------------------------------
Chen Qi (5):
fetch2/git.py: add filter_regex parameter to latest_versionstring fetch2/wget.py: add filter_regex parameter to latest_versionstring fetch2/crate.py: add filter_regex parameter to latest_versionstring fetch2/__init__.py: add filter_regex to default latest_versionstring bb/tests/fetch.py: add case for filter_regex parameter in
latest_versionstring
Richard Purdie (2):
tests/fetch: Switch to YP mirror repos instead of github tests/fetch: Drop ftp checkstatus test
lib/bb/fetch2/__init__.py | 2 +- lib/bb/fetch2/crate.py | 10 +++- lib/bb/fetch2/git.py | 6 +- lib/bb/fetch2/wget.py | 17 ++++-- lib/bb/tests/fetch.py | 119 ++++++++++++++++++++++++++++++-------- 5 files changed, 121 insertions(+), 33 deletions(-)
[bitbake][wrynose][2.18][PATCH 6/7] tests/fetch: Switch to YP mirror repos instead of github
From: Richard Purdie <[email protected]>
We're having issues with github urls, switch many of the test repos to our own mirror copies. Some mirror copies are modified to reduce their size and improve test times. More needs to be done in that area!
--- lib/bb/tests/fetch.py | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
lib/bb/tests/fetch.py +20 -22
@@ -1218,7 +1218,7 @@ class FetcherNetworkTest(FetcherTest): def test_git_submodule_dbus_broker(self): # The following external repositories have show failures in fetch and unpack operations # We want to avoid regressions! - url = "gitsm://github.com/bus1/dbus-broker;protocol=https;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2;branch=main" + url = "gitsm://git.yoctoproject.org/bbfetchtests-bus1-dbus-broker;protocol=https;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2;branch=main" fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() # Previous cwd has been deleted
@@ -1234,7 +1234,7 @@ class FetcherNetworkTest(FetcherTest): @skipIfNoNetwork() def test_git_submodule_CLI11(self): - url = "gitsm://github.com/CLIUtils/CLI11;protocol=https;rev=bd4dc911847d0cde7a6b41dfa626a85aab213baf;branch=main" + url = "gitsm://git.yoctoproject.org/bbfetchtests-cliutils-cli11;protocol=https;rev=474872a222f61e57b16c2feb774610a4595a729e;branch=main" fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() # Previous cwd has been deleted
@@ -1244,17 +1244,16 @@ class FetcherNetworkTest(FetcherTest): repo_path = os.path.join(self.tempdir, 'unpacked', 'git') self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/googletest/config')), msg='Missing submodule config "extern/googletest"') self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/json/config')), msg='Missing submodule config "extern/json"') - self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/sanitizers/config')), msg='Missing submodule config "extern/sanitizers"') @skipIfNoNetwork() def test_git_submodule_update_CLI11(self): """ Prevent regression on update detection not finding missing submodule, or modules without needed commits """ - url = "gitsm://github.com/CLIUtils/CLI11;protocol=https;rev=cf6a99fa69aaefe477cc52e3ef4a7d2d7fa40714;branch=main" + url = "gitsm://git.yoctoproject.org/bbfetchtests-cliutils-cli11;protocol=https;rev=fe0e149a0624db734de37dc827af3328855f51cf;branch=main" fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() # CLI11 that pulls in a newer nlohmann-json - url = "gitsm://github.com/CLIUtils/CLI11;protocol=https;rev=49ac989a9527ee9bb496de9ded7b4872c2e0e5ca;branch=main" + url = "gitsm://git.yoctoproject.org/bbfetchtests-cliutils-cli11;protocol=https;rev=141f9dca45bd5ef42e7b1a06637860b7581370c8;branch=main" fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() # Previous cwd has been deleted
@@ -1264,11 +1263,10 @@ class FetcherNetworkTest(FetcherTest): repo_path = os.path.join(self.tempdir, 'unpacked', 'git') self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/googletest/config')), msg='Missing submodule config "extern/googletest"') self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/json/config')), msg='Missing submodule config "extern/json"') - self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/sanitizers/config')), msg='Missing submodule config "extern/sanitizers"') @skipIfNoNetwork() def test_git_submodule_aktualizr(self): - url = "gitsm://github.com/advancedtelematic/aktualizr;branch=master;protocol=https;rev=d00d1a04cc2366d1a5f143b84b9f507f8bd32c44" + url = "gitsm://git.yoctoproject.org/bbfetchtests-advancedtelematic-aktualizr;branch=master;protocol=https;rev=d00d1a04cc2366d1a5f143b84b9f507f8bd32c44" fetcher = bb.fetch.Fetch([url], self.d) fetcher.download() # Previous cwd has been deleted
@@ -1313,7 +1311,7 @@ class FetcherNetworkTest(FetcherTest): @skipIfNoNetwork() def test_git_submodule_reference_to_parent(self): - self.recipe_url = "gitsm://github.com/gflags/gflags.git;protocol=https;branch=master" + self.recipe_url = "gitsm://git.yoctoproject.org/bbfetchtests-gflags;protocol=https;branch=master" self.d.setVar("SRCREV", "14e1138441bbbb584160cb1c0a0426ec1bac35f1") with Timeout(60): fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
@@ -1478,7 +1476,7 @@ class FetchLatestVersionTest(FetcherTest): test_git_uris = { # version pattern "X.Y.Z" - ("mx-1.0", "git://github.com/clutter-project/mx.git;branch=mx-1.4;protocol=https", "9b1db6b8060bd00b121a692f942404a24ae2960f", "", "") + ("mx-1.0", "git://git.yoctoproject.org/bbfetchtests-clutter-mx;branch=mx-1.4;protocol=https", "9b1db6b8060bd00b121a692f942404a24ae2960f", "", "") : "1.99.4", # version pattern "vX.Y" # mirror of git.infradead.org since network issues interfered with testing
@@ -1505,11 +1503,11 @@ class FetchLatestVersionTest(FetcherTest): : "0.4.3", ("build-appliance-image", "git://git.yoctoproject.org/poky;branch=master;protocol=https", "b37dd451a52622d5b570183a81583cc34c2ff555", r"(?P<pver>(([0-9][\.|_]?)+[0-9]))", "") : "11.0.0", - ("chkconfig-alternatives-native", "git://github.com/kergoth/chkconfig;branch=sysroot;protocol=https", "cd437ecbd8986c894442f8fce1e0061e20f04dee", r"chkconfig\-(?P<pver>((\d+[\.\-_]*)+))", "") + ("chkconfig-alternatives-native", "git://git.yoctoproject.org/bbfetchtests-kergoth-chkconfig;branch=sysroot;protocol=https", "cd437ecbd8986c894442f8fce1e0061e20f04dee", r"chkconfig\-(?P<pver>((\d+[\.\-_]*)+))", "") : "1.3.59", - ("remake", "git://github.com/rocky/remake.git;protocol=https;branch=master", "f05508e521987c8494c92d9c2871aec46307d51d", r"(?P<pver>(\d+\.(\d+\.)*\d*(\+dbg\d+(\.\d+)*)*))", "") + ("remake", "git://git.yoctoproject.org/bbfetchtests-rocky-remake;protocol=https;branch=master", "f05508e521987c8494c92d9c2871aec46307d51d", r"(?P<pver>(\d+\.(\d+\.)*\d*(\+dbg\d+(\.\d+)*)*))", "") : "3.82+dbg0.9", - ("sysdig", "git://github.com/draios/sysdig.git;branch=dev;protocol=https", "4fb6288275f567f63515df0ff0a6518043ecfa9b", r"^(?P<pver>\d+(\.\d+)+)", "10.0.0") + ("sysdig", "git://git.yoctoproject.org/bbfetchtests-draios-sysdig;branch=dev;protocol=https", "4fb6288275f567f63515df0ff0a6518043ecfa9b", r"^(?P<pver>\d+(\.\d+)+)", "10.0.0") : "0.28.0", }
@@ -1582,7 +1580,7 @@ class FetchLatestVersionTest(FetcherTest): test_git_stable_uris = { ("dtc", "git://git.yoctoproject.org/bbfetchtests-dtc.git;branch=master;protocol=https", "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf", "", r"^1\.4\.\d+$") : ("1.4.0", "1.5.0"), - ("systemd", "git://github.com/systemd/systemd.git;protocol=https;branch=stable/v259-stable", "b3d8fc43e9cb531d958c17ef2cd93b374bc14e8a", "", r"^259\.\d+$") + ("systemd", "git://git.yoctoproject.org/bbfetchtests-systemd;protocol=https;branch=stable/v259-stable", "b3d8fc43e9cb531d958c17ef2cd93b374bc14e8a", "", r"^259\.\d+$") : ("259.5", "260") }
@@ -3267,11 +3265,11 @@ class NPMTest(FetcherTest): 'resolved': 'https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz', 'integrity': 'sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==', 'dependencies': { - 'cookie': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + 'cookie': 'git+https://git.yoctoproject.org/bbfetchtests-jshttp-cookie#aec1177c7da67e3b3273df96cf476824dbc9ae09' } }, 'node_modules/array-flatten/node_modules/content-type/node_modules/cookie': { - 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + 'resolved': 'git+https://git.yoctoproject.org/bbfetchtests-jshttp-cookie#aec1177c7da67e3b3273df96cf476824dbc9ae09' } } })
@@ -3279,7 +3277,7 @@ class NPMTest(FetcherTest): fetcher.download() self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'array-flatten-1.1.1.tgz'))) self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'content-type-1.0.4.tgz'))) - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'git.yoctoproject.org.bbfetchtests-jshttp-cookie'))) fetcher.unpack(self.unpackdir) self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'npm-shrinkwrap.json'))) self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'node_modules', 'array-flatten', 'package.json')))
@@ -3292,13 +3290,13 @@ class NPMTest(FetcherTest): swfile = self.create_shrinkwrap_file({ 'packages': { 'node_modules/cookie': { - 'resolved': 'git+https://github.com/jshttp/cookie.git#aec1177c7da67e3b3273df96cf476824dbc9ae09' + 'resolved': 'git+https://git.yoctoproject.org/bbfetchtests-jshttp-cookie#aec1177c7da67e3b3273df96cf476824dbc9ae09' } } }) fetcher = bb.fetch.Fetch(['npmsw://' + swfile], self.d) fetcher.download() - self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'github.com.jshttp.cookie.git'))) + self.assertTrue(os.path.exists(os.path.join(self.dldir, 'git2', 'git.yoctoproject.org.bbfetchtests-jshttp-cookie'))) @skipIfNoNetwork() def test_npmsw_dev(self):
@@ -4005,20 +4003,20 @@ class GoModGitTest(FetcherTest): @skipIfNoNetwork() def test_gomodgit_url_host_only(self): urls = ['gomodgit://go.opencensus.io;version=v0.24.0;' - 'repo=github.com/census-instrumentation/opencensus-go;' + 'repo=git.yoctoproject.org/bbfetchtests-census-instrumentation-opencensus-go;' 'srcrev=b1a01ee95db0e690d91d7193d037447816fae4c5'] fetcher = bb.fetch2.Fetch(urls, self.d) ud = fetcher.ud[urls[0]] - self.assertEqual(ud.host, 'github.com') - self.assertEqual(ud.path, '/census-instrumentation/opencensus-go') + self.assertEqual(ud.host, 'git.yoctoproject.org') + self.assertEqual(ud.path, '/bbfetchtests-census-instrumentation-opencensus-go') self.assertEqual(ud.name, '[email protected]') self.assertEqual(self.d.getVar('[email protected]'), 'b1a01ee95db0e690d91d7193d037447816fae4c5') fetcher.download() fetcher.unpack(self.unpackdir) vcsdir = os.path.join(self.unpackdir, 'pkg/mod/cache/vcs') - self.assertTrue(os.path.exists(os.path.join(vcsdir, 'aae3ac7b2122ed3345654e6327855e9682f4a5350d63e93dbcfc51c4419df0e1'))) + self.assertTrue(os.path.exists(os.path.join(vcsdir, '24e4a8be150f9e7343b72e40000115a175fb2f19d015542f54abb6ccdbd52f14'))) downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') self.assertTrue(os.path.exists(os.path.join(downloaddir, 'go.opencensus.io/@v/v0.24.0.zip'))) self.assertTrue(os.path.exists(os.path.join(downloaddir, 'go.opencensus.io/@v/v0.24.0.mod')))
[bitbake][wrynose][2.18][PATCH 7/7] tests/fetch: Drop ftp checkstatus test
In reply to Yoann CongalFrom: Richard Purdie <[email protected]>
This single url takes 100s in each of the two tests it is used in, compared to the fraction of a second for the other urls. Nobody should really be using ftp any more anyway, drop this test url.
--- lib/bb/tests/fetch.py | 1 - 1 file changed, 1 deletion(-)
lib/bb/tests/fetch.py +0 -1
@@ -1716,7 +1716,6 @@ class FetchCheckStatusTest(FetcherTest): "https://docs.yoctoproject.org", "https://downloads.yoctoproject.org/releases/opkg/opkg-0.1.7.tar.gz", "https://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz", - "ftp://sourceware.org/pub/libffi/libffi-1.20.tar.gz", ] def _start_checkstatus_server(self):
[bitbake][wrynose][2.18][PATCH 5/7] bb/tests/fetch.py: add case for filter_regex parameter in latest_versionstring
In reply to Yoann CongalFrom: Chen Qi <[email protected]>
Add bitbake selftest case for fitler_regex parameter in latest_versionstring to ensure no regression.
--- lib/bb/tests/fetch.py | 78 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-)
lib/bb/tests/fetch.py +77 -1
@@ -1577,7 +1577,24 @@ class FetchLatestVersionTest(FetcherTest): # basic example; version pattern "A.B.C+cargo-D.E.F" ("cargo-c", "crate://crates.io/cargo-c/0.9.18+cargo-0.69") : "0.9.29" - } + } + + test_git_stable_uris = { + ("dtc", "git://git.yoctoproject.org/bbfetchtests-dtc.git;branch=master;protocol=https", "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf", "", r"^1\.4\.\d+$") + : ("1.4.0", "1.5.0"), + ("systemd", "git://github.com/systemd/systemd.git;protocol=https;branch=stable/v259-stable", "b3d8fc43e9cb531d958c17ef2cd93b374bc14e8a", "", r"^259\.\d+$") + : ("259.5", "260") + } + + test_wget_stable_uris = { + ("openssh", "https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.2p1.tar.gz", "10.2p1", "", "", r"^10\.2p\d+$") + : ("10.2p1", "10.3") + } + + test_crate_stable_uris = { + ("cargo-c", "crate://crates.io/cargo-c/0.9.18+cargo-0.69", r"^0\.9\.\d+") + : ("0.9.29", "0.10.0") + } @skipIfNoNetwork() def test_git_latest_versionstring(self):
@@ -1634,6 +1651,65 @@ class FetchLatestVersionTest(FetcherTest): r = bb.utils.vercmp_string(v, verstring) self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring)) + @skipIfNoNetwork() + def test_git_latest_versionstring_stable(self): + for k, v in self.test_git_stable_uris.items(): + with self.subTest(pn=k[0]): + self.d.setVar("PN", k[0]) + self.d.setVar("SRCREV", k[2]) + self.d.setVar("UPSTREAM_CHECK_GITTAGREGEX", k[3]) + filter_regex = k[4] + ud = bb.fetch2.FetchData(k[1], self.d) + pupver= ud.method.latest_versionstring(ud, self.d, filter_regex=filter_regex) + verstring = pupver[0] + self.assertTrue(verstring, msg="Could not find upstream version for %s" % k[0]) + v_less_or_equal = v[0] + v_larger = v[1] + r = bb.utils.vercmp_string(v_less_or_equal, verstring) + self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s < %s" % (k[0], v_less_or_equal, verstring)) + r = bb.utils.vercmp_string(verstring, v_larger) + self.assertTrue(r == -1, msg="Package %s, version: %s <= %s" % (k[0], v_larger, verstring)) + + @skipIfNoNetwork() + def test_wget_latest_versionstring_stable(self): + for k, v in self.test_wget_stable_uris.items(): + with self.subTest(pn=k[0]): + self.d.setVar("PN", k[0]) + url = k[1] + self.d.setVar("PV", k[2]) + if k[3]: + self.d.setVar("UPSTREAM_CHECK_URI", k[3]) + if k[4]: + self.d.setVar("UPSTREAM_CHECK_REGEX", k[4]) + filter_regex = k[5] + ud = bb.fetch2.FetchData(url, self.d) + pupver= ud.method.latest_versionstring(ud, self.d, filter_regex=filter_regex) + verstring = pupver[0] + self.assertTrue(verstring, msg="Could not find upstream version for %s" % k[0]) + v_less_or_equal = v[0] + v_larger = v[1] + r = bb.utils.vercmp_string(v_less_or_equal, verstring) + self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s < %s" % (k[0], v_less_or_equal, verstring)) + r = bb.utils.vercmp_string(verstring, v_larger) + self.assertTrue(r == -1, msg="Package %s, version: %s <= %s" % (k[0], v_larger, verstring)) + + @skipIfNoNetwork() + def test_crate_latest_versionstring_stable(self): + for k, v in self.test_crate_stable_uris.items(): + with self.subTest(pn=k[0]): + self.d.setVar("PN", k[0]) + ud = bb.fetch2.FetchData(k[1], self.d) + filter_regex = k[2] + pupver = ud.method.latest_versionstring(ud, self.d, filter_regex=filter_regex) + verstring = pupver[0] + self.assertTrue(verstring, msg="Could not find upstream version for %s" % k[0]) + v_less_or_equal = v[0] + v_larger = v[1] + r = bb.utils.vercmp_string(v_less_or_equal, verstring) + self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s < %s" % (k[0], v_less_or_equal, verstring)) + r = bb.utils.vercmp_string(verstring, v_larger) + self.assertTrue(r == -1, msg="Package %s, version: %s <= %s" % (k[0], v_larger, verstring)) + class FetchCheckStatusTest(FetcherTest): test_wget_uris = ["https://downloads.yoctoproject.org/releases/sato/sato-engine-0.1.tar.gz", "https://downloads.yoctoproject.org/releases/sato/sato-engine-0.2.tar.gz",
[bitbake][wrynose][2.18][PATCH 4/7] fetch2/__init__.py: add filter_regex to default latest_versionstring
In reply to Yoann CongalFrom: Chen Qi <[email protected]>
Add filter_regex parameter to the default latest_versionstring function so that fetchers that do not implement this function can also take the filter_regex parameter.
--- lib/bb/fetch2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +1 -1
@@ -1735,7 +1735,7 @@ class FetchMethod(object): def generate_revision_key(self, ud, d, name): return self._revision_key(ud, d, name) - def latest_versionstring(self, ud, d): + def latest_versionstring(self, ud, d, filter_regex=None): """ Compute the latest release name like "x.y.x" in "x.y.x+gitHASH" by searching through the tags output of ls-remote, comparing
[bitbake][wrynose][2.18][PATCH 1/7] fetch2/git.py: add filter_regex parameter to latest_versionstring
In reply to Yoann CongalFrom: Chen Qi <[email protected]>
We want to be able to do stable version upgrade for recipes. For example, 1.0.0 -> 1.0.1 instead of 1.0.0 -> 1.1.0.
To to this, we need an extra paramter to latest_versionstring so that we are able to filter out the versions we need. Using regex has the advantage of adapting to different version schemes.
--- lib/bb/fetch2/git.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +5 -1
@@ -975,7 +975,7 @@ class Git(FetchMethod): raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output for %s" % \ (ud.unresolvedrev, ud.host+ud.path)) - def latest_versionstring(self, ud, d): + def latest_versionstring(self, ud, d, filter_regex=None): """ Compute the latest release name like "x.y.x" in "x.y.x+gitHASH" by searching through the tags output of ls-remote, comparing
@@ -1015,6 +1015,10 @@ class Git(FetchMethod): pver = m.group('pver').replace("_", ".") + if filter_regex: + if not re.match(filter_regex, pver): + continue + if verstring and bb.utils.vercmp(("0", pver, ""), ("0", verstring, "")) < 0: continue
[bitbake][wrynose][2.18][PATCH 2/7] fetch2/wget.py: add filter_regex parameter to latest_versionstring
In reply to Yoann CongalFrom: Chen Qi <[email protected]>
We want to be able to do stable version upgrade for recipes. For example, 1.0.0 -> 1.0.1 instead of 1.0.0 -> 1.1.0.
To to this, we need an extra paramter to latest_versionstring so that we are able to filter out the versions we need. Using regex has the advantage of adapting to different version schemes.
--- lib/bb/fetch2/wget.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
lib/bb/fetch2/wget.py +11 -6
@@ -515,7 +515,7 @@ class Wget(FetchMethod): return fetchresult - def _check_latest_version(self, url, package, package_regex, current_version, ud, d): + def _check_latest_version(self, url, package, package_regex, current_version, ud, d, filter_regex=None): """ Return the latest version of a package inside a given directory path If error or no version, return ""
@@ -538,6 +538,11 @@ class Wget(FetchMethod): newver = self._parse_path(package_regex, str(line)) if newver: + if filter_regex: + # filter_regex is derived from PV, and uses . as separator + # while upstream may be using _ as separator + if not re.match(filter_regex, re.sub('_', '.', newver[1])): + continue bb.debug(3, "Upstream version found: %s" % newver[1]) if valid == 0: version = newver
@@ -555,7 +560,7 @@ class Wget(FetchMethod): return "" - def _check_latest_version_by_dir(self, dirver, package, package_regex, current_version, ud, d): + def _check_latest_version_by_dir(self, dirver, package, package_regex, current_version, ud, d, filter_regex=None): """ Scan every directory in order to get upstream version. """
@@ -599,7 +604,7 @@ class Wget(FetchMethod): ud.user, ud.pswd, {}]) pupver = self._check_latest_version(uri, - package, package_regex, current_version, ud, d) + package, package_regex, current_version, ud, d, filter_regex) if pupver: version[1] = pupver
@@ -660,7 +665,7 @@ class Wget(FetchMethod): return package_custom_regex_comp - def latest_versionstring(self, ud, d): + def latest_versionstring(self, ud, d, filter_regex=None): """ Manipulate the URL and try to obtain the latest package version
@@ -701,11 +706,11 @@ class Wget(FetchMethod): dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn))) if not dirver_pn_regex.search(dirver): return (self._check_latest_version_by_dir(dirver, - package, package_regex, current_version, ud, d), '') + package, package_regex, current_version, ud, d, filter_regex), '') uri = bb.fetch.encodeurl([ud.type, ud.host, path, ud.user, ud.pswd, {}]) else: uri = regex_uri return (self._check_latest_version(uri, package, package_regex, - current_version, ud, d), '') + current_version, ud, d, filter_regex), '')
[bitbake][wrynose][2.18][PATCH 3/7] fetch2/crate.py: add filter_regex parameter to latest_versionstring
In reply to Yoann CongalFrom: Chen Qi <[email protected]>
We want to be able to do stable version upgrade for recipes. For example, 1.0.0 -> 1.0.1 instead of 1.0.0 -> 1.1.0.
To to this, we need an extra paramter to latest_versionstring so that we are able to filter out the versions we need. Using regex has the advantage of adapting to different version schemes.
--- lib/bb/fetch2/crate.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/bb/fetch2/crate.py +8 -2
@@ -13,6 +13,7 @@ BitBake 'Fetch' implementation for crates.io import hashlib import json import os +import re import subprocess import bb from bb.fetch2 import logger, subprocess_setup, UnpackError
@@ -155,18 +156,20 @@ class Crate(Wget): with open(mdpath, "w") as f: json.dump(metadata, f) - def latest_versionstring(self, ud, d): + def latest_versionstring(self, ud, d, filter_regex=None): """ Return the latest version available when versionsurl is the [name]/versions URL. """ from functools import cmp_to_key json_data = json.loads(self._fetch_index(ud.versionsurl, ud, d)) versions = [(0, i["num"], "") for i in json_data["versions"]] + if filter_regex: + versions = [v for v in versions if re.match(filter_regex, v[1])] versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp)) return (versions[-1][1], "") if versions else ("", "") - def latest_versionstring_from_index(self, ud, d): + def latest_versionstring_from_index(self, ud, d, filter_regex=None): """ Return the latest version available when versionsurl is a Cargo index file.
@@ -181,5 +184,8 @@ class Crate(Wget): if not data.get("yanked", False): versions.append((0, data["vers"], "")) + if filter_regex: + versions = [v for v in versions if re.match(filter_regex, v[1])] + versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp)) return (versions[-1][1], "") if versions else ("", "")