-
Notifications
You must be signed in to change notification settings - Fork 127
/
versions.sh
executable file
·100 lines (89 loc) · 2.25 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ "${#versions[@]}" -eq 0 ]; then
versions=( */ )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
busyboxVersions="$(
wget -qO- 'https://busybox.net' \
| grep -oE '[0-9a-zA-Z ]+ -- BusyBox [0-9.]+ [(](un)?stable[)]' \
| jq -csR '
rtrimstr("\n")
| split("\n")
| map(
split(" -- BusyBox ")
| {
version: .[1],
date: .[0],
}
| .stability = (.version | gsub(".* [(]|[)]"; ""))
| .version |= split(" ")[0]
)
| sort_by(.version | split(".") | map(tonumber))
| reverse
'
)"
# [
# {
# "version": "1.36.0",
# "date": "3 January 2023",
# "stability": "unstable"
# },
# ...
# ]
buildrootVersion="$(
git ls-remote --tags https://gitlab.com/buildroot.org/buildroot.git \
| cut -d/ -f3 \
| cut -d^ -f1 \
| grep -E '^[0-9]+' \
| grep -vE -- '[-_]rc' \
| sort -uV \
| tail -1
)"
export buildrootVersion
for version in "${versions[@]}"; do
export version
minus="${version#latest}"
minus="${minus#-}"
: "${minus:=0}"
majorMinor="$(jq <<<"$busyboxVersions" -cr --argjson minus "$minus" '
map(.version | split(".")[0:2] | join("."))
| unique
| reverse[$minus]
')"
if [ -z "$majorMinor" ]; then
echo >&2 "error: failed to find '$version' release"
exit 1
fi
doc="$(jq <<<"$busyboxVersions" -c --arg majorMinor "$majorMinor" '
map(select(
.version
| startswith($majorMinor + ".")
))[0]
')"
fullVersion="$(jq <<<"$doc" -r '.version')"
export fullVersion
echo "$version: $fullVersion (buildroot $buildrootVersion)"
sha256="$(wget -qO- "https://busybox.net/downloads/busybox-$fullVersion.tar.bz2.sha256" | cut -d' ' -f1)"
export sha256
json="$(
jq <<<"$json" -c --argjson doc "$doc" '
.[env.version] = $doc + {
sha256: env.sha256,
buildroot: {
version: env.buildrootVersion,
},
# as of buildroot 2022.11, glibc is the default, so we follow suit (https://github.com/buildroot/buildroot/commit/4057e36ca9665edd5248512e4edba2c243b8f4be)
# https://busybox.net/FAQ.html#libc
variants: [ "glibc", "uclibc", "musl" ],
# (order here determines "preference" for representing "latest")
}
'
)"
done
jq <<<"$json" -S . > versions.json