Skip to content
Snippets Groups Projects
Unverified Commit 537e51cb authored by Casey's avatar Casey :recycle:
Browse files

chroot: apk: use apk.static in all cases


In 0b4fb911 (chroot: always run apk static v2 (MR 2423)) we adjusted
install_run_apk() to run apk static on the host and pass in the local
binary repo with "--repository". This function can call apk in two ways,
either with the progress bar handling or without, the second case was
never updated and still ran apk inside the chroot incorrectly.

Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
parent dec4fefa
Branches
No related tags found
No related merge requests found
Pipeline #209083 failed
......@@ -160,9 +160,7 @@ def packages_get_locally_built_apks(package_list: list[str], arch: Arch) -> list
for channel in channels:
apk_path = get_context().config.work / "packages" / channel / arch / apk_file
if apk_path.exists():
# FIXME: use /mnt/pmb… until MR 2351 is reverted (pmb#2388)
# local.append(apk_path)
local.append(Path("/mnt/pmbootstrap/packages/") / channel / arch / apk_file)
local.append(apk_path)
break
# Record all the packages we have visited so far
......@@ -245,7 +243,7 @@ def install_run_apk(to_add: list[str], to_add_local: list[Path], to_del: list[st
# Virtual package related commands don't actually install or remove
# packages, but only mark the right ones as explicitly installed.
# They finish up almost instantly, so don't display a progress bar.
pmb.chroot.root(["apk", "--no-progress"] + command, chroot)
pmb.helpers.apk.apk_no_progress(["--no-progress"] + command, chroot)
def install(packages, chroot: Chroot, build=True, quiet: bool = False):
......
......@@ -66,13 +66,10 @@ def _compute_progress(line):
return cur / tot if tot > 0 else 0
def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = None):
"""Run an apk subcommand while printing a progress bar to STDOUT.
:param command: apk subcommand in list form
:raises RuntimeError: when the apk command fails
def _prepare_command(command: Sequence[PathString], chroot: Chroot | None):
"""
Set --root and --arch and process Path objects in the command list.
"""
fifo = _prepare_fifo()
_command: list[str] = [str(get_context().config.work / "apk.static")]
if chroot:
_command.extend(["--root", str(chroot.path), "--arch", str(chroot.arch)])
......@@ -81,6 +78,17 @@ def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = Non
_command.append(str(c))
else:
_command.append(os.fspath(c))
return _command
def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = None):
"""Run an apk subcommand while printing a progress bar to STDOUT.
:param command: apk subcommand in list form
:raises RuntimeError: when the apk command fails
"""
fifo = _prepare_fifo()
_command = _prepare_command(command, chroot)
command_with_progress = _create_command_with_progress(_command, fifo)
log_msg = " ".join(_command)
with pmb.helpers.run.root(["cat", fifo], output="pipe") as p_cat:
......@@ -93,6 +101,16 @@ def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = Non
pmb.helpers.run_core.check_return_code(p_apk.returncode, log_msg)
def apk_no_progress(command: Sequence[PathString], chroot: Chroot | None = None):
"""Run an apk subcommand without printing a progress bar.
:param command: apk subcommand in list form
:raises RuntimeError: when the apk command fails
"""
_command = _prepare_command(command, chroot)
pmb.helpers.run.root(_command)
def check_outdated(version_installed, action_msg):
"""Check if the provided alpine version is outdated.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment