Skip to content
Permalink
Browse files
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.
  • Loading branch information
ottok committed Oct 29, 2016
1 parent 7316b14 commit c912d05fab9db5829c403432fddece257c75ece0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
@@ -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
@@ -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")
@@ -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
@@ -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,
@@ -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
@@ -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

0 comments on commit c912d05

Please sign in to comment.