2018-11-10 13:25:53 +00:00
|
|
|
#!/usr/local/bin/dumb-init /bin/bash
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
SRC=${1:-}
|
2018-11-17 19:14:14 +00:00
|
|
|
MAKEPKG_OPTS=(-cCs --noconfirm --needed)
|
2018-11-10 13:25:53 +00:00
|
|
|
|
|
|
|
# Override WORKDIR
|
|
|
|
cd /src
|
|
|
|
|
|
|
|
if [ ! -e PKGBUILD ]; then
|
|
|
|
if [ -z "${SRC}" ]; then
|
|
|
|
echo "No /src/PKGBUILD was found and no repo to clone was given as parameter"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure permissions on src
|
|
|
|
chown -R builder /src
|
|
|
|
|
|
|
|
gosu builder git clone "${SRC}" /src/git
|
|
|
|
cd /src/git
|
|
|
|
fi
|
|
|
|
|
2018-11-17 19:14:14 +00:00
|
|
|
[ -e /config/signing.asc ] && {
|
|
|
|
gosu builder gpg --import </config/signing.asc
|
|
|
|
MAKEPKG_OPTS+=(--sign)
|
|
|
|
}
|
|
|
|
|
2018-11-17 15:07:08 +00:00
|
|
|
# Update pacman index
|
|
|
|
pacman -Sy
|
|
|
|
|
2018-11-10 13:25:53 +00:00
|
|
|
# Execute the build itself
|
2018-11-17 19:14:14 +00:00
|
|
|
gosu builder makepkg ${MAKEPKG_OPTS[@]}
|
2018-11-10 13:25:53 +00:00
|
|
|
|
|
|
|
PACKAGE=$(ls *.pkg.*) # This should be only one file
|
|
|
|
|
|
|
|
REPODB=$(find /repo -name '*.db.*' ! -name '*.old')
|
|
|
|
if [ -z "${REPODB}" ]; then
|
|
|
|
echo "No database found in /repo, not adding package."
|
|
|
|
echo "The built package is available in ${PACKAGE}"
|
2018-11-17 15:11:46 +00:00
|
|
|
exit 0
|
2018-11-10 13:25:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
gosu builder mv "${PACKAGE}" /repo
|
|
|
|
|
|
|
|
cd /repo
|
|
|
|
gosu builder repo-add ${REPODB} "${PACKAGE}"
|