From c912d05fab9db5829c403432fddece257c75ece0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 29 Oct 2016 02:43:45 +0300 Subject: [PATCH] MDEV-6284: Install systemd files (almost) the Debian way The control file contents must be correct from the start and cannot be modified at build time by CMake. Also all static Debian package analyzers will fail to see all manipulations by CMake later on. It is best to do all manipulations like these in autobake-deb.sh. --- CMakeLists.txt | 6 ------ cmake/systemd.cmake | 6 ------ debian/autobake-deb.sh | 14 ++++++++++++++ debian/control | 2 ++ ...10.2.install.in => mariadb-server-10.2.install} | 5 ++++- debian/rules | 14 ++++++++++---- 6 files changed, 30 insertions(+), 17 deletions(-) rename debian/{mariadb-server-10.2.install.in => mariadb-server-10.2.install} (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54b3cbee939e9..b19b796621f50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -435,12 +435,6 @@ CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/info_macros.cmake.in ${CMAKE_BINARY_DIR}/info_macros.cmake @ONLY) -IF(DEB) - CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.2.install.in - ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.2.install) -ENDIF(DEB) - # Handle the "INFO_*" files. INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) # Source: This can be done during the cmake phase, all information is diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake index 1121fd64dce3b..9b51fb767998a 100644 --- a/cmake/systemd.cmake +++ b/cmake/systemd.cmake @@ -56,12 +56,6 @@ MACRO(CHECK_SYSTEMD) AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF) ADD_DEFINITIONS(-DHAVE_SYSTEMD) SET(SYSTEMD_SCRIPTS mariadb-service-convert galera_new_cluster galera_recovery) - SET(SYSTEMD_DEB_FILES "usr/bin/mariadb-service-convert - usr/bin/galera_new_cluster - usr/bin/galera_recovery - ${INSTALL_SYSTEMD_UNITDIR}/mariadb.service - ${INSTALL_SYSTEMD_UNITDIR}/mariadb@.service - ${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d/use_galera_new_cluster.conf") IF(DEB) SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld") SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start") diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index f8d313204d2da..1201e28009fcc 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -60,6 +60,20 @@ then sed '/libpcre3-dev/d' -i debian/control fi +# If libsystemd-dev is not available (before Debian Jessie or Ubuntu Wily) +# clean away the systemd stanzas so the package can build without them. +if ! apt-cache madison libsystemd-dev | grep 'libsystemd-dev' >/dev/null 2>&1 +then + sed '/dh-systemd/d' -i debian/control + sed '/libsystemd-dev/d' -i debian/control + sed 's/ --with systemd//' -i debian/rules + sed '/systemd/d' -i debian/rules + sed '/\.service/d' -i debian/rules + sed '/galera_new_cluster/d' -i debian/mariadb-server-10.2.install + sed '/galera_recovery/d' -i debian/mariadb-server-10.2.install + sed '/mariadb-service-convert/d' -i debian/mariadb-server-10.2.install +fi + # On Travis-CI, the log must stay under 4MB so make the build less verbose if [[ $TRAVIS ]] then diff --git a/debian/control b/debian/control index b9cfeff7684aa..cd36704ea634b 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Build-Depends: bison, cmake (>= 2.7), debhelper (>= 9), dh-apparmor, + dh-systemd, dpatch, libaio-dev [linux-any], libboost-dev, @@ -19,6 +20,7 @@ Build-Depends: bison, libpcre3-dev (>= 2:8.35-3.2~), libreadline-gplv2-dev, libssl-dev, + libsystemd-dev, libxml2-dev, libnuma-dev, lsb-release, diff --git a/debian/mariadb-server-10.2.install.in b/debian/mariadb-server-10.2.install similarity index 92% rename from debian/mariadb-server-10.2.install.in rename to debian/mariadb-server-10.2.install index fb435af3034a9..e8470b757c01a 100644 --- a/debian/mariadb-server-10.2.install.in +++ b/debian/mariadb-server-10.2.install @@ -63,4 +63,7 @@ usr/share/mysql/mysql_system_tables.sql usr/share/mysql/mysql_system_tables_data.sql usr/share/mysql/mysql_test_data_timezone.sql usr/share/mysql/wsrep_notify -@SYSTEMD_DEB_FILES@ +usr/bin/galera_new_cluster +usr/bin/galera_recovery +usr/bin/mariadb-service-convert +lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf diff --git a/debian/rules b/debian/rules index eca59c5b1f7a3..b0a4ceddca9c2 100755 --- a/debian/rules +++ b/debian/rules @@ -129,6 +129,10 @@ override_dh_auto_install: # If Spider plugin was not built skip the package [ -f $(BUILDDIR)/storage/spider/ha_spider.so ] || sed -i -e "/Package: mariadb-plugin-spider/,+14d" debian/control + # Copy systemd files to a location available for dh_installinit + cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.2.mariadb.service + cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.2.mariadb@.service + # make install cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP) @@ -158,13 +162,15 @@ override_dh_auto_install: override_dh_installlogrotate-arch: dh_installlogrotate --name mysql-server +override_dh_systemd_enable: + dh_systemd_enable --name=mariadb + dh_systemd_enable --no-enable --name=mariadb@ + # Start mysql at sequence number 19 before 20 where apache, proftpd etc gets # started which might depend on a running database server. override_dh_installinit-arch: - if [ -x /usr/bin/dh_systemd_enable -a -f debian/mariadb-server-10.2/lib/systemd/system/mariadb.service ]; then dh_systemd_enable -pmariadb-server-10.2 mariadb.service; fi - if [ -x /usr/bin/dh_systemd_enable -a -f debian/mariadb-server-10.2/lib/systemd/system/mariadb@.service ]; then dh_systemd_enable --no-enable -pmariadb-server-10.2 mariadb@.service; fi dh_installinit --name=mysql -- defaults 19 21 - if [ -x /usr/bin/dh_systemd_start -a -f debian/mariadb-server-10.2/lib/systemd/system/mariadb.service ]; then dh_systemd_start -pmariadb-server-10.2 --restart-after-upgrade mariadb.service; fi + dh_systemd_start --restart-after-upgrade override_dh_installcron-arch: dh_installcron --name mysql-server @@ -173,6 +179,6 @@ get-orig-source: uscan --force-download --verbose %: - dh $@ --parallel --with dpatch + dh $@ --parallel --with dpatch --with systemd # vim: ts=8