Skip to content
Snippets Groups Projects
Commit 6440c0d6 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Implement proper version detection in maintainer scripts (Closes: #920415)

Fixes regression introduced by changes in commit 6b1f48b3.
parent 6452ba6a
No related branches found
Tags v4.0.0
No related merge requests found
Pipeline #37243 failed with stages
in 2 hours
......@@ -3,10 +3,8 @@ set -e
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file.
# Assume the filename is /path/to/mariadb-server-##.#.postinst
# Pick version string based on location. Python equivalent would be x[-13:-9].
VERSION=${0: -13:4}
# Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
......@@ -14,7 +12,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
ERR_LOGGER="logger -p daemon.err -t mariadb-server-$VERSION.postinst -i"
ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i"
# Specify syslog tag name so it is clear the entry came from this postinst script.
# This will make an error in a logged command immediately apparent by aborting
# the install, rather than failing silently and leaving a broken install.
......@@ -98,7 +96,7 @@ EOF
# Clean up old flags before setting new one
rm -f $mysql_datadir/debian-*.flag
# Flag data dir to avoid downgrades
touch $mysql_datadir/debian-$VERSION.flag
touch $mysql_datadir/debian-$MAJOR_VER.flag
# initiate databases. Output is not allowed by debconf :-(
# This will fail if we are upgrading an existing database; in this case
......
......@@ -3,10 +3,8 @@ set -e
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file.
# Assume the filename is /path/to/mariadb-server-##.#.postrm
# Pick version string based on location. Python equivalent would be x[-11:-7].
VERSION=${0: -11:4}
# Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
......@@ -16,14 +14,14 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
# - Remove the mysql user only after all his owned files are purged.
# - Cleanup the initscripts only if this was the last provider of them
#
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-$VERSION.flag" ]; then
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-$MAJOR_VER.flag" ]; then
# we remove the mysql user only after all his owned files are purged
rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
rm -rf /var/log/mysql
db_input high mariadb-server-$VERSION/postrm_remove_databases || true
db_input high mariadb-server-$MAJOR_VER/postrm_remove_databases || true
db_go || true
db_get mariadb-server-$VERSION/postrm_remove_databases || true
db_get mariadb-server-$MAJOR_VER/postrm_remove_databases || true
if [ "$RET" = "true" ]; then
# never remove the debian.cnf when the databases are still existing
# else we ran into big trouble on the next install!
......
......@@ -9,10 +9,8 @@
. /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file.
# Assume the filename is /path/to/mariadb-server-##.#.preinst
# Pick version string based on location. Python equivalent would be x[-12:-8].
VERSION=${0: -12:4}
# Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
# Just kill the invalid insserv.conf.d directory without fallback
if [ -d "/etc/insserv.conf.d/mariadb/" ]; then
......@@ -28,7 +26,7 @@ mysql_upgradedir=/var/lib/mysql-upgrade
################################ main() ##########################
this_version=$VERSION
this_version=$MAJOR_VER
max_upgradeable_version=5.7
# Check if a flag file is found that indicates a previous MariaDB or MySQL
......@@ -92,7 +90,7 @@ fi
# Instead simply move the old datadir and create a new for this_version.
if [ ! -z "$downgrade_detected" ]
then
db_input critical mariadb-server-$VERSION/old_data_directory_saved || true
db_input critical mariadb-server-$MAJOR_VER/old_data_directory_saved || true
db_go
echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2
echo "version that cannot automatically be upgraded. Therefore the" 1>&2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment