Skip to content
Snippets Groups Projects

Rework apk handling and always use apk.static

Merged Casey requested to merge caleb/apk-static-and-other-cleanups into master
All threads resolved!

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

Merge request pipeline #209485 failed

Merge request pipeline failed for 500b0908

Approved by

Merged by CaseyCasey 5 months ago (Nov 2, 2024 5:18pm UTC)

Merge details

Pipeline #209486 failed

Pipeline failed for 500b0908 on master

Deployed to dep‎loy‎ 5 months ago

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Oliver Smith
  • LGTM besides the open threads. Great work, this is elegantly abstracted now! I like that we don't need to pass --arch anymore, it is implicit from the chroot! :tada:

  • Oliver Smith approved this merge request

    approved this merge request

  • Newbyte
  • Newbyte mentioned in merge request !2469 (merged)

    mentioned in merge request !2469 (merged)

  • Casey resolved all threads

    resolved all threads

  • Casey added 37 commits

    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

    Compare with previous version

  • Casey added 10 commits

    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)

    Compare with previous version

  • Casey enabled an automatic merge when all merge checks for 71d275e5 pass

    enabled an automatic merge when all merge checks for 71d275e5 pass

  • Casey aborted the automatic merge because the source branch was updated. Learn more.

    aborted the automatic merge because the source branch was updated. Learn more.

  • Casey added 10 commits

    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

    Compare with previous version

  • Casey added 10 commits

    added 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)

    Compare with previous version

  • Casey enabled an automatic merge when all merge checks for 500b0908 pass

    enabled an automatic merge when all merge checks for 500b0908 pass

  • Casey canceled the automatic merge

    canceled the automatic merge

  • merged

  • Please register or sign in to reply
    Loading