arch-repo-builder/run.sh
Knut Ahlers 5d7082b7f3
Update package database before building
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-11-17 16:07:08 +01:00

39 lines
802 B
Bash
Executable file

#!/usr/local/bin/dumb-init /bin/bash
set -euxo pipefail
SRC=${1:-}
# 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
# Update pacman index
pacman -Sy
# Execute the build itself
gosu builder makepkg -cCs --noconfirm --needed
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}"
fi
gosu builder mv "${PACKAGE}" /repo
cd /repo
gosu builder repo-add ${REPODB} "${PACKAGE}"