mirror of
https://github.com/bitnami/minideb.git
synced 2026-06-04 10:13:55 +08:00
separate snapshot_id logic
This commit is contained in:
@@ -11,50 +11,18 @@ stretch
|
||||
buster
|
||||
unstable
|
||||
"
|
||||
|
||||
DISTS_WITH_SNAPSHOT="buster"
|
||||
|
||||
get_latest_month_query(){
|
||||
local -r snapshot_tmp_dir=$(mktemp -d)
|
||||
local -r snapshot_archive_tmp_file="${snapshot_tmp_dir}/archive.html"
|
||||
mkdir -p "${snapshot_tmp_dir}"
|
||||
|
||||
! 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_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: ${month_query_regex}" && return 1
|
||||
|
||||
echo "$month_query"
|
||||
}
|
||||
|
||||
get_latest_debian_snapshot_id() {
|
||||
local -r snapshot_tmp_dir=$(mktemp -d)
|
||||
local -r snapshot_list_tmp_file="${snapshot_tmp_dir}/month-snapshots.html"
|
||||
mkdir -p "${snapshot_tmp_dir}"
|
||||
|
||||
! month_query=$(get_latest_month_query) && return 1
|
||||
|
||||
! 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_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: ${snapshot_id_regex}" && return 1
|
||||
|
||||
echo "$snapshot_id"
|
||||
}
|
||||
|
||||
for DIST in $DISTS; do
|
||||
./buildone "$DIST"
|
||||
done
|
||||
|
||||
! snapshot_id=$(get_latest_debian_snapshot_id) && exit 1
|
||||
snapshot_id=$(./snapshotid)
|
||||
if [ -n "$snapshot_id" ]; then
|
||||
for DIST in $DISTS_WITH_SNAPSHOT; do
|
||||
./buildone "$DIST" "$snapshot_id"
|
||||
done
|
||||
|
||||
for DIST in $DISTS_WITH_SNAPSHOT; do
|
||||
./buildone "$DIST" "$snapshot_id"
|
||||
done
|
||||
|
||||
mkdir -p build
|
||||
echo "$snapshot_id" > build/snapshot_id
|
||||
mkdir -p build
|
||||
echo "$snapshot_id" > build/snapshot_id
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user