From fb4656956c2e6fa726aef3946b5cdac5e7b92ee1 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sun, 16 Jul 2023 19:20:22 +0200 Subject: unitfiles and scripts --- scripts/build_container.sh | 7 ++++++ scripts/build_packages.sh | 46 ++++++++++++++++++++++++++++++++++ unitfiles/aurbuilder-container.service | 11 ++++++++ unitfiles/aurbuilder-package.service | 11 ++++++++ 4 files changed, 75 insertions(+) create mode 100755 scripts/build_container.sh create mode 100755 scripts/build_packages.sh create mode 100644 unitfiles/aurbuilder-container.service create mode 100644 unitfiles/aurbuilder-package.service diff --git a/scripts/build_container.sh b/scripts/build_container.sh new file mode 100755 index 0000000..614d34c --- /dev/null +++ b/scripts/build_container.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +PODMAN=$(which podman) +DIR=${DIR:-/usr/share/aurbuilder} + +$PODMAN pull archlinux:base-devel +$PODMAN build --no-cache -t aurbuilder "$DIR" diff --git a/scripts/build_packages.sh b/scripts/build_packages.sh new file mode 100755 index 0000000..2393569 --- /dev/null +++ b/scripts/build_packages.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +PODMAN=$(which podman) + +CONFFILE=${CONFFILE:-/etc/aurbuilder/packages} +OUTPUT=${OUTPUT:-/srv/pkg/} +FORCE_REBUILD=${FORCE_REBUILD:-no} +CHOWN_TO=${CHOWN_TO:-$USER} + +if ! ($PODMAN image list | grep aurbuilder > /dev/null); then + echo Container image \"aurbuilder\" was not found. Was it built? + exit 1 +fi + +ERROR=0 +ERR_PKGS=() + +while read -r LINE; do + [[ $LINE == \#* ]] && continue + echo "" + echo "BUILDING $LINE" + echo "=======================" + echo "" + echo "" + + CONT_NAME="aurbuilder-$RANDOM" + $PODMAN run --userns=host --name "$CONT_NAME" \ + --env PACKAGE_NAME="$LINE" \ + --env FORCE_REBUILD="$FORCE_REBUILD" \ + --env CHOWN="$(id -u "$CHOWN_TO"):$(id -g "$CHOWN_TO")" \ + -v "$OUTPUT:/pkgout:z" \ + aurbuilder \ + RET=$? + $PODMAN rm "$CONT_NAME" + + if [ "$RET" -ne 0 ]; then + ERROR=1 + ERR_PKGS+=("$LINE") + fi +done < "$CONFFILE" + +if [ "$ERROR" -ne 0 ]; then + echo There were Errors while building following packages: "${ERR_PKGS[@]}" + exit 1 +fi + diff --git a/unitfiles/aurbuilder-container.service b/unitfiles/aurbuilder-container.service new file mode 100644 index 0000000..de0232b --- /dev/null +++ b/unitfiles/aurbuilder-container.service @@ -0,0 +1,11 @@ +[Unit] +Description=aurbuilder Container build job + +[Service] +Type=simple +User=aurbuilder +Group=aurbuilder +ExecStart=/usr/lib/aurbuilder/build_container.sh +Restart=no +StartLimitInterval=10min +StartLimitBurst=8 diff --git a/unitfiles/aurbuilder-package.service b/unitfiles/aurbuilder-package.service new file mode 100644 index 0000000..228e87a --- /dev/null +++ b/unitfiles/aurbuilder-package.service @@ -0,0 +1,11 @@ +[Unit] +Description=aurbuilder Package build job + +[Service] +Type=simple +User=aurbuilder +Group=aurbuilder +ExecStart=/usr/lib/aurbuilder/build_packages.sh +Restart=no +StartLimitInterval=10min +StartLimitBurst=8 -- cgit v1.2.3