Commit ec09c034 authored by Tuukka Pasanen's avatar Tuukka Pasanen Committed by Daniel Black

MDEV-33852: Rework systemd installation on Debian

Let dh_systemd handle most of the systemd side and
get rid of custom scripts

Rework installation of systemd service and socket files
base on Michael Biebl merge request:

https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/63
https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/75
parent 7ff64931
......@@ -5,7 +5,7 @@ Maintainer: MariaDB Developers <developers@lists.mariadb.org>
Build-Depends: bison,
cmake,
cracklib-runtime <!nocheck>,
debhelper (>= 10),
debhelper (>= 11),
dh-exec,
flex [amd64],
gdb <!nocheck>,
......
......@@ -11,6 +11,10 @@ lib/*/security/pam_user_map.so
lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
lib/systemd/system/mysql.service
lib/systemd/system/mysqld.service
usr/share/mysql/systemd/mariadb-extra@.socket
usr/share/mysql/systemd/mariadb.service
usr/share/mysql/systemd/mariadb@.service
usr/share/mysql/systemd/mariadb@.socket
support-files/rpm/enable_encryption.preset etc/mysql/mariadb.conf.d/99-enable-encryption.cnf.preset
usr/bin/aria_chk
usr/bin/aria_dump_log
......
......@@ -285,28 +285,5 @@ esac
db_stop # in case invoke fails
# dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb.
# Thus MariaDB server is started via init.d script, which in turn redirects to
# systemctl. If we upgrade from MySQL mysql.service may be masked, which also
# means init.d script is disabled. Unmask mysql service explicitly.
# Check first that the command exists, to avoid emitting any warning messages.
if [ -x "$(command -v deb-systemd-helper)" ]
then
deb-systemd-helper unmask mysql.service > /dev/null
fi
#DEBHELPER#
# Modified dh_systemd_start snippet that's not added automatically
if [ -d /run/systemd/system ]
then
systemctl --system daemon-reload >/dev/null || true
deb-systemd-invoke start mariadb.service >/dev/null || true
# Modified dh_installinit snippet to only run with sysvinit
elif [ -x "/etc/init.d/mariadb" ]
then
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]
then
invoke-rc.d mariadb start || exit $?
fi
fi
......@@ -12,50 +12,7 @@ fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
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! Another mariadbd in e.g. a different chroot is fine for us.
stop_server() {
# Return immediately if there are no mysqld processes running
# as there is no point in trying to shutdown in that case.
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
then
return
fi
set +e
invoke-rc.d mariadb stop
invoke-rc.d mysql stop # Backwards compatibility
errno=$?
set -e
# systemctl could emit exit code 100=no init script (fresh install)
if [ "$errno" != 0 ] && [ "$errno" != 100 ]
then
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
echo "Stop it yourself and try again!" 1>&2
db_stop
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
;;
*)
echo "postrm called with unknown argument '$1'" 1>&2
exit 1
;;
esac
#DEBHELPER#
#
# - Purge logs and data only if they are ours (#307473)
......
#!/bin/sh
set -e
#DEBHELPER#
# Modified dh_systemd_start snippet that's not added automatically
if [ -d /run/systemd/system ]
then
deb-systemd-invoke stop mariadb.service >/dev/null
# Modified dh_installinit snippet to only run with sysvinit
elif [ -x "/etc/init.d/mariadb" ]
then
invoke-rc.d mariadb stop || exit $?
fi
......@@ -64,10 +64,6 @@ usr/share/mysql/policy/selinux/README # In MariaDB we don't want to use SELinux
usr/share/mysql/policy/selinux/mariadb-server.fc # In MariaDB we don't want to use SELinux at the moment
usr/share/mysql/policy/selinux/mariadb-server.te # In MariaDB we don't want to use SELinux at the moment
usr/share/mysql/policy/selinux/mariadb.te # In MariaDB we don't want to use SELinux at the moment
usr/share/mysql/systemd/mariadb-extra@.socket # Installed by rules file
usr/share/mysql/systemd/mariadb.service # Installed by rules file
usr/share/mysql/systemd/mariadb@.service # Installed by rules file
usr/share/mysql/systemd/mariadb@.socket # Installed by rules file
usr/share/mysql/systemd/mysql.service # Installed by rules file
usr/share/mysql/systemd/mysqld.service # Installed by rules file
usr/share/mysql/systemd/use_galera_new_cluster.conf
......@@ -126,16 +126,6 @@ override_dh_auto_install:
dh_testdir
dh_testroot
ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
# Copy systemd files to a location available for dh_installinit
cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server.mariadb.service
cp $(BUILDDIR)/support-files/mariadb.socket debian/mariadb-server.mariadb.socket
cp $(BUILDDIR)/support-files/mariadb-extra.socket debian/mariadb-server.mariadb-extra.socket
cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server.mariadb@.service
cp $(BUILDDIR)/support-files/mariadb@.socket debian/mariadb-server.mariadb@.socket
cp $(BUILDDIR)/support-files/mariadb-extra@.socket debian/mariadb-server.mariadb-extra@.socket
endif
# Run 'make install' without output since it is uninteresting and
# silencing it helps to make overall build log shorter and more readable
@echo "Running $(MAKE) install DESTDIR=$(TMP) ..."
......@@ -178,8 +168,8 @@ endif
# Move test plugins that are only needed by the client to the libmariadb path
mv -v $(TMP)/usr/lib/mysql/plugin/qa_auth_client.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/
override_dh_systemd_enable:
dh_systemd_enable --name=mariadb
override_dh_installsystemd:
dh_systemd_enable --name=mariadb mariadb.service
dh_systemd_enable --no-enable --name=mariadb mariadb.socket
dh_systemd_enable --no-enable --name=mariadb-extra mariadb-extra.socket
dh_systemd_enable --no-enable --name=mariadb@ mariadb.socket
......
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