-
Notifications
You must be signed in to change notification settings - Fork 115
/
versions.sh
executable file
·44 lines (41 loc) · 1.04 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
#!/usr/bin/env bash
set -Eeuo pipefail
distsSuites=( "$@" )
if [ "${#distsSuites[@]}" -eq 0 ]; then
distsSuites=( */*/ )
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