1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00

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
This commit is contained in:
Oliver Smith 2025-07-03 21:19:10 +02:00
parent 3d764546c1
commit c9674c4455
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -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())