config: add auto_zap_misconfigured_chroots (MR 2252)

This option will make pmbootstrap automatically zap chroots that are
initialized for the wrong channel, making it much faster to switch
between edge and systemd.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-13 22:48:43 +02:00 committed by Oliver Smith
parent af826c671d
commit c1aa5acdaa
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 49 additions and 9 deletions

View file

@ -114,10 +114,17 @@ def init(chroot: Chroot, usr_merge=UsrMerge.AUTO):
config = get_context().config
# If the channel is wrong and the user has auto_zap_misconfigured_chroots
# enabled, zap the chroot and reinitialize it
if chroot.exists():
zap = pmb.config.workdir.chroot_check_channel(chroot)
if zap:
pmb.chroot.del_chroot(chroot.path, confirm=False)
pmb.config.workdir.clean()
pmb.chroot.mount(chroot)
mark_in_chroot(chroot)
if chroot.exists():
pmb.config.workdir.chroot_check_channel(chroot)
copy_resolv_conf(chroot)
pmb.chroot.apk.update_repository_list(chroot)
warn_if_chroot_is_outdated(chroot)