forked from docker-library/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·51 lines (45 loc) · 1.27 KB
/
update.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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
defaultDebianVariant='stretch-slim'
declare -A debianVariants=(
#[5.5]='jessie'
)
for version in "${versions[@]}"; do
debianVariant="${debianVariants[$version]:-$defaultDebianVariant}"
debianSuite="${debianVariant%%-*}" # "stretch", etc
if [ "$version" = '5.5' ]; then
fullVersion="$(curl -sSL "https://dev.mysql.com/downloads/mysql/$version.html?os=2" \
| grep '">(mysql-'"$version"'.*-linux.*-x86_64\.tar\.gz)<' \
| sed -r 's!.*\(mysql-([^<)]+)-linux.*-x86_64\.tar\.gz\).*!\1!' \
| sort -V | tail -1)"
else
fullVersion="$(
curl -fsSL "http://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
}
'
)"
fi
(
set -x
sed -ri \
-e 's/^(ENV MYSQL_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(ENV MYSQL_MAJOR) .*/\1 '"$version"'/' \
-e 's/^(FROM) .*/\1 debian:'"$debianVariant"'/' \
-e 's!(http://repo.mysql.com/apt/debian/) [^ ]+!\1 '"$debianSuite"'!' \
"$version/Dockerfile"
)
done