On Fri, Jan 27, 2017 at 11:52:34AM +0200, Otto Kekäläinen wrote: > Thanks Julian, you've done a very thorough job in producing and > documenting the patch.
And here is the patch for mysql-5.6, against the current git version on alioth (so diff against commit e6f3b698). Incidentally, the build give a lintian error (as well as numerous lintian warnings, which are easily fixed): E: mysql-server-5.6: depends-on-essential-package-without-using-version depends: bsdutils This can presumably be fixed by simply dropping the dependency on bsdutils; likewise the dependency on initscripts seems redundant. Best wishes, Julian
diff --git a/debian/mysql-server-5.6.lintian-overrides b/debian/mysql-server-5.6.lintian-overrides index e8c27b76..6f34209a 100644 --- a/debian/mysql-server-5.6.lintian-overrides +++ b/debian/mysql-server-5.6.lintian-overrides @@ -1,3 +1,5 @@ # These long lines reproduce actual output and to reformat them # would damage the integrity of the man page. mysql-server-5.6: manpage-has-errors-from-man usr/share/man/man1/mysqlbinlog.1.gz 1880: warning [p 12, 5.7i, div `3tbd3,2', 0.8i]: can't break line +# the second update-rc.d is informational only: see postrm for details +mysql-server-5.6: duplicate-updaterc.d-calls-in-postrm mysql diff --git a/debian/mysql-server-5.6.postinst b/debian/mysql-server-5.6.postinst old mode 100644 new mode 100755 index 0b552740..f8d77433 --- a/debian/mysql-server-5.6.postinst +++ b/debian/mysql-server-5.6.postinst @@ -12,14 +12,6 @@ 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 mysqld_safe -i" -invoke() { - if [ -x /usr/sbin/invoke-rc.d ]; then - invoke-rc.d mysql $1 - else - /etc/init.d/mysql $1 - fi -} - MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables" test_mysql_access() { @@ -60,7 +52,9 @@ EOF # and because changed configuration options should take effect immediately. # In case the server wasn't running at all it should be ok if the stop # script fails. I can't tell at this point because of the cleaned /var/run. -set +e; invoke stop; set -e +set +e +invoke-rc.d mysql stop +set -e case "$1" in configure) @@ -231,6 +225,24 @@ if [ "$1" = "configure" ]; then db_go fi + # Fix broken postrms in mysql-server-5.[1-5] and mariadb-server-10.[01] + # packages to prevent purging these packages from breaking our package. + # (See #852495) It is unlikely that a user would have mariadb-server + # postrm files lying around, but we aim to be safe. We do not touch + # mysql-server-5.7 postrm files, though, as we assume the sysadmin + # has not done a downgrade from mysql-server-5.7; if they have, they + # will probably have to have done a purge anyway. + + # We comment out all of the commands which assume that there is no other + # mysql server installed. + # (Because of the Conflicts in the control file for this package, they can + # only possibly be in a configuration-only state at this point. And this + # cannot harm even if the system is in a very broken state and we are being + # configured in spite of those packages being in a different state.) + olds=$(ls /var/lib/dpkg/info/mysql-server-5.[1-5].postrm /var/lib/dpkg/info/mariadb-server-10.[01].postrm 2>/dev/null || true) + if [ -n "$olds" ]; then + perl -i -pe 's/stop_server(?=\s|$)/# stop_server/; s/^(\s*)((?:update|invoke)-rc\.d.*$)/$1# $2\n$1true/; s/^(\s*)(deb-systemd-helper.*$)/$1# $2\n$1true/; s%rm -f "/etc/apparmor.d%# rm -f "/etc/apparmor.d%' $olds + fi fi db_stop # in case invoke failes diff --git a/debian/mysql-server-5.6.postrm b/debian/mysql-server-5.6.postrm old mode 100644 new mode 100755 index e3d5c887..41b402ff --- a/debian/mysql-server-5.6.postrm +++ b/debian/mysql-server-5.6.postrm @@ -11,34 +11,11 @@ if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } mysql_cfgdir=/etc/mysql -MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" - -# Try to stop the server in a sane way. If it does not success let the admin -# do it himself. No database directories should be removed while the server -# is running! -stop_server() { - set +e - if [ -x /usr/sbin/invoke-rc.d ]; then - invoke-rc.d mysql stop - else - /etc/init.d/mysql stop - fi - errno=$? - set -e - - if [ "$?" != 0 ]; then - echo "Trying to stop the MySQL server resulted in exitcode $?." 1>&2 - echo "Stop it yourself and try again!" 1>&2 - exit 1 - fi -} case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then - stop_server - sleep 2 - fi + # We handle purge actions below. The server has already been stopped + # if necessary by the prerm. ;; *) echo "postrm called with unknown argument '$1'" 1>&2 @@ -73,8 +50,56 @@ if [ "$1" = "purge" -a ! \( -x /usr/sbin/mysqld -o -L /usr/sbin/mysqld \) ]; the rm -rf /var/lib/mysql userdel mysql || true fi + + # Would have been automatically added by dh_installinit + update-rc.d mysql remove >/dev/null + + # Would have been automatically added by dh_systemd_enable + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper purge mysql.service >/dev/null + deb-systemd-helper unmask mysql.service >/dev/null + fi + + # Would have been automatically added by dh_apparmor + if ! [ -e "/etc/apparmor.d/usr.sbin.mysqld" ] ; then + rm -f "/etc/apparmor.d/disable/usr.sbin.mysqld" || true + rm -f "/etc/apparmor.d/force-complain/usr.sbin.mysqld" || true + rm -f "/etc/apparmor.d/local/usr.sbin.mysqld" || true + rmdir /etc/apparmor.d/disable 2>/dev/null || true + rmdir /etc/apparmor.d/local 2>/dev/null || true + rmdir /etc/apparmor.d 2>/dev/null || true + fi + # End automatically added section + fi -#DEBHELPER# +# Would have been automatically added by dh_installinit +# This is always safe to run here +# In case this system is running systemd, we make systemd reload the unit files +# to pick up changes. +if [ -d /run/systemd/system ] ; then + systemctl --system daemon-reload >/dev/null || true +fi +# End automatically added section + +# Would have been automatically added by dh_systemd_enable +if [ "$1" = "remove" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper mask mysql.service >/dev/null + fi +fi +# End automatically added section +# Would have been automatically added by dh_installdebconf +if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule + db_purge +fi +# End automatically added section exit 0 + +# We add the debhelper snippets here, after the exit 0, so that they can +# be visually checked in the future to ensure that nothing has been left +# out above. + +#DEBHELPER# diff --git a/debian/mysql-server-5.6.preinst b/debian/mysql-server-5.6.preinst old mode 100644 new mode 100755 index 09c65aaa..07b22335 --- a/debian/mysql-server-5.6.preinst +++ b/debian/mysql-server-5.6.preinst @@ -27,12 +27,7 @@ stop_server() { if [ ! -x /etc/init.d/mysql ]; then return; fi set +e - if [ -x /usr/sbin/invoke-rc.d ]; then - cmd="invoke-rc.d mysql stop" - else - cmd="/etc/init.d/mysql stop" - fi - $cmd + invoke-rc.d mysql stop errno=$? set -e