1
0
mirror of https://github.com/Luzifer/archrepo.git synced 2024-09-20 03:02:57 +00:00
archrepo/scripts/update-repo.sh

55 lines
1.4 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}"
2019-09-29 23:20:25 +00:00
}
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 git.luzifer.io/registry/arch-repo-builder
2019-09-29 23:20:25 +00:00
step "Building package $(basename ${REPO})"
extra_opts=()
if [[ -f /etc/pacman.d/mirrorlist ]]; then
info "Using host system mirrorlist..."
extra_opts+=(-v "/etc/pacman.d/mirrorlist:/etc/pacman.d/mirrorlist:ro")
fi
2019-09-29 23:20:25 +00:00
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" \
"${extra_opts[@]}" \
--ulimit nofile=262144:262144 \
git.luzifer.io/registry/arch-repo-builder \
"${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