From 8b8f25227feec77a9a13034b15b0301e9626ff53 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 29 Nov 2023 21:36:02 +0100 Subject: [PATCH] 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". Reviewed-by: Caleb Connolly (via chat) --- pmb/helpers/package.py | 8 ++++++++ pmb/helpers/pmaports.py | 1 + pmb/parse/apkindex.py | 6 ++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pmb/helpers/package.py b/pmb/helpers/package.py index db648a6b..f3541086 100644 --- a/pmb/helpers/package.py +++ b/pmb/helpers/package.py @@ -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. diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py index 510ec4d0..7cf02eba 100644 --- a/pmb/helpers/pmaports.py +++ b/pmb/helpers/pmaports.py @@ -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: diff --git a/pmb/parse/apkindex.py b/pmb/parse/apkindex.py index 4d23f9c8..3828c268 100644 --- a/pmb/parse/apkindex.py +++ b/pmb/parse/apkindex.py @@ -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: