Skip to content

Rework apk handling and always use apk.static

Caleb Connolly requested to merge caleb/apk-static-and-other-cleanups into master

Ok this is a fairly big one.

I previously implemented what I thought was a fairly straightforward optimisation -- using apk.static to install packages rather than apk via chroot (which might be running through QEMU!). This did indeed make things much faster, but there were some oversights.

The main issue and hurdle to overcome with this is that there are now two possible contexts where apk could be run, either inside the chroot or out. This affects the /etc/apk/repositories file since it contains paths to the local repos, which are either mounted in /mnt/pmbootstrap/packages (in the chroot) or are relative to the workdir on your host.

The approach taken in this MR is to just avoid adding the local repositories to the repositories file and instead use the --repository flag with apk. The only time we add the local repos to the repositories file is when the user starts an interactive shell with pmbootstrap chroot, since they would expect to be able to access packages in the local repos.

This could be further improved down the line by not populating the repositories at all (until we build the final image), this would avoid the dance we do currently of figuring out if the file contents are what we want and rewriting it if not.

Most of this is implemented in commit ("chroot: apk: use apk.static in all cases")

In addition, there's a few minor cleanups, type hints, etc.

Close #2388 (closed) (we don't have a forked apk-tools anymore and this MR removes the related workaround)

Edited by Oliver Smith

Merge request reports

Loading