forked from docker-library/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·44 lines (38 loc) · 999 Bytes
/
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
#!/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
fullVersion="$(
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
}
'
)"
(
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