images/archlinux: run chroot in new PID namespace

gpg-agent remains after exit, and causes umount to fail.

Mirrors what was done in arch-chroot:
2be79c6259
This commit is contained in:
Simon Ser 2024-03-16 16:52:15 +01:00
parent 2b0d4e25cb
commit 9668eb0856
1 changed files with 4 additions and 2 deletions

View File

@ -34,12 +34,14 @@ pacstrap -G root base base-devel git mercurial openssh mkinitcpio linux syslinux
run_root() {
local cmd="$@"
chroot $root /bin/bash -c "$cmd"
# Run in a PID namespace to tear down processes remaining in the chroot on
# exit (e.g. gpg-agent)
unshare --fork --pid chroot $root /bin/bash -c "$cmd"
}
run_normal() {
local cmd="$@"
chroot $root sudo -u build -g build \
unshare --fork --pid chroot $root sudo -u build -g build \
/bin/bash -c "cd /home/build && $cmd"
}