pmb.chroot.init: add postmarketos_mirror argument (MR 2273)

Add this argument, so we can disable the pmOS repository during
"pmbootstrap repo_bootstrap" for the chroot we build in.

If building natively, it will be disabled in the "native" chroot.

If building for a foreign arch, it will be disabled in the
"buildroot_$arch" chroot, but still be enabled in the native chroot so
we have the cross compilers available.

The name of the argument is a bit long, but it is consistent with the
argument of the same name in pmb.helpers.repo.urls() (to which it gets
passed).
This commit is contained in:
Oliver Smith 2024-02-25 13:26:18 +01:00
parent 6f3ed45d49
commit 9126d15452
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 10 additions and 6 deletions

View file

@ -92,7 +92,8 @@ def init_usr_merge(args, suffix):
f"{args.work}/chroot_{suffix}"])
def init(args, suffix="native", usr_merge=UsrMerge.AUTO):
def init(args, suffix="native", usr_merge=UsrMerge.AUTO,
postmarketos_mirror=True):
"""
Initialize a chroot by copying the resolv.conf and updating
/etc/apk/repositories. If /bin/sh is missing, create the chroot from
@ -101,6 +102,7 @@ def init(args, suffix="native", usr_merge=UsrMerge.AUTO):
:param usr_merge: set to ON to force having a merged /usr. With AUTO it is
only done if the user chose to install systemd in
pmbootstrap init.
:param postmarketos_mirror: add postmarketos mirror URLs
"""
# When already initialized: just prepare the chroot
chroot = f"{args.work}/chroot_{suffix}"
@ -112,7 +114,7 @@ def init(args, suffix="native", usr_merge=UsrMerge.AUTO):
if os.path.islink(f"{chroot}/bin/sh"):
pmb.config.workdir.chroot_check_channel(args, suffix)
copy_resolv_conf(args, suffix)
pmb.chroot.apk.update_repository_list(args, suffix)
pmb.chroot.apk.update_repository_list(args, suffix, postmarketos_mirror)
return
# Require apk-tools-static
@ -128,7 +130,7 @@ def init(args, suffix="native", usr_merge=UsrMerge.AUTO):
# Initialize /etc/apk/keys/, resolv.conf, repositories
init_keys(args)
copy_resolv_conf(args, suffix)
pmb.chroot.apk.update_repository_list(args, suffix)
pmb.chroot.apk.update_repository_list(args, suffix, postmarketos_mirror)
pmb.config.workdir.chroot_save_init(args, suffix)