36 lines
724 B
Bash
Executable File
36 lines
724 B
Bash
Executable File
#!/usr/bin/env bash
|
|
shopt -s nullglob
|
|
|
|
cleanup() {
|
|
chown -R root:root /buildroot
|
|
}
|
|
|
|
# Upgrade
|
|
pacman -Suy --noconfirm
|
|
|
|
# Create a builder user
|
|
useradd -U builder
|
|
builder_uid=$(id -u builder)
|
|
builder_gid=$(id -g builder)
|
|
|
|
# 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
|
|
|
|
# Workdir
|
|
cd /buildroot
|
|
|
|
# Install all additional packages
|
|
deps=( ./deps/* )
|
|
[[ $deps ]] && pacman -U "${deps[@]}"
|
|
|
|
# Build the damn thing
|
|
sudo -u builder GNUPGHOME="/.gnupg" makepkg "$@"
|
|
|
|
chown -R root:root /buildroot/
|