improve scripts

This commit is contained in:
darteaga
2020-07-02 10:38:56 +00:00
parent eb3437cd8a
commit ff93bf6411
2 changed files with 22 additions and 15 deletions
+6 -4
View File
@@ -21,9 +21,10 @@ get_latest_month_query(){
! curl -sSfL "https://snapshot.debian.org/archive/debian/" > "$snapshot_archive_tmp_file" && echo "Error when accessing https://snapshot.debian.org/archive/debian/" && return 1
local -r month_query=$(grep -Po "(\?year=\d\d\d\d&month=\d+)" "${snapshot_archive_tmp_file}" | tail -1)
local -r month_query_regex="(\?year=\d\d\d\d&month=\d+)"
local -r month_query=$(grep -Po "${month_query_regex}" "${snapshot_archive_tmp_file}" | tail -1)
[[ -z "$month_query" ]] && echo "Not found snapshots using the following regex: (?year=\d\d\d\d&month=\d+)" && return 1
[[ -z "$month_query" ]] && echo "Not found snapshots using the following regex: ${month_query_regex}" && return 1
echo "$month_query"
}
@@ -37,9 +38,10 @@ get_latest_debian_snapshot_id() {
! curl -sSfL "https://snapshot.debian.org/archive/debian/$month_query" > "$snapshot_list_tmp_file" && echo "Not found snapshots for these parameters: query=${month_query}" && return 1
local -r snapshot_id=$(grep -Po "(\d+T.*Z)" "${snapshot_list_tmp_file}" | tail -1)
local -r snapshot_id_regex="(\d+T.*Z)"
local -r snapshot_id=$(grep -Po "${snapshot_id_regex}" "${snapshot_list_tmp_file}" | tail -1)
[[ -z "$snapshot_id" ]] && echo "Not found snapshot id using the following regex: (\d+T.*Z)" && return 1
[[ -z "$snapshot_id" ]] && echo "Not found snapshot id using the following regex: ${snapshot_id_regex}" && return 1
echo "$snapshot_id"
}
+16 -11
View File
@@ -7,9 +7,9 @@ set -o pipefail
DISTS="jessie
stretch
buster
buster-snapshot
unstable
"
DISTS_WITH_SNAPSHOT="buster"
LATEST=buster
BASENAME=bitnami/minideb
GCR_BASENAME=gcr.io/bitnami-containers/minideb
@@ -50,18 +50,23 @@ push() {
}
for DIST in $DISTS; do
if is_snapshot "$DIST"; then
! debian_snapshot_id=$(cat build/snapshot_id) && continue
TAG="${DIST}-${debian_snapshot_id}"
else
TAG=$DIST
fi
docker tag "${BASENAME}:${TAG}" "${QUAY_BASENAME}:${TAG}"
docker tag "${BASENAME}:${TAG}" "${GCR_BASENAME}:${TAG}"
push "$TAG"
docker tag "${BASENAME}:${DIST}" "${QUAY_BASENAME}:${DIST}"
docker tag "${BASENAME}:${DIST}" "${GCR_BASENAME}:${DIST}"
push "$DIST"
done
if [ -f "build/snapshot_id" ]; then
snapshot_id=$(cat build/snapshot_id)
for DIST in $DISTS_WITH_SNAPSHOT; do
DIST="${DIST}-snapshot-${snapshot_id}"
docker tag "${BASENAME}:${DIST}" "${QUAY_BASENAME}:${DIST}"
docker tag "${BASENAME}:${DIST}" "${GCR_BASENAME}:${DIST}"
push "$DIST"
done
fi
docker tag "${BASENAME}:${LATEST}" "${BASENAME}:latest"
docker tag "${QUAY_BASENAME}:${LATEST}" "${QUAY_BASENAME}:latest"
docker tag "${GCR_BASENAME}:${LATEST}" "${GCR_BASENAME}:latest"