From 753e563ccc57a31758905b239b95008e3e19466a Mon Sep 17 00:00:00 2001 From: "Lauren N. Liberda" Date: Sun, 13 Aug 2023 22:20:45 +0200 Subject: [PATCH] parse: allow "-r" in pkgver this seems to be parsed correctly, other than this one check bug: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2260 Reviewed-by: Oliver Smith Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230813202045.24493-1-lauren@selfisekai.rocks%3E --- pmb/parse/_apkbuild.py | 3 +-- test/test_parse_apkbuild.py | 7 +++++++ test/testdata/apkbuild/APKBUILD.weird-pkgver | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/testdata/apkbuild/APKBUILD.weird-pkgver diff --git a/pmb/parse/_apkbuild.py b/pmb/parse/_apkbuild.py index 39b27868..6e9d004f 100644 --- a/pmb/parse/_apkbuild.py +++ b/pmb/parse/_apkbuild.py @@ -320,8 +320,7 @@ def apkbuild(path, check_pkgver=True, check_pkgname=True): # Sanity check: pkgver if check_pkgver: - if ("-r" in ret["pkgver"] or not - pmb.parse.version.validate(ret["pkgver"])): + if not pmb.parse.version.validate(ret["pkgver"]): logging.info( "NOTE: Valid pkgvers are described here: " "https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#pkgver") diff --git a/test/test_parse_apkbuild.py b/test/test_parse_apkbuild.py index d34072d5..2b91ca12 100644 --- a/test/test_parse_apkbuild.py +++ b/test/test_parse_apkbuild.py @@ -154,3 +154,10 @@ def test_parse_unmaintained(): path = (f"{pmb_test.const.testdata}/apkbuild" "/APKBUILD.missing-pkgdesc-in-subpackage") assert pmb.parse._apkbuild.unmaintained(path) == "This is broken!" + + +def test_weird_pkgver(): + path = (f"{pmb_test.const.testdata}/apkbuild" + "/APKBUILD.weird-pkgver") + apkbuild = pmb.parse.apkbuild(path, check_pkgname=False, check_pkgver=True) + assert apkbuild["pkgver"] == "3.0.0_alpha369-r0" diff --git a/test/testdata/apkbuild/APKBUILD.weird-pkgver b/test/testdata/apkbuild/APKBUILD.weird-pkgver new file mode 100644 index 00000000..a4754416 --- /dev/null +++ b/test/testdata/apkbuild/APKBUILD.weird-pkgver @@ -0,0 +1,8 @@ +pkgname=dart-stage0 +pkgver=3.0.0_alpha369-r0 +pkgrel=1 +pkgdesc="Dart is a client-optimized language for fast apps on any platform (temporary bootstrap package)" +url="https://dart.dev/" +arch="aarch64 armv7 x86_64" +license="BSD-3-Clause" +options="!check"