Files
builder/autobuilder/build
T

36 lines
723 B
Python
Raw Normal View History

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