-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathversions.sh
executable file
·79 lines (76 loc) · 2.56 KB
/
versions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -Eeuo pipefail
distsSuites=( "$@" )
if [ "${#distsSuites[@]}" -eq 0 ]; then
# 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)"
fi
distsSuites=( "${distsSuites[@]%/}" )
for version in "${distsSuites[@]}"; do
codename="$(basename "$version")"
dist="$(dirname "$version")"
doc='{"variants": [ "curl", "scm", "" ]}'
suite=
case "$dist" in
debian)
# "stable", "oldstable", etc.
suite="$(
wget -qO- -o /dev/null "https://deb.debian.org/debian/dists/$codename/Release" \
| gawk -F ':[[:space:]]+' '$1 == "Suite" { print $2 }'
)"
;;
ubuntu)
suite="$(
wget -qO- -o /dev/null "http://archive.ubuntu.com/ubuntu/dists/$codename/Release" \
| gawk -F ':[[:space:]]+' '$1 == "Version" { print $2 }'
)"
;;
esac
if [ -n "$suite" ]; then
export suite
doc="$(jq <<<"$doc" -c '.suite = env.suite')"
echo "$version: $suite"
else
echo "$version: ???"
fi
export doc version
json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')"
done
jq <<<"$json" -S . > versions.json