forked from tianon/docker-qemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversions.sh
executable file
·48 lines (40 loc) · 936 Bytes
/
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
#!/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[@]%/}" )
# https://download.qemu.org/?C=M;O=D
urls="$(
wget -qO- 'https://www.qemu.org/download/' \
| grep -oE 'https://download[.]qemu[.]org/qemu-([^"]+)[.]tar[.]xz' \
| sort -ruV
)"
for version in "${versions[@]}"; do
rcGrepV='-v'
rcVersion="${version%-rc}"
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
url="$(
grep -E "qemu-$rcVersion([.-])" <<<"$urls" \
| grep $rcGrepV -E -- '-rc' \
| head -1
)"
fullVersion="${url##*/qemu-}"
fullVersion="${fullVersion%%.tar.*}"
echo "$version: $fullVersion"
export version fullVersion url
json="$(jq <<<"$json" '
.[env.version] = {
version: env.fullVersion,
url: env.url,
}
')"
done
jq <<<"$json" -S . > versions.json