File: /var/lib/dpkg/info/mysql-apt-config.config
#!/bin/bash
# Copyright (c) 2014, 2018, 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-tools && DEFAULT_TOOLS=${RET}
db_get mysql-apt-config/select-preview && DEFAULT_PREVIEW=${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}" = "5.5" ];
then
INSTALLED_VERSION="MySQL Server 5.5"
DEFAULT_VERSION="mysql-5.6"
elif [ "${INSTALLED_SERVER}" = "5.6" ];
then
INSTALLED_VERSION="MySQL Server 5.6"
DEFAULT_VERSION="mysql-5.6"
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.0"
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_TOOLS}" ];
then
DEFAULT_TOOLS=${MYSQL_TOOLS}
else
DEFAULT_TOOLS="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/tools-component ${DEFAULT_TOOLS}
db_set mysql-apt-config/preview-component ${NULL}
db_set mysql-apt-config/repo-url ${REPO_URL_BASE}
exit 0
fi
set -e
SUPPORTED_DISTROS="ubuntutrusty ubuntuxenial ubuntubionic ubuntucosmic debianjessie debianstretch"
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
jessie)
SERVER_VERSIONS="mysql-5.6, mysql-5.7, mysql-cluster-7.5, mysql-cluster-7.6"
;;
stretch)
SERVER_VERSIONS="mysql-5.6, mysql-5.7, mysql-8.0, mysql-cluster-7.5, mysql-cluster-7.6"
;;
trusty)
SERVER_VERSIONS="mysql-5.6, mysql-5.7, mysql-cluster-7.5, mysql-cluster-7.6"
;;
xenial)
SERVER_VERSIONS="mysql-5.7, mysql-8.0, mysql-cluster-7.5, mysql-cluster-7.6"
;;
bionic)
SERVER_VERSIONS="mysql-5.7, mysql-8.0, mysql-cluster-7.5, mysql-cluster-7.6"
;;
cosmic)
SERVER_VERSIONS="mysql-5.7, mysql-8.0, mysql-cluster-7.5, mysql-cluster-7.6"
;;
*)
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-tools ${DEFAULT_TOOLS}
db_set mysql-apt-config/select-preview ${DEFAULT_PREVIEW}
db_fset mysql-apt-config/select-product seen false
db_fset mysql-apt-config/select-server seen false
db_fset mysql-apt-config/select-tools seen false
db_fset mysql-apt-config/select-preview 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_tools ${DEFAULT_TOOLS}
db_subst mysql-apt-config/select-product selected_preview ${DEFAULT_PREVIEW}
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}" =~ "Tools & Connectors" ]];
then
db_input high mysql-apt-config/select-tools || true
db_go
elif [[ "${SELECT_PRODUCT}" =~ "Preview Packages" ]];
then
db_input high mysql-apt-config/select-preview || true
db_go
fi
SELECT_PRODUCT=${NULL}
db_set mysql-apt-config/select-product ""
db_get mysql-apt-config/select-tools && TOOLS_ENABLED=${RET}
db_get mysql-apt-config/select-server && SERVER_SELECTED=${RET}
db_get mysql-apt-config/select-preview && PREVIEW_ENABLED=${RET}
db_subst mysql-apt-config/select-product selected_server ${SERVER_SELECTED}
db_subst mysql-apt-config/select-product selected_tools ${TOOLS_ENABLED}
db_subst mysql-apt-config/select-product selected_preview ${PREVIEW_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-tools && TOOLS_ENABLED=${RET}
if [ "${TOOLS_ENABLED}" = "Enabled" ];
then
db_set mysql-apt-config/tools-component "mysql-tools"
else
db_set mysql-apt-config/tools-component ${NULL}
fi
if [ "${PREVIEW_ENABLED}" = "Enabled" ];
then
db_set mysql-apt-config/preview-component "mysql-tools-preview"
else
db_set mysql-apt-config/preview-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