diff --git a/autobuilder/build b/autobuilder/build index 46d59d7..c3112e8 100755 --- a/autobuilder/build +++ b/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