mirror of
https://github.com/luzifer-docker/arch-repo-builder.git
synced 2024-10-18 06:44:20 +00:00
58 lines
1.1 KiB
Bash
Executable file
58 lines
1.1 KiB
Bash
Executable file
#!/usr/local/bin/dumb-init /bin/bash
|
|
set -euxo pipefail
|
|
|
|
SRC=${1:-}
|
|
MAKEPKG_OPTS=(-cCs --noconfirm --needed)
|
|
REPOADD_OPTS=()
|
|
|
|
# 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
|
|
|
|
[[ ${SKIP_VERIFY:-} == true ]] && {
|
|
MAKEPKG_OPTS+=(--skippgpcheck)
|
|
}
|
|
|
|
[ -e /config/signing.asc ] && {
|
|
gosu builder gpg --import </config/signing.asc
|
|
MAKEPKG_OPTS+=(--sign)
|
|
REPOADD_OPTS+=(--sign)
|
|
}
|
|
|
|
# Update pacman index
|
|
pacman -Sy --noconfirm
|
|
|
|
# Retrieve GPG keys if required
|
|
gosu builder getkeys.sh
|
|
|
|
# Execute the build itself
|
|
gosu builder makepkg ${MAKEPKG_OPTS[@]}
|
|
|
|
PACKAGE=($(ls *.pkg.tar.xz))
|
|
|
|
REPODB=$(find /repo -name '*.db.tar.xz')
|
|
if [ -z "${REPODB}" ]; then
|
|
echo "No database found in /repo, not adding package."
|
|
echo "The built package is available in ${PACKAGE}"
|
|
exit 0
|
|
fi
|
|
|
|
for pkg_file in "${PACKAGE[@]}"; do
|
|
gosu builder mv ${pkg_file}* /repo
|
|
|
|
pushd /repo
|
|
gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}"
|
|
popd
|
|
done
|