From 1c00484fc23d3b873ec30494111144ad9a2139e3 Mon Sep 17 00:00:00 2001 From: Tobias Manske Date: Mon, 21 Aug 2023 19:42:52 +0200 Subject: [PATCH] Move Repo update to the end --- entrypoint.sh | 55 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f8e945c..9e2e6ee 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,20 +18,6 @@ mcli alias set s3 https://s3.tobiasmanske.de "${REPO_ACCESS_KEY}" "${REPO_SECRET # LOCK LOCK="" -while [[ "${LOCK}" != "${PIPELINE_ID}" ]]; do - if [[ ${DEBUG:-} == "true" ]]; then - echo "Debug mode, not waiting for lock" - break - fi - LOCK=$(mcli cat s3/repo/LOCK) - if [[ "${LOCK}" == "FREE" ]]; then - echo $PIPELINE_ID | mcli pipe s3/repo/LOCK - LOCK=$(mcli cat s3/repo/LOCK) - continue - fi - echo "Waiting for lock with id $PIPELINE_ID..." - sleep $((RANDOM % 10)) -done unlock() { if [[ "${LOCK}" == "${PIPELINE_ID}" ]]; then @@ -40,16 +26,36 @@ unlock() { } -trap unlock EXIT INT TERM +lock () { + while [[ "${LOCK}" != "${PIPELINE_ID}" ]]; do + if [[ ${DEBUG:-} == "true" ]]; then + echo "Debug mode, not waiting for lock" + break + fi + LOCK=$(mcli cat s3/repo/LOCK) + if [[ "${LOCK}" == "FREE" ]]; then + echo $PIPELINE_ID | mcli pipe s3/repo/LOCK + LOCK=$(mcli cat s3/repo/LOCK) + continue + fi + echo "Waiting for lock with id $PIPELINE_ID..." + sleep $((RANDOM % 10)) + done + trap unlock EXIT INT TERM +} -echo "Pulling Repository" -( - mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.db.tar.xz" /repo - mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.db.tar.xz.sig" /repo - mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.files.tar.xz" /repo - mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.files.tar.xz.sig" /repo +pullrepo () { + echo "Pulling Repository" + ( + mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.db.tar.xz" /repo + mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.db.tar.xz.sig" /repo + mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.files.tar.xz" /repo + mcli cp "s3/repo/x86_64/${AUR_REPO_NAME}.files.tar.xz.sig" /repo -) &>/dev/null + ) &>/dev/null +} + +pullrepo if ! (aur repo >/dev/null 2>&1); then printf "Aur repo not initialized, initializing /repo...\n" @@ -129,5 +135,8 @@ cat graph | aur sync--ninja -S -- aur build -S --noconfirm --no-sync --margs -s echo "##################################" ls -la /repo -## Upload to repo +pullrepo +lock +repo-add -k C3FE87CFB8F8D503AE03EC1C033E7F3DC71FE89E --sign "/repo/${AUR_REPO_NAME}.db.tar.xz" /repo/*.pkg.tar.zst mcli mirror --overwrite /repo s3/repo/x86_64 +unlock