1
0
Fork 0
mirror of https://github.com/Luzifer/archrepo.git synced 2024-11-14 04:12:42 +00:00
archrepo/scripts/update-repo.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

2019-09-29 23:20:25 +00:00
#!/bin/bash
set -euo pipefail
source ./scripts/script_framework.sh
REPO_DIR=${REPO_DIR:-$(pwd)}
REPO=${1:-}
[ -z "${REPO}" ] && fail "No repo given as CLI argument"
step "Checking for changes from last build"
last_remote_hash=$(git ls-remote ${REPO} master | awk '{print $1}')
grep "${REPO}#${last_remote_hash}" .repo_cache && {
warn "Remote has no changes from last build, skipping..."
exit 0
} || true
2019-09-29 23:20:25 +00:00
# Create working dir
TMPDIR="/tmp/aur2repo_$(basename ${REPO})"
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 gcr.io/luzifer-registry/arch-repo-builder
2019-09-29 23:20:25 +00:00
step "Building package $(basename ${REPO})"
docker run --rm -ti \
-v "${TMPDIR}/src:/src" \
-v "${TMPDIR}/cfg:/config" \
-v "${REPO_DIR}:/repo" \
-v "$(pwd)/scripts/pacman.conf:/etc/pacman.conf:ro" \
gcr.io/luzifer-registry/arch-repo-builder \
2019-09-29 23:20:25 +00:00
"${REPO}"
step "Updating cache entry"
grep -v "^${REPO}#" .repo_cache >.repo_cache.tmp || true
echo "${REPO}#${last_remote_hash}" >>.repo_cache.tmp
mv .repo_cache.tmp .repo_cache