pmb.build.package: fix strict mode

In strict mode, pmbootstrap uninstalls packages between builds. This was
broken since we switched from installing dependencies via abuild to
pmbootstrap since our code doesn't use "--virtual .makedepends-…" when
installing the makedepends:

  (088776) [15:32:34] (native) % cd /home/pmos/build; busybox su pmos -c SUDO_APK='abuild-apk --no-progress' HOME=/home/pmos abuild undeps ;
  ERROR: No such package: .makedepends-systemd-stage0

Instead of restoring the logic and worrying about uninstalling deps in
the right chroots, just zap all chroots in strict mode.

I've also considered implementing "--virtual .makedepends-…" again, but
running zap on the chroots makes the logic much simpler, is easier to
maintain and makes so little speed difference that it is worth the
trade-off. We don't need to pass additional parameters fore the 2nd
chroot to zap in cross-native2, no need to figure out the virtual
package name in two places, etc.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2587
This commit is contained in:
Oliver Smith 2025-04-05 18:57:18 +02:00 committed by Stefan Hansson
parent fda8963ed7
commit b982e45c8d
No known key found for this signature in database
GPG key ID: ACD854892B38D898

View file

@ -143,24 +143,22 @@ def finish(
# package we need to parse it again)
pmb.parse.apkindex.clear_cache(out_dir / arch / "APKINDEX.tar.gz")
# Uninstall build dependencies (strict mode)
if strict or "pmb:strict" in apkbuild["options"]:
logging.info(f"({chroot}) uninstall build dependencies")
pmb.chroot.user(
["abuild", "undeps"],
chroot,
Path("/home/pmos/build"),
env={"SUDO_APK": "abuild-apk --no-progress"},
)
# If the build depends contain postmarketos-keys or postmarketos-base,
# abuild will have removed the postmarketOS repository key (pma#1230)
pmb.chroot.init_keys()
# Zap chroots (strict mode)
zap_reason = None
if "pmb:strict" in apkbuild["options"]:
zap_reason = "pmb:strict in APKBUILD"
elif strict:
zap_reason = "running with --strict"
if zap_reason:
logging.info(f"({chroot}) zapping chroots ({zap_reason})")
pmb.chroot.zap(False)
logging.info(f"@YELLOW@=>@END@ @BLUE@{channel}/{apkbuild['pkgname']}@END@: Done!")
# If we just built a package which is used to build other packages, then
# update the buildroot to use the newly built version.
if apkbuild["pkgname"] in pmb.config.build_packages:
if not zap_reason and apkbuild["pkgname"] in pmb.config.build_packages:
logging.info(
f"NOTE: Updating package {apkbuild['pkgname']} in buildroot since it's"
" used for building..."