Sometimes I want to build an older version of a package from Alpine, and
since package upgrades can involve things like patches and other
externalities just changing the pkgver and running checksum in pmaports
may not be enough. As such, it tends to be easier to revert the change
in the local aports repo and then fork than forking and then trying to
manually revert the changes yourself (since you can't have git do that
for you given that they are distinct repositories).
Prior to this patch, that was not possible since pmbootstrap would
assume older aport version equals outdated aports in general and as such
cancel the whole operation. Instead, just print a warning and helpful
information to make this workflow possible while also warning users that
they may want to update their local aports.
---
pmb/aportgen/core.py | 9 ++++-----test/test_aportgen.py | 4 +---
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/pmb/aportgen/core.py b/pmb/aportgen/core.py
index 65fa8963..30ee94c9 100644
--- a/pmb/aportgen/core.py+++ b/pmb/aportgen/core.py
@@ -202,8 +202,6 @@ def get_upstream_aport(args, pkgname, arch=None):
# Compare version (return when equal)
compare = pmb.parse.version.compare(apkbuild_version, package["version"])
- if compare == 0:- return aport_path # APKBUILD > binary: this is fine
if compare == 1:
@@ -213,10 +211,11 @@ def get_upstream_aport(args, pkgname, arch=None):
return aport_path
# APKBUILD < binary: aports.git is outdated
- logging.error("ERROR: Package '" + pkgname + "' has a lower version in"+ if compare == -1:+ logging.warning("WARNING: Package '" + pkgname + "' has a lower version in" " local checkout of Alpine's aports (" + apkbuild_version +
") compared to Alpine's binary package (" +
package["version"] + ")!")
+ logging.info("NOTE: You can update your local checkout with: 'pmbootstrap pull'")- raise RuntimeError("You can update your local checkout with: "- "'pmbootstrap pull'")+ return aport_path
diff --git a/test/test_aportgen.py b/test/test_aportgen.py
index ceb1515c..3ab4f757 100644
--- a/test/test_aportgen.py+++ b/test/test_aportgen.py
@@ -123,9 +123,7 @@ def test_aportgen_get_upstream_aport(args, monkeypatch):
# APKBUILD < binary
apkbuild = {"pkgver": "1.0", "pkgrel": "0"}
package = {"version": "2.0-r0"}
- with pytest.raises(RuntimeError) as e:- func(args, upstream)- assert str(e.value).startswith("You can update your local checkout with")+ assert func(args, upstream) == upstream_full # APKBUILD > binary
apkbuild = {"pkgver": "3.0", "pkgrel": "0"}
--
2.43.0
On Sat Dec 9, 2023 at 12:18 PM CET, Newbyte wrote:
> Sometimes I want to build an older version of a package from Alpine, and> since package upgrades can involve things like patches and other> externalities just changing the pkgver and running checksum in pmaports> may not be enough. As such, it tends to be easier to revert the change> in the local aports repo and then fork than forking and then trying to> manually revert the changes yourself (since you can't have git do that> for you given that they are distinct repositories).>> Prior to this patch, that was not possible since pmbootstrap would> assume older aport version equals outdated aports in general and as such> cancel the whole operation. Instead, just print a warning and helpful> information to make this workflow possible while also warning users that> they may want to update their local aports.
Makes sense, thanks!
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
> ---> pmb/aportgen/core.py | 9 ++++-----> test/test_aportgen.py | 4 +---> 2 files changed, 5 insertions(+), 8 deletions(-)>> diff --git a/pmb/aportgen/core.py b/pmb/aportgen/core.py> index 65fa8963..30ee94c9 100644> --- a/pmb/aportgen/core.py> +++ b/pmb/aportgen/core.py> @@ -202,8 +202,6 @@ def get_upstream_aport(args, pkgname, arch=None):> > # Compare version (return when equal)> compare = pmb.parse.version.compare(apkbuild_version, package["version"])> - if compare == 0:> - return aport_path> > # APKBUILD > binary: this is fine> if compare == 1:> @@ -213,10 +211,11 @@ def get_upstream_aport(args, pkgname, arch=None):> return aport_path> > # APKBUILD < binary: aports.git is outdated> - logging.error("ERROR: Package '" + pkgname + "' has a lower version in"> + if compare == -1:> + logging.warning("WARNING: Package '" + pkgname + "' has a lower version in"> " local checkout of Alpine's aports (" + apkbuild_version +> ") compared to Alpine's binary package (" +> package["version"] + ")!")> + logging.info("NOTE: You can update your local checkout with: 'pmbootstrap pull'")> > - raise RuntimeError("You can update your local checkout with: "> - "'pmbootstrap pull'")> + return aport_path> diff --git a/test/test_aportgen.py b/test/test_aportgen.py> index ceb1515c..3ab4f757 100644> --- a/test/test_aportgen.py> +++ b/test/test_aportgen.py> @@ -123,9 +123,7 @@ def test_aportgen_get_upstream_aport(args, monkeypatch):> # APKBUILD < binary> apkbuild = {"pkgver": "1.0", "pkgrel": "0"}> package = {"version": "2.0-r0"}> - with pytest.raises(RuntimeError) as e:> - func(args, upstream)> - assert str(e.value).startswith("You can update your local checkout with")> + assert func(args, upstream) == upstream_full> > # APKBUILD > binary> apkbuild = {"pkgver": "3.0", "pkgrel": "0"}> -- > 2.43.0
On Sat, 9 Dec 2023 12:18:13 +0100, Newbyte wrote:
> Sometimes I want to build an older version of a package from Alpine, and> since package upgrades can involve things like patches and other> externalities just changing the pkgver and running checksum in pmaports> may not be enough. As such, it tends to be easier to revert the change> in the local aports repo and then fork than forking and then trying to> manually revert the changes yourself (since you can't have git do that> for you given that they are distinct repositories).> > [...]
Applied, thanks!
[1/1] aportgen: Only warn if binary version > APKBUILD version
commit: ddc5c59562cce01d14a8509fd0411f6c0f171540
Best regards,
--
Oliver Smith <ollieparanoid@postmarketos.org>