chroot: always run apk static (MR 2252)

Testing by building postmarketos-initramfs (which installs >100 packages
but is very fast to build, so a worst-case scenario) this results in a
~15-20% speedup (which everything cached and doing multiple back to back
runs). From 32 seconds down to 25.

Doing a full install with --no-image, this takes us from 70 seconds on
my laptop down to 40s!

This also lets us drastically simplify pmb/helpers/apk.py!

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-24 04:45:36 +02:00 committed by Oliver Smith
parent cf651e56d5
commit b82c4eb167
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 41 additions and 43 deletions

View file

@ -160,10 +160,16 @@ def init(args: PmbArgs, chroot: Chroot=Chroot.native(), usr_merge=UsrMerge.AUTO,
# Install alpine-base
pmb.helpers.repo.update(args, arch)
pkgs = ["alpine-base"]
# install apk static in the native chroot so we can run it
# we have a forked apk for systemd and this is the easiest
# way to install/run it.
if chroot.type == ChrootType.NATIVE:
pkgs += ["apk-tools-static"]
pmb.chroot.apk_static.run(args, ["--root", chroot.path,
"--cache-dir", apk_cache,
"--initdb", "--arch", arch,
"add", "alpine-base"])
"add"] + pkgs)
# Merge /usr
if usr_merge is UsrMerge.AUTO and pmb.config.is_systemd_selected(args):