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"
|
|
|
|
|
2020-07-19 22:49:49 +00:00
|
|
|
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 && {
|
2023-02-18 15:25:55 +00:00
|
|
|
warn "Remote has no changes from last build, skipping..."
|
|
|
|
exit 0
|
2020-07-19 22:49:49 +00:00
|
|
|
} || 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() {
|
2023-02-18 15:25:55 +00:00
|
|
|
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"
|
2021-09-23 06:46:24 +00:00
|
|
|
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 \
|
2023-02-18 15:25:55 +00:00
|
|
|
-v "${TMPDIR}/src:/src" \
|
|
|
|
-v "${TMPDIR}/cfg:/config" \
|
|
|
|
-v "${REPO_DIR}:/repo" \
|
|
|
|
-v "$(pwd)/scripts/pacman.conf:/etc/pacman.conf:ro" \
|
|
|
|
--ulimit nofile=262144:262144 \
|
|
|
|
gcr.io/luzifer-registry/arch-repo-builder \
|
|
|
|
"${REPO}"
|
2020-07-19 22:49:49 +00:00
|
|
|
|
|
|
|
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
|