File: //var/lib/dpkg/info/mysql-apt-config.config
#!/bin/bash
# Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
. /usr/share/debconf/confmodule
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ];
then
db_get mysql-apt-config/repo-distro && DISTRO=${RET}
db_get mysql-apt-config/repo-codename && DISTRO_VERSION=${RET}
if [ -z "${DISTRO}" ]; then
DISTRO=$(lsb_release -is | tr 'A-Z' 'a-z')
fi
if [ -z "${DISTRO_VERSION}" ]; then
DISTRO_VERSION=$(lsb_release -cs)
fi
db_get mysql-apt-config/repo-url && REPO_URL_BASE=${RET}
db_get mysql-apt-config/select-connectors && DEFAULT_CONNECTORS=${RET}
db_get mysql-apt-config/select-server && DEFAULT_VERSION=${RET}
# If server version was not previously selected,
# and mysql-server is already installed, we pick the closest available version as the default
if [ -z "${DEFAULT_VERSION}" ];
then
INSTALLED_SERVER=$(dpkg -s mysql-server mysql-community-server mysql-commercial-server 2> /dev/null | grep Version: | cut -d' ' -f2 | cut -d. -f-2| tail -n1)
if [ "${INSTALLED_SERVER}" = "8.0" ];
then
INSTALLED_VERSION="MySQL Server 8.0"
DEFAULT_VERSION="mysql-8.0"
elif [ "${INSTALLED_SERVER}" = "9.3" ];
then
INSTALLED_VERSION="MySQL Server 9.3"
DEFAULT_VERSION="mysql-innovation"
elif [ "${INSTALLED_SERVER}" = "8.4" ];
then
INSTALLED_VERSION="MySQL Server 8.4"
DEFAULT_VERSION="mysql-8.4-lts"
elif [ "${INSTALLED_SERVER}" = "5.7" ];
then
INSTALLED_VERSION="MySQL Server 5.7"
DEFAULT_VERSION="mysql-5.7"
elif [ "${INSTALLED_SERVER}" = "7.5" ];
then
INSTALLED_VERSION="MySQL Cluster 7.5"
DEFAULT_VERSION="mysql-cluster-7.5"
elif [ "${INSTALLED_SERVER}" = "7.6" ];
then
INSTALLED_VERSION="MySQL Cluster 7.6"
DEFAULT_VERSION="mysql-cluster-7.6"
else
INSTALLED_VERSION="no MySQL Server"
DEFAULT_VERSION="mysql-8.4-lts"
fi
else
INSTALLED_VERSION="${DEFAULT_VERSION}"
fi
if [ "${DEBIAN_FRONTEND}" = "noninteractive" ];
then
if [ ! -z "${MYSQL_REPO_URL}" ];
then
REPO_URL_BASE=${MYSQL_REPO_URL}
fi
if [ ! -z "${MYSQL_SERVER_VERSION}" ];
then
DEFAULT_VERSION=${MYSQL_SERVER_VERSION}
fi
if [ ! -z "${MYSQL_CONNECTORS}" ];
then
DEFAULT_CONNECTORS=${MYSQL_CONNECTORS}
else
DEFAULT_CONNECTORS="mysql-tools"
fi
db_set mysql-apt-config/repo-distro ${DISTRO}
db_set mysql-apt-config/repo-codename ${DISTRO_VERSION}
db_set mysql-apt-config/select-server ${DEFAULT_VERSION}
db_set mysql-apt-config/connectors-component ${DEFAULT_TOOLS}
db_set mysql-apt-config/repo-url ${REPO_URL_BASE}
exit 0
fi
set -e
SUPPORTED_DISTROS="ubuntulunar ubuntufocal ubuntujammy ubuntunoble ubuntuoracular ubuntuplucky debianbookworm debiantrixie"
db_set mysql-apt-config/repo-distro ${DISTRO}
db_set mysql-apt-config/repo-codename ${DISTRO_VERSION}
db_go
if [[ ! ${SUPPORTED_DISTROS} =~ (^| )${DISTRO}${DISTRO_VERSION}($| ) ]];
then
db_subst mysql-apt-config/unsupported-platform platform "${DISTRO} ${DISTRO_VERSION}"
db_input high mysql-apt-config/unsupported-platform || true
db_go
db_get mysql-apt-config/unsupported-platform && UNSUPPORTED_RESPONSE=${RET}
if [ "${UNSUPPORTED_RESPONSE}" = "abort" ];
then
exit 0 # Skip the rest
else
DISTRO=$(echo $UNSUPPORTED_RESPONSE | cut -d' ' -f1)
DISTRO_VERSION=$(echo $UNSUPPORTED_RESPONSE | cut -d' ' -f2)
db_set mysql-apt-config/repo-distro ${DISTRO}
db_set mysql-apt-config/repo-codename ${DISTRO_VERSION}
db_go
fi
fi
case ${DISTRO_VERSION} in
focal)
SERVER_VERSIONS="mysql-8.0, mysql-cluster-8.0"
;;
lunar)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
jammy)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
bookworm)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
trixie)
SERVER_VERSIONS="mysql-innovation, mysql-8.4-lts, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
noble)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
oracular)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
plucky)
SERVER_VERSIONS="mysql-8.0, mysql-innovation, mysql-8.4-lts, mysql-cluster-8.0, mysql-cluster-innovation, mysql-cluster-8.4-lts"
;;
*)
SERVER_VERSIONS=""
;;
esac
db_subst mysql-apt-config/select-server server_versions ${SERVER_VERSIONS}
db_set mysql-apt-config/select-server ${DEFAULT_VERSION}
db_set mysql-apt-config/select-connectors ${DEFAULT_CONNECTORS}
db_fset mysql-apt-config/select-product seen false
db_fset mysql-apt-config/select-server seen false
db_fset mysql-apt-config/select-connectors seen false
db_subst mysql-apt-config/select-server installed_server ${INSTALLED_VERSION}
db_subst mysql-apt-config/select-product selected_server ${DEFAULT_VERSION}
db_subst mysql-apt-config/select-product selected_connectors ${DEFAULT_CONNECTORS}
SELECT_PRODUCT=${NULL}
while [ "${SELECT_PRODUCT}" != "Ok" ]
do
if [[ "${SELECT_PRODUCT}" =~ "Server & Cluster" ]];
then
db_input high mysql-apt-config/select-server || true
db_go
elif [[ "${SELECT_PRODUCT}" =~ "MySQL Connectors" ]];
then
db_input high mysql-apt-config/select-connectors || true
db_go
fi
SELECT_PRODUCT=${NULL}
db_set mysql-apt-config/select-product ""
db_get mysql-apt-config/select-connectors && CONNECTORS_ENABLED=${RET}
db_get mysql-apt-config/select-server && SERVER_SELECTED=${RET}
db_subst mysql-apt-config/select-product selected_server ${SERVER_SELECTED}
db_subst mysql-apt-config/select-product selected_connectors ${CONNECTORS_ENABLED}
db_input high mysql-apt-config/select-product || true
db_go
db_get mysql-apt-config/select-product && SELECT_PRODUCT=${RET}
if [ -z "${SELECT_PRODUCT}" ]; #TODO Is this even possible?
then
break;
fi
done
db_get mysql-apt-config/select-connectors && CONNECTORS_ENABLED=${RET}
if [ "${CONNECTORS_ENABLED}" = "Enabled" ];
then
db_set mysql-apt-config/connectors-component "mysql-tools"
else
db_set mysql-apt-config/connectors-component ${NULL}
fi
if [ "${SERVER_SELECTED}" = "None" ];
then
db_set mysql-apt-config/select-server ${NULL}
fi
if [ -z "${SELECT_PRODUCT}" ];
then
db_set mysql-apt-config/select-server ${NULL}
fi
set +e
fi