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
|
|
|
|
|
|
|
# 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-03-06 03:41:56 +00:00
|
|
|
# gnupg 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-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 "$@"
|
|
|
|
|
|
|
|
# Return the permissions
|
|
|
|
chown -R root:root /buildroot
|