Skip to content

pmb.chroot.apk.install: let apk figure out depends

Oliver Smith requested to merge fix-apk-install into master

Fix #2137 (closed), which cause master:asus-me176c:sxmo-de-sway to fail in bpo, and Sxmo failing in the upgrade compat test. Fix #2125 (closed) too.

Getting this merged is kind of urgent in order to unblock these. So I'll merge this in 2-3 days even if there is no review.

However if e.g. @cherrypicker (probably most familiar with this part besides me?), @minlexx, @z3ntu, @craftyguy, @Minecrell or anybody else wants to review it, it would be appreciated. This MR consists of multiple patches, each with a very descriptive commit message. I suggest reading each of them and reviewing them separately to better understand why the code had to be transformed that way and how it's iteratively done. With that being said, after some refactoring patches first, this is the most important patch:

pmb.chroot.apk.install: let apk figure out depends
    
Previously to this patch, pmbootstrap would pass a full dependency tree
to "apk add". It would use a virtual package to ensure only the right
packages get added to /etc/apk/world. For example:
  apk add -u --virtual .pmbootstrap postmarketos-base device-asus-me176c \
  postmarketos-ui-sxmo-de-sway device-asus-me176c-nonfree-firmware w3m \
  sfeed clickclack firefox-esr font-noto font-noto-emoji gnome-icon-theme \
  imv megapixels mobile-config-firefox ttyescape postmarketos-base-nofde \
  eudev openssh postmarketos-mkinitfs postmarketos-mvcfg postmarketos-keys \
  ...
    
Instead of doing that, only pass the packages we want to install and let
apk figure out the dependencies. Most of the time we can even avoid
using the virtual package now.
    
== Remaining edge case: locally built packages
apk will only upgrade a package with the same pkgver + pkgrel but a
different build date if the full path to an apk file gets passed as
argument. So if the user built a package locally that will be installed,
or one of its dependencies then we still need to use a virtual package
and possibly pass a dependency to apk. Replace
replace_aports_packages_with_path() with packages_get_locally_built_apks()
to get a list of such packages and adjust install() and
install_run_apk() to use it.

I've also tweaked the log while at it:

pmb.chroot.apk.install: fix empty install messages

Previously pmbootstrap would only show the packages that are about to be
installed. In case all packages were already installed, this would lead
to weird empty install messages:

  (rootfs_asus-me176c) install

Show all packages that we want to install, even if they are already
installed in the given chroot.

  (rootfs_asus-me176c) install device-asus-me176c

Merge request reports