forked from MariaDB/mariadb-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·160 lines (139 loc) · 3.87 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env bash
set -Eeuo pipefail
#
# Usage ./update.sh [version(multiple)...]
#
defaultSuite='jammy'
declare -A suites=(
[10.3]='focal'
[10.4]='focal'
[10.5]='focal'
[10.6]='focal'
[10.7]='focal'
)
declare -A suffix=(
['focal']='ubu2004'
['jammy']='ubu2204'
)
#declare -A dpkgArchToBashbrew=(
# [amd64]='amd64'
# [armel]='arm32v5'
# [armhf]='arm32v7'
# [arm64]='arm64v8'
# [i386]='i386'
# [ppc64el]='ppc64le'
# [s390x]='s390x'
#)
update_version()
{
echo "$version: $mariaVersion ($releaseStatus)"
suite="${suites[$version]:-$defaultSuite}"
fullVersion=1:${mariaVersion}+maria~${suffix[${suite}]}
if [[ $version = 10.[234] ]]; then
arches=" amd64 arm64v8 ppc64le"
else
arches=" amd64 arm64v8 ppc64le s390x"
fi
cp Dockerfile.template "$version/Dockerfile"
cp docker-entrypoint.sh healthcheck.sh "$version/"
chmod a+x "$version"/healthcheck.sh
sed -i \
-e 's!%%MARIADB_VERSION%%!'"$fullVersion"'!g' \
-e 's!%%MARIADB_VERSION_BASIC%%!'"$mariaVersion"'!g' \
-e 's!%%MARIADB_MAJOR%%!'"$version"'!g' \
-e 's!%%MARIADB_RELEASE_STATUS%%!'"$releaseStatus"'!g' \
-e 's!%%SUITE%%!'"$suite"'!g' \
-e 's!%%ARCHES%%!'"$arches"'!g' \
"$version/Dockerfile"
# Start using the new executable names
case "$version" in
10.3 | 10.4)
sed -i -e '/--old-mode/d' "$version/docker-entrypoint.sh"
;; # almost nothing to see/do here
10.5)
sed -i -e '/--old-mode/d' "$version/docker-entrypoint.sh"
sed -i '/backwards compat/d' "$version/Dockerfile"
;;
*)
sed -i -e '/^CMD/s/mysqld/mariadbd/' \
-e '/backwards compat/d' "$version/Dockerfile"
sed -i -e 's/mysql_upgrade\([^_]\)/mariadb-upgrade\1/' \
-e 's/mysqldump/mariadb-dump/' \
-e 's/mysqladmin/mariadb-admin/' \
-e 's/\bmysql --protocol\b/mariadb --protocol/' \
-e 's/mysql_install_db/mariadb-install-db/' \
-e "0,/#ENDOFSUBSTITUTIONS/s/mysqld/mariadbd/" \
-e 's/mysql_tzinfo_to_sql/mariadb-tzinfo-to-sql/' \
"$version/docker-entrypoint.sh"
sed -i -e '0,/#ENDOFSUBSTITUTIONS/s/\bmysql\b/mariadb/' "$version/healthcheck.sh"
if [[ ! $version =~ 10.[678] ]]; then
# quoted $ intentional
# shellcheck disable=SC2016
sed -i -e '/^ARG MARIADB_MAJOR/d' \
-e '/^ENV MARIADB_MAJOR/d' \
-e 's/-\$MARIADB_MAJOR//' \
"$version/Dockerfile"
fi
;&
esac
}
mariaversion()
{
mariaVersion=$( curl -fsSL https://downloads.mariadb.org/rest-api/mariadb/"${version}" \
| jq 'first(..|select(.release_id)) | .release_id' )
mariaVersion=${mariaVersion//\"}
}
all()
{
curl -fsSL https://downloads.mariadb.org/rest-api/mariadb/ \
| jq '.major_releases[] | [ .release_id ], [ .release_status ] | @tsv ' \
| while read -r version
do
version=${version//\"}
if [ ! -d "$version" ]; then
echo >&2 "warning: no rule for $version"
continue
fi
mariaversion
read -r releaseStatus
releaseStatus=${releaseStatus//\"}
case "$releaseStatus" in
Alpha | Beta | Gamma | RC | Stable ) ;; # sanity check
"Old Stable" )
releaseStatus=Stable
;; # insanity check
*) echo >&2 "error: unexpected 'release status' value for $mariaVersion: $releaseStatus"; ;;
esac
update_version
done
}
development_version=10.12
in_development()
{
releaseStatus=Alpha
version=$development_version
mariaVersion=${development_version}.0
[ -d "$development_version" ] && update_version
}
if [ $# -eq 0 ]; then
all
in_development
exit 0
fi
versions=( "$@" )
for version in "${versions[@]}"; do
if [ "$version" == $development_version ]; then
in_development
continue
fi
if [ ! -d "$version" ]; then
mariaVersion=$version
version=${version%.[[:digit:]]*}
else
mariaversion
fi
releaseStatus=$(curl -fsSL https://downloads.mariadb.org/rest-api/mariadb/ \
| jq ".major_releases[] | select(.release_id == \"$version\") | .release_status")
releaseStatus=${releaseStatus//\"}
update_version
done