2021-02-26 23:50:00 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-10-06 09:26:25 +00:00
|
|
|
shopt -s nullglob
|
2021-02-26 23:50:00 +00:00
|
|
|
|
2021-10-28 13:48:47 +00:00
|
|
|
cleanup() {
|
|
|
|
chown -R root:root /buildroot
|
|
|
|
}
|
|
|
|
|
2021-02-26 23:50:00 +00:00
|
|
|
# Upgrade
|
2021-03-01 12:43:07 +00:00
|
|
|
pacman -Suy --noconfirm
|
2021-02-26 23:50:00 +00:00
|
|
|
|
2021-10-06 07:57:26 +00:00
|
|
|
# Create a builder user
|
2021-10-06 09:26:25 +00:00
|
|
|
useradd -U builder
|
|
|
|
builder_uid=$(id -u builder)
|
|
|
|
builder_gid=$(id -g builder)
|
2021-10-06 07:57:26 +00:00
|
|
|
|
2021-10-28 13:48:47 +00:00
|
|
|
# dir permissions
|
2021-10-06 09:26:25 +00:00
|
|
|
chown -R "$builder_uid:$builder_gid" /.gnupg /buildroot
|
2021-03-06 03:41:56 +00:00
|
|
|
|
2021-10-28 13:48:47 +00:00
|
|
|
# Return the permissions on exit
|
|
|
|
trap cleanup INT TERM EXIT
|
|
|
|
|
2021-03-06 03:48:58 +00:00
|
|
|
# Add sudo permissions for pacman to install dependencies
|
2021-10-06 09:26:25 +00:00
|
|
|
printf '%s ALL=(ALL) NOPASSWD: /usr/bin/pacman\n' 'builder' > /etc/sudoers.d/builduser
|
2021-03-06 03:48:58 +00:00
|
|
|
|
2021-02-26 23:50:00 +00:00
|
|
|
# Workdir
|
|
|
|
cd /buildroot
|
|
|
|
|
2021-10-06 09:26:25 +00:00
|
|
|
# Install all additional packages
|
|
|
|
deps=( ./deps/* )
|
|
|
|
[[ $deps ]] && pacman -U "${deps[@]}"
|
|
|
|
|
2021-02-26 23:50:00 +00:00
|
|
|
# Build the damn thing
|
2021-10-06 07:57:26 +00:00
|
|
|
sudo -u builder GNUPGHOME="/.gnupg" makepkg "$@"
|
|
|
|
|
|
|
|
chown -R root:root /buildroot
|