~postmarketos/pmbootstrap-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH pmbootstrap] aportgen: Only warn if binary version > APKBUILD version

Details
Message ID
<20231209111813.37756-1-newbyte@postmarketos.org>
DKIM signature
missing
Download raw message
Patch: +5 -8
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

[pmbootstrap/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CXJRS05ZQIKP.2H2O5RFKW9JVG@cirno2>
In-Reply-To
<20231209111813.37756-1-newbyte@postmarketos.org> (view parent)
DKIM signature
missing
Download raw message
pmbootstrap/patches/.build.yml: SUCCESS in 14m9s

[aportgen: Only warn if binary version > APKBUILD version][0] from [Newbyte][1]

[0]: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/47519
[1]: newbyte@postmarketos.org

✓ #1111353 SUCCESS pmbootstrap/patches/.build.yml https://builds.sr.ht/~postmarketos/job/1111353
Details
Message ID
<CXKP3V8LZ5VP.28VL0PVZW6X3N@pm-mail-aerc>
In-Reply-To
<20231209111813.37756-1-newbyte@postmarketos.org> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<170221574128.1697.1880728276800778398.b4-ty@postmarketos.org>
In-Reply-To
<20231209111813.37756-1-newbyte@postmarketos.org> (view parent)
DKIM signature
missing
Download raw message
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>
Reply to thread Export thread (mbox)