From 87b3761c89be3652f885bd801b83b0d3cd0f01f9 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 22 Nov 2018 17:56:13 +0100 Subject: [PATCH] Add aur2repo script Signed-off-by: Knut Ahlers --- bin/aur2repo | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/aur2repo diff --git a/bin/aur2repo b/bin/aur2repo new file mode 100755 index 0000000..8cea7c0 --- /dev/null +++ b/bin/aur2repo @@ -0,0 +1,41 @@ +#!/bin/bash +set -euo pipefail + +source ${HOME}/bin/script_framework.sh + +REPO_DIR=${REPO_DIR:-/home/luzifer/tmp/archrepo} + +PACKAGE=${1:-} +[ -z "${PACKAGE}" ] && fail "No package given as CLI argument" + +# Create working dir +TMPDIR="/tmp/aur2repo_${PACKAGE}" +mkdir -p "${TMPDIR}/cfg" + +# Ensure cleanup on script exit +function cleanup() { + rm -rf "${TMPDIR}" +} +trap cleanup EXIT + +step "Fetching signing key" +vault read --field=key secret/jenkins/arch-signing >"${TMPDIR}/cfg/signing.asc" + +step "Re-fetching Docker image" +docker pull luzifer/arch-repo-builder + +step "Synchronizing the repository" +vault2env --key=secret/aws/private -- \ + aws s3 sync --delete s3://arch-luzifer-io/repo/x86_64/ "${REPO_DIR}/" + +step "Building AUR package" +docker run --rm -ti \ + -v "${TMPDIR}/src:/src" \ + -v "${TMPDIR}/cfg:/config" \ + -v "${REPO_DIR}:/repo" \ + luzifer/arch-repo-builder \ + "https://aur.archlinux.org/${PACKAGE}.git" + +step "Synchronizing repository changes" +vault2env --key=secret/aws/private -- \ + aws s3 sync --delete --exclude '*.old*' --acl=public-read "${REPO_DIR}/" s3://arch-luzifer-io/repo/x86_64/