forked from docker-library/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versions.sh
executable file
·55 lines (47 loc) · 1.07 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
#!/usr/bin/env bash
set -Eeuo pipefail
defaultDebianSuite='buster'
declare -A debianSuites=(
[5.6]='stretch'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( *.*/ )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
for version in "${versions[@]}"; do
export version
debianSuite="${debianSuites[$version]:-$defaultDebianSuite}"
debianVersion="$(
curl -fsSL "https://repo.mysql.com/apt/debian/dists/$debianSuite/mysql-$version/binary-amd64/Packages.gz" \
| gunzip \
| awk -F ': ' '
$1 == "Package" {
pkg = $2
next
}
pkg == "mysql-server" && $1 == "Version" {
print $2
}
'
)"
# example 8.0.22-1debian10 => 8.0.22
baseVersion="${debianVersion%-*}"
export baseVersion debianSuite debianVersion
json="$(
jq <<<"$json" -c \
'.[env.version] = {
version: env.baseVersion,
debian: {
architectures: [ "amd64" ],
suite: env.debianSuite,
version: env.debianVersion,
},
}'
)"
done
jq <<<"$json" -S . > versions.json