Merge pull request #164 from infosiftr/canonical-suites

Use `bashbrew` to gather the canonical list of supported suites
This commit is contained in:
Tianon Gravi 2025-02-11 16:39:32 -08:00 committed by GitHub
commit 4f4a759c51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -14,6 +14,9 @@ fi
if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"
# TODO make this cleaner
rm -rf debian ubuntu
fi
generated_warning() {

View File

@ -3,7 +3,42 @@ set -Eeuo pipefail
distsSuites=( "$@" )
if [ "${#distsSuites[@]}" -eq 0 ]; then
distsSuites=( */*/ )
# when run without arguments, let's use "bashbrew" to get the canonical list of currently supported suites/codenames
bashbrew --version > /dev/null
if [ -z "${BASHBREW_LIBRARY:-}" ] || [ ! -s "$BASHBREW_LIBRARY/debian" ] || [ ! -s "$BASHBREW_LIBRARY/ubuntu" ]; then
tempDir="$(mktemp -d)"
trap 'rm -rf "$tempDir"' EXIT
wget -qO "$tempDir/debian" 'https://github.com/docker-library/official-images/raw/HEAD/library/debian'
wget -qO "$tempDir/ubuntu" 'https://github.com/docker-library/official-images/raw/HEAD/library/ubuntu'
export BASHBREW_LIBRARY="$tempDir"
bashbrew cat debian ubuntu > /dev/null
fi
dists="$(
bashbrew cat debian ubuntu --format '
{{- range .Entries -}}
{{- $.Tags "" false . | json -}}
{{- "\n" -}}
{{- end -}}
' | jq -r '
map(select(test("
# a few tags we explicitly want to ignore in our search for codenames
:(
experimental | rc-buggy # not a release
|
latest | .*stable | devel | rolling | testing # stable/development/rolling aliases
|
.* - .* # anything with a hyphen
|
[0-9].* # likewise with numerics
)$
"; "x") | not))
| .[0] // empty # then we filter to the first leftover in each tag group and it should be the codename
| sub(":"; "/")
| @sh
'
)"
# TODO expand this and do our supported architectures detection here too, while we've already done the lookups? Ubuntu version number lookups via this method too? (unfortunately we can't map Debian codenames to aliases like "stable" this way)
eval "distsSuites=( $dists )"
json='{}'
else
json="$(< versions.json)"