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-17 19:37:29 +00:00
|
|
|
REPOADD_OPTS=()
|
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
|
|
|
|
|
2020-02-05 13:25:37 +00:00
|
|
|
[[ ${SKIP_VERIFY:-} == true ]] && {
|
|
|
|
MAKEPKG_OPTS+=(--skippgpcheck)
|
|
|
|
}
|
|
|
|
|
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 19:37:29 +00:00
|
|
|
REPOADD_OPTS+=(--sign)
|
2018-11-17 19:14:14 +00:00
|
|
|
}
|
|
|
|
|
2018-11-17 15:07:08 +00:00
|
|
|
# Update pacman index
|
2020-02-27 23:05:34 +00:00
|
|
|
pacman -Sy --noconfirm
|
2018-11-17 15:07:08 +00:00
|
|
|
|
2019-04-04 16:09:42 +00:00
|
|
|
# Retrieve GPG keys if required
|
|
|
|
gosu builder getkeys.sh
|
|
|
|
|
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
|
|
|
|
2019-08-11 12:10:10 +00:00
|
|
|
PACKAGE=($(ls *.pkg.tar.xz))
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2018-11-17 19:37:29 +00:00
|
|
|
REPODB=$(find /repo -name '*.db.tar.xz')
|
2018-11-10 13:25:53 +00:00
|
|
|
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
|
|
|
|
|
2019-08-11 12:10:10 +00:00
|
|
|
for pkg_file in "${PACKAGE[@]}"; do
|
|
|
|
gosu builder mv ${pkg_file}* /repo
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2019-08-11 12:14:51 +00:00
|
|
|
pushd /repo
|
2019-08-11 12:10:10 +00:00
|
|
|
gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}"
|
2019-08-11 12:14:51 +00:00
|
|
|
popd
|
2019-08-11 12:10:10 +00:00
|
|
|
done
|