From fb4a12c46429a3fc6fc6bd9ba9df4c3f26b78df2 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Sun, 28 Aug 2022 03:04:48 +0200 Subject: [PATCH] packages.filter_packages(): optionally check package arch --- packages/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/__init__.py b/packages/__init__.py index 365d505..e464c5e 100644 --- a/packages/__init__.py +++ b/packages/__init__.py @@ -80,6 +80,7 @@ def init_prebuilts(arch: Arch, dir: str = None): def filter_packages( paths: Iterable[str], repo: Optional[dict[str, Pkgbuild]] = None, + arch: Optional[Arch] = None, allow_empty_results=True, use_paths=True, use_names=True, @@ -96,7 +97,12 @@ def filter_packages( comparison.add(pkg.path) if use_names: comparison.add(pkg.name) - if comparison.intersection(paths): + matches = list(comparison.intersection(paths)) + if matches: + assert pkg.arches + if arch and not set([arch, 'any']).intersection(pkg.arches): + logging.warn(f"Pkg {pkg.name} matches query {matches[0]} but isn't available for architecture {arch}: {pkg.arches}") + continue result += [pkg] if not allow_empty_results and not result: @@ -647,7 +653,7 @@ def build_packages_by_paths( assert config.runtime.arch for _arch in set([arch, config.runtime.arch]): init_prebuilts(_arch) - packages = filter_packages(paths, repo=repo, allow_empty_results=False) + packages = filter_packages(paths, arch=arch, repo=repo, allow_empty_results=False) return build_packages( packages, arch,