aportgen: Only warn if binary version > APKBUILD version

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.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20231209111813.37756-1-newbyte@postmarketos.org%3E
This commit is contained in:
Newbyte 2023-12-09 12:18:13 +01:00 committed by Oliver Smith
parent 38ae6120bb
commit ddc5c59562
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 5 additions and 8 deletions

View file

@ -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

View file

@ -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"}