43 lines
1.0 KiB
Bash
43 lines
1.0 KiB
Bash
#!/bin/bash
|
|
|
|
# Function to get the corresponding debian-archive-keyring
|
|
get_keyring() {
|
|
date_string=${1:-"20190608T160814Z"}
|
|
|
|
echo "${date_string}"
|
|
echo ""
|
|
|
|
# Remove the 'SOURCES_DATE=' prefix
|
|
date_string=${date_string#*=}
|
|
|
|
echo "${date_string}"
|
|
echo ""
|
|
|
|
# Convert the date format
|
|
date_string=$(date -d"${date_string:0:4}-${date_string:4:2}-${date_string:6:2}T${date_string:9:2}:${date_string:11:2}:${date_string:13:2}" +"%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
echo "${date_string}"
|
|
echo ""
|
|
|
|
# Get the list of keyrings
|
|
keyrings=$(curl -s "https://snapshot.debian.org/mr/package/debian-archive-keyring/")
|
|
|
|
echo "${keyrings}" | jq -r '.result[].version'
|
|
echo ""
|
|
|
|
# Obtain the available version numbers
|
|
echo "${keyrings}" | jq -r '.result[].version' | sort -rV
|
|
echo ""
|
|
|
|
# Find the keyring that was first seen closest to but not later than the given date
|
|
|
|
|
|
|
|
keyring=$(echo "${keyrings}" | jq -r '.result[].version' | sort -V | awk -v date="${date_string}" '$0 <= date {print; exit}')
|
|
|
|
echo "debian-archive-keyring_${keyring}"
|
|
}
|
|
|
|
# Call the function
|
|
get_keyring "$@"
|