Rework apk handling and always use apk.static
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)
Merge request reports
Activity
requested review from @ollieparanoid
added 10 commits
- 99846d52 - types: add Arch to PathString
- ec8b8c9e - config: export workdir modules
- 2efc75c9 - commands: repo_bootstrap: type hint run_steps()
- e16bad26 - helpers: logging: reduce the risk of a cyclical import
- 825f4a76 - helpers: apk: move update_repository_list() from chroot.apk
- 4aeb0a67 - chroot: apk: use apk.static in all cases
- b2fa7d1a - chroot: apk_static: remove dead run() function
- e5f75e76 - helpers: apk_static: move from pmb.chroot
- 57a0ae28 - commands: remove deviceinfo_parse
- 364d5312 - helpers: apk: sanity check final command
Toggle commit listadded 10 commits
- 99846d52 - types: add Arch to PathString
- ec8b8c9e - config: export workdir modules
- 2efc75c9 - commands: repo_bootstrap: type hint run_steps()
- e16bad26 - helpers: logging: reduce the risk of a cyclical import
- 825f4a76 - helpers: apk: move update_repository_list() from chroot.apk
- 4aeb0a67 - chroot: apk: use apk.static in all cases
- b2fa7d1a - chroot: apk_static: remove dead run() function
- e5f75e76 - helpers: apk_static: move from pmb.chroot
- 57a0ae28 - commands: remove deviceinfo_parse
- 364d5312 - helpers: apk: sanity check final command
Toggle commit list- Resolved by Casey
Does this work with pre- and post-install scripts for foreign arches? I guess if it didn't work, then this would have failed earlier already (given that we already use apk.static most of the time) but just to make sure.
Edited by Oliver Smith
- Resolved by Casey
- Resolved by Casey
- Resolved by Casey
mentioned in merge request !2469 (merged)
added 37 commits
-
364d5312...b524d6da - 27 commits from branch
master
- 9eb2a438 - config: export workdir modules
- c2ebef65 - commands: repo_bootstrap: type hint run_steps()
- 9a32f706 - helpers: logging: reduce the risk of a cyclical import
- b242f5ff - helpers: apk: move update_repository_list() from chroot.apk
- b9925f87 - chroot: apk: use apk.static in all cases
- ec8f93c0 - chroot: apk_static: remove dead run() function
- 2feb4022 - helpers: apk_static: move from pmb.chroot
- b4cf1c0e - commands: remove deviceinfo_parse
- c957a581 - helpers: apk: sanity check final command
- 2ac10ccd - helpers: run: stop handling Arch in PathString
Toggle commit list-
364d5312...b524d6da - 27 commits from branch
added 10 commits
- 6d362d47 - config: export workdir modules (MR 2463)
- 3c39cc36 - commands: repo_bootstrap: type hint run_steps() (MR 2463)
- a4db06d9 - helpers: logging: reduce the risk of a cyclical import (MR 2463)
- 46eda50c - helpers: apk: move update_repository_list() from chroot.apk (MR 2463)
- 7ab8b69b - chroot: apk: use apk.static in all cases (MR 2463)
- fd3943a4 - chroot: apk_static: remove dead run() function (MR 2463)
- 12b05b00 - helpers: apk_static: move from pmb.chroot (MR 2463)
- da7165ce - commands: remove deviceinfo_parse (MR 2463)
- 3571d453 - helpers: apk: sanity check final command (MR 2463)
- 71d275e5 - helpers: run: stop handling Arch in PathString (MR 2463)
Toggle commit listenabled an automatic merge when all merge checks for 71d275e5 pass
aborted the automatic merge because the source branch was updated. Learn more.
added 10 commits
- 9eb2a438 - config: export workdir modules
- 624be6f8 - commands: repo_bootstrap: type hint
- 31ce278f - helpers: logging: reduce the risk of a cyclical import
- ff2fbe57 - helpers: apk: move update_repository_list() from chroot.apk
- 349dd7d8 - chroot: apk: use apk.static in all cases
- 2a0694d4 - chroot: apk_static: remove dead run() function
- 43490489 - helpers: apk_static: move from pmb.chroot
- d61e3812 - commands: remove deviceinfo_parse
- f47b71cd - helpers: apk: sanity check final command
- e42a0789 - helpers: run: stop handling Arch in PathString
Toggle commit listadded 10 commits
- 8b880b71 - config: export workdir modules (MR 2463)
- 2f39edd5 - commands: repo_bootstrap: type hint (MR 2463)
- af1bf538 - helpers: logging: reduce the risk of a cyclical import (MR 2463)
- 12846f3b - helpers: apk: move update_repository_list() from chroot.apk (MR 2463)
- 42158637 - chroot: apk: use apk.static in all cases (MR 2463)
- c4a92c37 - chroot: apk_static: remove dead run() function (MR 2463)
- 26ec1631 - helpers: apk_static: move from pmb.chroot (MR 2463)
- 78474880 - commands: remove deviceinfo_parse (MR 2463)
- 41c8413f - helpers: apk: sanity check final command (MR 2463)
- 500b0908 - helpers: run: stop handling Arch in PathString (MR 2463)
Toggle commit listenabled an automatic merge when all merge checks for 500b0908 pass