From c9674c44556c7443ea40a7e230be5544b71a5a8f Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Thu, 3 Jul 2025 21:19:10 +0200 Subject: [PATCH] Fix crash in "zap -a" and "zap -o" with apk3 With apkv3, APKINDEX files get deleted when running "apk cache clean". This is unexpected and needs to be investigated. Meanwhile run cache_clean() on the native arch last, as it needs the APKINDEX for the Alpine main repo of the native arch (even if cleaning other arches) in order to set up the chroot where we run "apk cache clean". This prevents crashing in "pmbootstrap zap -a" and "pmbootstrap zap -o". Related: BPO issue 160 Related: pmb issue 2627 Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2636 --- pmb/chroot/zap.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pmb/chroot/zap.py b/pmb/chroot/zap.py index 99aca32a..70cced0e 100644 --- a/pmb/chroot/zap.py +++ b/pmb/chroot/zap.py @@ -182,8 +182,21 @@ def zap_pkgs_online_mismatch(confirm: bool = True, dry: bool = False) -> None: return # Iterate over existing apk caches + clean_native = False for path in paths: arch = Arch.from_str(path.name.split("_", 2)[2]) if not dry: + if arch == Arch.native(): + clean_native = True + continue pmb.helpers.apk.cache_clean(arch) + + # pmb#2672: With apkv3, APKINDEX files get deleted when running "apk cache + # clean". This is unexpected and needs to be investigated. Meanwhile run + # cache_clean() on the native arch last, as it needs the APKINDEX for the + # Alpine main repo of the native arch (even if cleaning other arches) in + # order to set up the chroot where we run "apk cache clean". This prevents + # crashing in "pmbootstrap zap -a" and "pmbootstrap zap -o". + if clean_native and not dry: + pmb.helpers.apk.cache_clean(Arch.native())