~postmarketos/pmbootstrap

d9322fe11aa59a5756e019fa27cbf89ef5f99de2 — Oliver Smith 9 months ago 1e3c9fc fix-pkgname-split
pmb.helpers.pmaports.get: deal with operators

Fix that APKBUILDs mentioning other packages with an operator could not
be found. As we are building the initial branch of v23.12, this
currently happens with postmarketos-mkinitfs: it depends on
devicepkg-utils>=0.2.0 and currently pmbootstrap will only remove the
>=0.2.0 when looking for the pkgname in the APKINDEX of binary packages
(which is why it works on master). But it does not yet do that when
looking for the pkgname in pmaports.

Move the code for stripping the operator to a common place and use it
for getting packages from pmaports too.

Change the order of operators while at it, try to find <= before =, as
otherwise it would cut off example<=1.2.3 as "example<" instead of
"example".
3 files changed, 11 insertions(+), 4 deletions(-)

M pmb/helpers/package.py
M pmb/helpers/pmaports.py
M pmb/parse/apkindex.py
M pmb/helpers/package.py => pmb/helpers/package.py +8 -0
@@ 12,6 12,14 @@ import pmb.helpers.pmaports
import pmb.helpers.repo


def remove_operators(package):
    for operator in [">", ">=", "<=", "=", "<", "~"]:
        if operator in package:
            package = package.split(operator)[0]
            break
    return package


def get(args, pkgname, arch, replace_subpkgnames=False, must_exist=True):
    """ Find a package in pmaports, and as fallback in the APKINDEXes of the
        binary packages.

M pmb/helpers/pmaports.py => pmb/helpers/pmaports.py +1 -0
@@ 204,6 204,7 @@ def get(args, pkgname, must_exist=True, subpackages=True):
                    "options": [],
                    ... }
    """
    pkgname = pmb.helpers.package.remove_operators(pkgname)
    if subpackages:
        aport = find(args, pkgname, must_exist)
        if aport:

M pmb/parse/apkindex.py => pmb/parse/apkindex.py +2 -4
@@ 5,6 5,7 @@ import logging
import os
import tarfile
import pmb.chroot.apk
import pmb.helpers.package
import pmb.helpers.repo
import pmb.parse.version



@@ 283,10 284,7 @@ def providers(args, package, arch=None, must_exist=True, indexes=None):
        arch = arch or pmb.config.arch_native
        indexes = pmb.helpers.repo.apkindex_files(args, arch)

    for operator in [">", ">=", "=", "<=", "<", "~"]:
        if operator in package:
            package = package.split(operator)[0]
            break
    package = pmb.helpers.package.remove_operators(package)

    ret = collections.OrderedDict()
    for path in indexes: