pmb.chroot.init_keys: split into own function (MR 2110)
Move code to install Alpine and postmarketOS keys into its own function, so it can be called outside of pmb.chroot.init too (next patch). Describe why this is needed in the first place and, while at it, tweak the function to only copy the key if it does not exist in the target directory.
This commit is contained in:
parent
77d39ecdf1
commit
9b7feadca6
|
@ -57,6 +57,23 @@ def setup_qemu_emulation(args, suffix):
|
|||
create_folders=True)
|
||||
|
||||
|
||||
def init_keys(args):
|
||||
"""
|
||||
All Alpine and postmarketOS repository keys are shipped with pmbootstrap.
|
||||
Copy them into $WORK/config_apk_keys, which gets mounted inside the various
|
||||
chroots as /etc/apk/keys.
|
||||
|
||||
This is done before installing any package, so apk can verify APKINDEX
|
||||
files of binary repositories even though alpine-keys/postmarketos-keys are
|
||||
not installed yet.
|
||||
"""
|
||||
for key in glob.glob(f"{pmb.config.apk_keys_path}/*.pub"):
|
||||
target = f"{args.work}/config_apk_keys/{os.path.basename(key)}"
|
||||
if not os.path.exists(target):
|
||||
# Copy as root, so the resulting files in chroots are owned by root
|
||||
pmb.helpers.run.root(args, ["cp", key, target])
|
||||
|
||||
|
||||
def init(args, suffix="native"):
|
||||
# When already initialized: just prepare the chroot
|
||||
chroot = f"{args.work}/chroot_{suffix}"
|
||||
|
@ -82,9 +99,7 @@ def init(args, suffix="native"):
|
|||
f"{chroot}/etc/apk/cache"])
|
||||
|
||||
# Initialize /etc/apk/keys/, resolv.conf, repositories
|
||||
for key in glob.glob(f"{pmb.config.apk_keys_path}/*.pub"):
|
||||
pmb.helpers.run.root(args, ["cp", key, f"{args.work}"
|
||||
"/config_apk_keys/"])
|
||||
init_keys(args)
|
||||
copy_resolv_conf(args, suffix)
|
||||
pmb.chroot.apk.update_repository_list(args, suffix)
|
||||
|
||||
|
|
Loading…
Reference in New Issue