From 2daa9d20f4615a95905e73a09aeeeab7d635b017 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 18 Feb 2023 15:57:04 +0100 Subject: [PATCH] Add timeout for makepkg Signed-off-by: Knut Ahlers --- run.sh | 76 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/run.sh b/run.sh index cb86911..8f8d13c 100755 --- a/run.sh +++ b/run.sh @@ -1,24 +1,26 @@ #!/usr/local/bin/dumb-init /bin/bash set -euo pipefail +: ${TIMEOUT:=0} # allow to restrict runtime of the makepkg build + MAKEPKG_OPTS=(-cCs --noconfirm --needed) REPOADD_OPTS=() SKIP_VERIFY="${SKIP_VERIFY:-}" while getopts ":hRs" opt; do - 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 + 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 done SRC=${1:-} @@ -27,34 +29,34 @@ SRC=${1:-} 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 + 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 + # Ensure permissions on src + chown -R builder /src - gosu builder git clone "${SRC}" /src/git - cd /src/git + gosu builder git clone "${SRC}" /src/git + cd /src/git fi [[ ${SKIP_VERIFY:-} == true ]] && { - MAKEPKG_OPTS+=(--skippgpcheck) + MAKEPKG_OPTS+=(--skippgpcheck) } [ -e /config/signing.asc ] && { - gosu builder gpg --import >/etc/pacman.conf + # Allow to provide a partial pacman.conf to append + cat /config/pacman.conf.partial >>/etc/pacman.conf fi # Update pacman index and any updated package @@ -64,21 +66,21 @@ pacman -Syyu --noconfirm gosu builder getkeys.sh # Execute the build itself -gosu builder makepkg ${MAKEPKG_OPTS[@]} +gosu builder timeout ${TIMEOUT} makepkg ${MAKEPKG_OPTS[@]} PACKAGE=($(find . -regextype egrep -regex '^.*\.pkg(|\.tar|\.tar\.xz|\.tar\.zst)$')) REPODB=$(find /repo -regextype egrep -regex '^.*\.db(\.tar|\.tar\.xz|\.tar.zst)$') if [ -z "${REPODB}" ]; then - echo "No database found in /repo, not adding package." - echo "The built package is available in ${PACKAGE}" - exit 0 + 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 + gosu builder mv ${pkg_file}* /repo - pushd /repo - gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}" - popd + pushd /repo + gosu builder repo-add ${REPOADD_OPTS[@]} ${REPODB} "${pkg_file}" + popd done