2018-11-10 13:25:53 +00:00
|
|
|
#!/usr/local/bin/dumb-init /bin/bash
|
2020-05-15 13:30:34 +00:00
|
|
|
set -euo pipefail
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2023-02-18 14:57:04 +00:00
|
|
|
: ${TIMEOUT:=0} # allow to restrict runtime of the makepkg build
|
|
|
|
|
2018-11-17 19:14:14 +00:00
|
|
|
MAKEPKG_OPTS=(-cCs --noconfirm --needed)
|
2018-11-17 19:37:29 +00:00
|
|
|
REPOADD_OPTS=()
|
2020-05-15 13:30:34 +00:00
|
|
|
SKIP_VERIFY="${SKIP_VERIFY:-}"
|
|
|
|
|
|
|
|
while getopts ":hRs" opt; do
|
2023-02-18 14:57:04 +00:00
|
|
|
case "${opt}" in
|
|
|
|
R) # Remove older version of package from repo
|
|
|
|
REPOADD_OPTS+=(-R)
|
|
|
|
;;
|
|
|
|
s) # Skip PGP check for source signatures
|
|
|
|
SKIP_VERIFY="true"
|
|
|
|
;;
|
|
|
|
h | *) # Display help
|
|
|
|
echo "Usage:"
|
|
|
|
grep '\s.)\ #' $0
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-05-15 13:30:34 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
SRC=${1:-}
|
2018-11-10 13:25:53 +00:00
|
|
|
|
|
|
|
# Override WORKDIR
|
|
|
|
cd /src
|
|
|
|
|
|
|
|
if [ ! -e PKGBUILD ]; then
|
2023-02-18 14:57:04 +00:00
|
|
|
if [ -z "${SRC}" ]; then
|
|
|
|
echo "No /src/PKGBUILD was found and no repo to clone was given as parameter"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2023-02-18 14:57:04 +00:00
|
|
|
# Ensure permissions on src
|
|
|
|
chown -R builder /src
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2023-02-18 14:57:04 +00:00
|
|
|
gosu builder git clone "${SRC}" /src/git
|
|
|
|
cd /src/git
|
2018-11-10 13:25:53 +00:00
|
|
|
fi
|
|
|
|
|
2020-02-05 13:25:37 +00:00
|
|
|
[[ ${SKIP_VERIFY:-} == true ]] && {
|
2023-02-18 14:57:04 +00:00
|
|
|
MAKEPKG_OPTS+=(--skippgpcheck)
|
2020-02-05 13:25:37 +00:00
|
|
|
}
|
|
|
|
|
2018-11-17 19:14:14 +00:00
|
|
|
[ -e /config/signing.asc ] && {
|
2023-02-18 14:57:04 +00:00
|
|
|
gosu builder gpg --import </config/signing.asc
|
|
|
|
MAKEPKG_OPTS+=(--sign)
|
|
|
|
REPOADD_OPTS+=(--sign)
|
2018-11-17 19:14:14 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 12:45:13 +00:00
|
|
|
if [ -e /config/pacman.conf ]; then
|
2023-02-18 14:57:04 +00:00
|
|
|
# Allow full overwrite of pacman.conf
|
|
|
|
cp /config/pacman.conf /etc/pacman.conf
|
2020-05-18 12:45:13 +00:00
|
|
|
elif [ -e /config/pacman.conf.partial ]; then
|
2023-02-18 14:57:04 +00:00
|
|
|
# Allow to provide a partial pacman.conf to append
|
|
|
|
cat /config/pacman.conf.partial >>/etc/pacman.conf
|
2020-05-18 12:45:13 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-02 13:04:27 +00:00
|
|
|
# Update pacman index and any updated package
|
|
|
|
pacman -Syyu --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
|
2023-02-18 14:57:04 +00:00
|
|
|
gosu builder timeout ${TIMEOUT} makepkg ${MAKEPKG_OPTS[@]}
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2020-07-15 20:33:44 +00:00
|
|
|
PACKAGE=($(find . -regextype egrep -regex '^.*\.pkg(|\.tar|\.tar\.xz|\.tar\.zst)$'))
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2020-07-15 20:39:27 +00:00
|
|
|
REPODB=$(find /repo -regextype egrep -regex '^.*\.db(\.tar|\.tar\.xz|\.tar.zst)$')
|
2018-11-10 13:25:53 +00:00
|
|
|
if [ -z "${REPODB}" ]; then
|
2023-02-18 14:57:04 +00:00
|
|
|
echo "No database found in /repo, not adding package."
|
|
|
|
echo "The built package is available in ${PACKAGE}"
|
|
|
|
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
|
2023-02-18 14:57:04 +00:00
|
|
|
gosu builder mv ${pkg_file}* /repo
|
2018-11-10 13:25:53 +00:00
|
|
|
|
2023-02-18 14:57:04 +00:00
|
|
|
pushd /repo
|
|
|
|
gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}"
|
|
|
|
popd
|
2019-08-11 12:10:10 +00:00
|
|
|
done
|