mirror of
https://github.com/bitnami/minideb.git
synced 2026-06-04 10:13:55 +08:00
29 lines
857 B
Bash
Executable File
29 lines
857 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
set -u
|
|
set -o pipefail
|
|
|
|
|
|
get_debian_snapshot_id() {
|
|
local -r year=$(date -u +%G)
|
|
local -r month=$(date -u +%m)
|
|
local -r day=$(date -u +%d)
|
|
|
|
snapshot_list_tmp_dir=$(mktemp -d)
|
|
snapshot_list_tmp_file="${snapshot_list_tmp_dir}/${year}-${month}.html"
|
|
|
|
! curl -sSfL "https://snapshot.debian.org/archive/debian/?year=$year&month=$month" > "$snapshot_list_tmp_file" && echo "Not found snapshots for these parameters: year=${year} month=${month}" && return 1
|
|
|
|
snapshot_id=$(grep -Po "(${year}${month}${day}T.*Z)" "${snapshot_list_tmp_file}" | tail -1)
|
|
|
|
[[ -z "$snapshot_id" ]] && echo "Not found snapshot id using the following regex: (${year}${month}${day}T.*Z)" && return 1
|
|
|
|
rm -f "${snapshot_list_tmp_file}"
|
|
echo "$snapshot_id" > build/snapshot_id && return 0
|
|
}
|
|
|
|
mkdir -p build
|
|
|
|
get_debian_snapshot_id
|