chroot: apk: fix installing local packages (MR 2252)

This got broken during rework. Fix it up, make sure we filter out
packages from to_add that are specified in to_add_local.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-14 04:19:27 +02:00 committed by Oliver Smith
parent fc950100ba
commit c89b53a87e
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -6,7 +6,7 @@ import pmb.chroot.apk_static
from pmb.core.arch import Arch from pmb.core.arch import Arch
from pmb.helpers import logging from pmb.helpers import logging
import shlex import shlex
from typing import List, Sequence from typing import List, Sequence, Tuple
import pmb.build import pmb.build
import pmb.chroot import pmb.chroot
@ -112,7 +112,7 @@ def packages_split_to_add_del(packages):
return (to_add, to_del) return (to_add, to_del)
def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]: def packages_get_locally_built_apks(packages, arch: Arch) -> Tuple[List[str], List[Path]]:
""" """
Iterate over packages and if existing, get paths to locally built packages. Iterate over packages and if existing, get paths to locally built packages.
This is used to force apk to upgrade packages to newer local versions, even This is used to force apk to upgrade packages to newer local versions, even
@ -120,25 +120,29 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
:param packages: list of pkgnames :param packages: list of pkgnames
:param arch: architecture that the locally built packages should have :param arch: architecture that the locally built packages should have
:returns: list of apk file paths that are valid inside the chroots, e.g. :returns: Pair of lists, the first is the input packages with local apks removed.
the second is a list of apk file paths that are valid inside the chroots, e.g.
["/mnt/pmbootstrap/packages/x86_64/hello-world-1-r6.apk", ...] ["/mnt/pmbootstrap/packages/x86_64/hello-world-1-r6.apk", ...]
""" """
channel: str = pmb.config.pmaports.read_config()["channel"] channel: str = pmb.config.pmaports.read_config()["channel"]
ret: List[Path] = [] local: List[Path] = []
to_add = []
for package in packages: for package in packages:
data_repo = pmb.parse.apkindex.package(package, arch, False) data_repo = pmb.parse.apkindex.package(package, arch, False)
if not data_repo: if not data_repo:
to_add.append(package)
continue continue
apk_file = f"{package}-{data_repo['version']}.apk" apk_file = f"{package}-{data_repo['version']}.apk"
apk_path = get_context().config.work / "packages" / channel / arch / apk_file apk_path = get_context().config.work / "packages" / channel / arch / apk_file
if not apk_path.exists(): if not apk_path.exists():
to_add.append(package)
continue continue
ret.append(apk_path) local.append(apk_path)
return ret return to_add, local
# FIXME: List[Sequence[PathString]] weirdness # FIXME: List[Sequence[PathString]] weirdness
@ -244,10 +248,10 @@ def install(packages, chroot: Chroot, build=True):
if build and context.config.build_pkgs_on_install: if build and context.config.build_pkgs_on_install:
pmb.build.packages(context, to_add, arch) pmb.build.packages(context, to_add, arch)
to_add_local = packages_get_locally_built_apks(to_add, arch) to_add, to_add_local = packages_get_locally_built_apks(to_add, arch)
logging.info(f"({chroot}) install {' '.join(packages)}") logging.info(f"({chroot}) install {' '.join(packages)}")
install_run_apk(packages, to_add_local, to_del, chroot) install_run_apk(to_add, to_add_local, to_del, chroot)
def installed(suffix: Chroot=Chroot.native()): def installed(suffix: Chroot=Chroot.native()):