2019-06-03 16:32:38 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
2021-10-25 08:52:18 +11:00
|
|
|
#
|
|
|
|
# Usage ./update.sh [version(multiple)...]
|
|
|
|
#
|
2014-11-24 15:31:55 -08:00
|
|
|
|
2022-03-04 14:13:46 +11:00
|
|
|
defaultSuite='jammy'
|
2015-07-20 15:28:26 -07:00
|
|
|
declare -A suites=(
|
2022-03-04 14:13:46 +11:00
|
|
|
[10.4]='focal'
|
|
|
|
[10.5]='focal'
|
|
|
|
[10.6]='focal'
|
2017-07-27 17:21:39 -07:00
|
|
|
)
|
2015-07-20 15:28:26 -07:00
|
|
|
|
2022-08-23 10:51:38 +10:00
|
|
|
declare -A suffix=(
|
|
|
|
['focal']='ubu2004'
|
|
|
|
['jammy']='ubu2204'
|
|
|
|
)
|
|
|
|
|
2021-03-02 15:00:11 +11:00
|
|
|
#declare -A dpkgArchToBashbrew=(
|
|
|
|
# [amd64]='amd64'
|
|
|
|
# [armel]='arm32v5'
|
|
|
|
# [armhf]='arm32v7'
|
|
|
|
# [arm64]='arm64v8'
|
|
|
|
# [i386]='i386'
|
|
|
|
# [ppc64el]='ppc64le'
|
|
|
|
# [s390x]='s390x'
|
|
|
|
#)
|
|
|
|
|
2023-02-17 10:52:34 +01:00
|
|
|
# For testing with https://downloads.dev.mariadb.org/rest-api
|
|
|
|
typeset -r DOWNLOADS_REST_API="https://downloads.mariadb.org/rest-api"
|
|
|
|
|
2021-03-02 15:00:11 +11:00
|
|
|
update_version()
|
|
|
|
{
|
|
|
|
echo "$version: $mariaVersion ($releaseStatus)"
|
2014-11-24 15:31:55 -08:00
|
|
|
|
2015-07-20 15:28:26 -07:00
|
|
|
suite="${suites[$version]:-$defaultSuite}"
|
2022-08-23 10:51:38 +10:00
|
|
|
fullVersion=1:${mariaVersion}+maria~${suffix[${suite}]}
|
2019-03-01 13:15:13 -08:00
|
|
|
|
2021-03-02 15:00:11 +11:00
|
|
|
if [[ $version = 10.[234] ]]; then
|
2023-06-17 22:13:35 +02:00
|
|
|
arches="amd64 arm64v8 ppc64le"
|
2021-03-02 15:00:11 +11:00
|
|
|
else
|
2023-06-17 22:13:35 +02:00
|
|
|
arches="amd64 arm64v8 ppc64le s390x"
|
2021-07-08 19:08:37 +10:00
|
|
|
fi
|
2018-07-16 16:49:00 -07:00
|
|
|
|
|
|
|
cp Dockerfile.template "$version/Dockerfile"
|
2022-03-04 16:15:13 +11:00
|
|
|
|
2022-01-31 15:27:25 +11:00
|
|
|
cp docker-entrypoint.sh healthcheck.sh "$version/"
|
2021-03-02 15:00:11 +11:00
|
|
|
chmod a+x "$version"/healthcheck.sh
|
2019-03-01 13:15:13 -08:00
|
|
|
sed -i \
|
|
|
|
-e 's!%%MARIADB_VERSION%%!'"$fullVersion"'!g' \
|
2021-07-13 10:27:06 +10:00
|
|
|
-e 's!%%MARIADB_VERSION_BASIC%%!'"$mariaVersion"'!g' \
|
2019-03-01 13:15:13 -08:00
|
|
|
-e 's!%%MARIADB_MAJOR%%!'"$version"'!g' \
|
|
|
|
-e 's!%%MARIADB_RELEASE_STATUS%%!'"$releaseStatus"'!g' \
|
2023-05-08 11:59:02 +10:00
|
|
|
-e 's!%%MARIADB_SUPPORT_TYPE%%!'"$supportType"'!g' \
|
2019-03-01 13:15:13 -08:00
|
|
|
-e 's!%%SUITE%%!'"$suite"'!g' \
|
2023-06-17 22:13:35 +02:00
|
|
|
-e 's!%%ARCHES%%! '"$arches"'!g' \
|
2019-03-01 13:15:13 -08:00
|
|
|
"$version/Dockerfile"
|
|
|
|
|
2021-11-18 18:37:29 +11:00
|
|
|
# Start using the new executable names
|
2021-09-03 16:35:24 +10:00
|
|
|
case "$version" in
|
2023-05-11 12:11:51 +10:00
|
|
|
10.4)
|
MDEV-29762: Add capability for replication
These are controled by:
* MARIADB_MASTER_HOST - if specified, the master, and the container is a replica
* MARIADB_REPLICATION_PORT - port number
* MARIADB_REPLICATION_USER - create or use this user
* MARIADB_REPLICATION_PASSWORD - create or use this password
* MARIADB_REPLICATION_PASSWORD_HASH (on master only)
If MARIADB_MASTER_HOST isn't specified, the container is a master. In
this case, the MARIADB_REPLICATION_USER is created, with password{,hash},
and given the REPLICATION REPLICA grant, or REPLICATION SLAVE (for
10.3, 10.4).
If the MARIADB_MASTER_HOST is specified, CHANGE MASTER TO is used to
connect to the MARIADB_MASTER_HOST:MARIADB_MASTER_PORT(default 3306)
using the MARIADB_REPLICATION_USER. As the password is needed
MARIADB_REPLICATION_PASSWORD_HASH cannot be used on a replica.
CHANGE MASTER TO is executed with MASTER_CONNECT_RETRY=10 and the
replica is started by default.
The creation of the replication user is replicated along with the
master's /docker-entrypoint-initdb.d/ contents and MARIADB_DATABASE
/MARIADB_USER. The MARIADB_MYSQL_LOCALHOST_USER isn't replicated and
neither is the timezone data.
Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
Reviewed-by: Daniel Black <daniel@mariadb.org>
2023-04-01 01:02:21 +05:30
|
|
|
sed -i -e '/--old-mode/d' \
|
|
|
|
-e 's/REPLICATION REPLICA/REPLICATION SLAVE/' \
|
2023-11-28 18:34:50 +01:00
|
|
|
-e 's/START REPLICA/START SLAVE/' \
|
MDEV-29762: Add capability for replication
These are controled by:
* MARIADB_MASTER_HOST - if specified, the master, and the container is a replica
* MARIADB_REPLICATION_PORT - port number
* MARIADB_REPLICATION_USER - create or use this user
* MARIADB_REPLICATION_PASSWORD - create or use this password
* MARIADB_REPLICATION_PASSWORD_HASH (on master only)
If MARIADB_MASTER_HOST isn't specified, the container is a master. In
this case, the MARIADB_REPLICATION_USER is created, with password{,hash},
and given the REPLICATION REPLICA grant, or REPLICATION SLAVE (for
10.3, 10.4).
If the MARIADB_MASTER_HOST is specified, CHANGE MASTER TO is used to
connect to the MARIADB_MASTER_HOST:MARIADB_MASTER_PORT(default 3306)
using the MARIADB_REPLICATION_USER. As the password is needed
MARIADB_REPLICATION_PASSWORD_HASH cannot be used on a replica.
CHANGE MASTER TO is executed with MASTER_CONNECT_RETRY=10 and the
replica is started by default.
The creation of the replication user is replicated along with the
master's /docker-entrypoint-initdb.d/ contents and MARIADB_DATABASE
/MARIADB_USER. The MARIADB_MYSQL_LOCALHOST_USER isn't replicated and
neither is the timezone data.
Signed-off-by: MdSahil-oss <Mohdssahil1@gmail.com>
Reviewed-by: Daniel Black <daniel@mariadb.org>
2023-04-01 01:02:21 +05:30
|
|
|
"$version/docker-entrypoint.sh"
|
2023-06-20 16:39:17 +10:00
|
|
|
sed -i -e 's/ REPLICA\$/ SLAVE$/' "$version"/healthcheck.sh
|
2023-10-01 09:27:37 +03:00
|
|
|
sed -i -e 's/\/run/\/var\/run\//g' "$version/Dockerfile"
|
2023-11-28 18:34:50 +01:00
|
|
|
;; # almost nothing to see/do here
|
2021-03-02 15:00:11 +11:00
|
|
|
10.5)
|
2022-11-30 14:17:28 +11:00
|
|
|
sed -i -e '/--old-mode/d' "$version/docker-entrypoint.sh"
|
2021-03-02 15:00:11 +11:00
|
|
|
sed -i '/backwards compat/d' "$version/Dockerfile"
|
|
|
|
;;
|
2021-11-18 18:37:29 +11:00
|
|
|
*)
|
2021-03-02 15:00:11 +11:00
|
|
|
sed -i -e '/^CMD/s/mysqld/mariadbd/' \
|
2023-11-28 18:34:50 +01:00
|
|
|
-e '/backwards compat/d' "$version/Dockerfile"
|
2021-11-18 18:37:29 +11:00
|
|
|
sed -i -e 's/mysql_upgrade\([^_]\)/mariadb-upgrade\1/' \
|
2023-11-28 18:34:50 +01:00
|
|
|
-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 's/mysql_tzinfo_to_sql/mariadb-tzinfo-to-sql/' \
|
|
|
|
"$version/docker-entrypoint.sh"
|
2023-11-24 16:13:56 +11:00
|
|
|
if [ "$version" = 10.6 ]; then
|
2023-10-21 10:10:37 +11:00
|
|
|
# my_print_defaults didn't recognise --mysqld until 10.11
|
|
|
|
sed -i -e '0,/#ENDOFSUBSTITUTIONS/s/\([^-]\)mysqld/\1mariadbd/g' \
|
|
|
|
"$version/docker-entrypoint.sh"
|
|
|
|
else
|
|
|
|
sed -i -e '0,/#ENDOFSUBSTITUTIONS/s/\mysqld/mariadbd/g' \
|
|
|
|
"$version/docker-entrypoint.sh"
|
|
|
|
fi
|
2022-03-07 16:34:11 +11:00
|
|
|
sed -i -e '0,/#ENDOFSUBSTITUTIONS/s/\bmysql\b/mariadb/' "$version/healthcheck.sh"
|
2022-10-14 14:33:54 +11:00
|
|
|
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
|
2023-03-24 11:35:52 +11:00
|
|
|
if [[ $version =~ 11.[012345] ]]; then
|
2023-02-07 18:53:21 +11:00
|
|
|
sed -i -e 's/mysql_upgrade_info/mariadb_upgrade_info/' \
|
|
|
|
"$version/docker-entrypoint.sh" "$version/healthcheck.sh"
|
|
|
|
fi
|
2023-07-17 11:53:44 +10:00
|
|
|
if [[ $version =~ 11.[01] ]]; then
|
|
|
|
sed -i -e 's/50-mysqld_safe.cnf/50-mariadb_safe.cnf/' "$version/Dockerfile"
|
|
|
|
fi
|
2022-10-14 14:33:54 +11:00
|
|
|
;&
|
2023-11-28 18:34:50 +01:00
|
|
|
esac
|
2023-06-17 22:13:35 +02:00
|
|
|
|
2023-11-28 18:34:50 +01:00
|
|
|
# Add version to versions.json
|
|
|
|
versionJson="$(jq -e \
|
|
|
|
--arg milestone "$version" --arg version "$mariaVersion" --arg fullVersion "$fullVersion" --arg releaseStatus "$releaseStatus" --arg supportType "$supportType" --arg base "ubuntu:$suite" --arg arches "$arches" \
|
|
|
|
'.[$milestone] = {"milestone": $milestone, "version": $version, "fullVersion": $fullVersion, "releaseStatus": $releaseStatus, "supportType": $supportType, "base": $base, "arches": $arches|split(" ")}' versions.json)"
|
|
|
|
printf '%s\n' "$versionJson" > versions.json
|
2021-03-02 15:00:11 +11:00
|
|
|
}
|
|
|
|
|
2023-05-08 11:59:02 +10:00
|
|
|
update_version_array()
|
|
|
|
{
|
|
|
|
c0=$(( $1 - 2 ))
|
|
|
|
c1=$(( $1 - 1 ))
|
2023-06-17 21:57:27 +02:00
|
|
|
version=${release[$c0]}
|
2023-05-08 11:59:02 +10:00
|
|
|
if [ ! -d "$version" ]; then
|
|
|
|
echo >&2 "warning: no rule for $version"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
mariaversion
|
|
|
|
|
2023-06-17 21:57:27 +02:00
|
|
|
releaseStatus=${release[$c1]}
|
2023-05-08 11:59:02 +10:00
|
|
|
|
|
|
|
case "$releaseStatus" in
|
|
|
|
Alpha | Beta | Gamma | RC | Stable ) ;; # sanity check
|
|
|
|
*) echo >&2 "error: unexpected 'release status' value for $mariaVersion: $releaseStatus"; ;;
|
|
|
|
esac
|
|
|
|
|
2023-06-17 21:57:27 +02:00
|
|
|
supportType=$2
|
2023-05-08 11:59:02 +10:00
|
|
|
|
|
|
|
update_version
|
|
|
|
}
|
|
|
|
|
2023-11-28 18:34:50 +01:00
|
|
|
mariaversion()
|
|
|
|
{
|
|
|
|
mariaVersion=$(curl -fsSL "$DOWNLOADS_REST_API/mariadb/${version}" \
|
|
|
|
| jq -r 'first(.releases[]).release_id')
|
2021-03-02 15:00:11 +11:00
|
|
|
}
|
2021-11-18 18:37:29 +11:00
|
|
|
|
2021-03-02 15:00:11 +11:00
|
|
|
all()
|
|
|
|
{
|
2023-06-17 22:13:35 +02:00
|
|
|
printf '%s\n' "{}" > versions.json
|
|
|
|
|
2023-05-08 11:59:02 +10:00
|
|
|
readarray -O 0 -c 3 -C update_version_array -t release <<< "$(curl -fsSL "$DOWNLOADS_REST_API/mariadb/" \
|
2023-06-17 21:57:27 +02:00
|
|
|
| jq -r '.major_releases[] | [ .release_id ], [ .release_status ], [ .release_support_type ] | @tsv')"
|
2021-03-02 15:00:11 +11:00
|
|
|
}
|
|
|
|
|
2023-11-15 10:33:34 +11:00
|
|
|
development_version=11.4
|
2021-03-02 15:00:11 +11:00
|
|
|
|
|
|
|
in_development()
|
|
|
|
{
|
|
|
|
releaseStatus=Alpha
|
2023-05-08 11:59:02 +10:00
|
|
|
supportType=Unknown
|
2021-03-02 15:00:11 +11:00
|
|
|
version=$development_version
|
|
|
|
mariaVersion=${development_version}.0
|
2022-03-31 22:17:13 +11:00
|
|
|
[ -d "$development_version" ] && update_version
|
2021-03-02 15:00:11 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2023-05-08 11:59:02 +10:00
|
|
|
readarray -t release <<< "$(curl -fsSL "$DOWNLOADS_REST_API/mariadb/" \
|
2023-06-17 21:57:27 +02:00
|
|
|
| jq -r --arg version "$version" '.major_releases[] | select(.release_id == $version) | [ .release_status ] , [ .release_support_type ] | @tsv')"
|
|
|
|
releaseStatus=${release[0]}
|
|
|
|
supportType=${release[1]}
|
2023-02-17 10:52:34 +01:00
|
|
|
|
2021-03-02 15:00:11 +11:00
|
|
|
update_version
|
2014-11-24 15:31:55 -08:00
|
|
|
done
|