Commit 13c2fd36 authored by Otto Kekäläinen's avatar Otto Kekäläinen

Deb: Implement proper version detection in maintainer scripts

Fixes bug introduced in commit 54150029.

Using script run-time filename does not always work. One cannot assume
that the filename is always the same as there might be temporary file
names used by dpkg in certain situations. See Debian #920415.

The same fix has been successfully in use in Debian official packages
since February 2019:
https://salsa.debian.org/mariadb-team/mariadb-10.3/commit/6440c0d6e75
parent 8a79fa0e
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# assume the filename is /path/to/mariadb-server-##.#.postinst # Automatically set version to ease maintenance of this file
VER=${0: -13:4} MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
...@@ -11,7 +11,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ...@@ -11,7 +11,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin 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. # 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-$VER.postinst -i" ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i"
# This will make an error in a logged command immediately apparent by aborting # This will make an error in a logged command immediately apparent by aborting
# the install, rather than failing silently and leaving a broken install. # the install, rather than failing silently and leaving a broken install.
set -o pipefail set -o pipefail
...@@ -134,7 +134,7 @@ EOF ...@@ -134,7 +134,7 @@ EOF
db_set mysql-server/postrm_remove_database false || true db_set mysql-server/postrm_remove_database false || true
# To avoid downgrades. # To avoid downgrades.
touch $mysql_statedir/debian-$VER.flag touch $mysql_statedir/debian-$MAJOR_VER.flag
## On every reconfiguration the maintenance user is recreated. ## On every reconfiguration the maintenance user is recreated.
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment