pmb.chroot: merge_usr earlier (MR 2252)

We currently do stuff in the chroot before merging /usr, this could lead
to weird side effects due to the recursive nature of chroot.init being
called every time we run a command. Let's reorder a bit to reduce the
risk of weirdness here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-23 02:07:31 +02:00 committed by Oliver Smith
parent 2d232200f8
commit 3322eab30c
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -166,6 +166,12 @@ def init(args: PmbArgs, chroot: Chroot=Chroot.native(), usr_merge=UsrMerge.AUTO,
"--initdb", "--arch", arch,
"add", "alpine-base"])
# Merge /usr
if usr_merge is UsrMerge.AUTO and pmb.config.is_systemd_selected(args):
usr_merge = UsrMerge.ON
if usr_merge is UsrMerge.ON:
init_usr_merge(args, chroot)
# Building chroots: create "pmos" user, add symlinks to /home/pmos
if not chroot.type == ChrootType.ROOTFS:
pmb.chroot.root(args, ["adduser", "-D", "pmos", "-u",
@ -182,12 +188,6 @@ def init(args: PmbArgs, chroot: Chroot=Chroot.native(), usr_merge=UsrMerge.AUTO,
pmb.chroot.user(args, ["ln", "-s", target, link_name], chroot)
pmb.chroot.root(args, ["chown", "pmos:pmos", target], chroot)
# Merge /usr
if usr_merge is UsrMerge.AUTO and pmb.config.is_systemd_selected(args):
usr_merge = UsrMerge.ON
if usr_merge is UsrMerge.ON:
init_usr_merge(args, chroot)
# Upgrade packages in the chroot, in case alpine-base, apk, etc. have been
# built from source with pmbootstrap
command = ["--no-network", "upgrade", "-a"]