Browse Source

do this with a trap

Signed-off-by: fbt <fbt@fleshless.org>
master
Jack L. Frost 7 months ago
parent
commit
99bba5c866
  1. 10
      autobuilder/build

10
autobuilder/build

@ -1,6 +1,10 @@
#!/usr/bin/env bash
shopt -s nullglob
cleanup() {
chown -R root:root /buildroot
}
# Upgrade
pacman -Suy --noconfirm
@ -9,9 +13,12 @@ useradd -U builder
builder_uid=$(id -u builder)
builder_gid=$(id -g builder)
# gnupg dir permissions
# dir permissions
chown -R "$builder_uid:$builder_gid" /.gnupg /buildroot
# Return the permissions on exit
trap cleanup INT TERM EXIT
# Add sudo permissions for pacman to install dependencies
printf '%s ALL=(ALL) NOPASSWD: /usr/bin/pacman\n' 'builder' > /etc/sudoers.d/builduser
@ -25,5 +32,4 @@ deps=( ./deps/* )
# Build the damn thing
sudo -u builder GNUPGHOME="/.gnupg" makepkg "$@"
# Return the permissions
chown -R root:root /buildroot

Loading…
Cancel
Save