2012-01-23 12:20:16 +01:00
#!/usr/bin/make -f
export DH_VERBOSE=1
2016-10-09 22:39:01 +02:00
# enable Debian Hardening
# see: https://wiki.debian.org/Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
BUILDDIR := builddir
2012-01-23 12:20:16 +01:00
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
2016-10-09 22:39:01 +02:00
DEB_BUILD_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEBVERSION := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }' | sed 's/^.*-//' )
2012-01-23 12:20:16 +01:00
DEB_SOURCE_PACKAGE ?= $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))
DEB_VERSION ?= $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DEB_NOEPOCH_VERSION ?= $(shell echo $(DEB_VERSION) | cut -d: -f2-)
DEB_UPSTREAM_VERSION ?= $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
DEB_UPSTREAM_VERSION_MAJOR_MINOR := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -r -n 's/^([0-9]+\.[0-9]+).*/\1/p')
2016-10-09 22:39:01 +02:00
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DISTRIBUTION := $(shell lsb_release -i -s)
RELEASE := $(shell lsb_release -r -s)
TMP:=$(CURDIR)/debian/tmp
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
CC := $(DEB_HOST_GNU_TYPE)-gcc
CXX := $(DEB_HOST_GNU_TYPE)-g++
2012-01-23 12:20:16 +01:00
2016-08-18 10:47:20 +02:00
# Parallel build support as advised
# at https://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j $(NUMJOBS)
2016-10-09 22:39:01 +02:00
else
# NUMJOBS cannot be empty as it is used as a parameter to mtr, default to 1.
NUMJOBS = 1
2012-01-23 12:20:16 +01:00
endif
2016-10-09 22:39:01 +02:00
# Ignore test suite exit code on unstable platforms
ifneq (,$(filter $(ARCH), mips mipsel))
TESTSUITE_FAIL_CMD:=true
else
TESTSUITE_FAIL_CMD:=exit 1
2012-01-23 12:20:16 +01:00
endif
2016-10-09 22:39:01 +02:00
# Skip TokuDB if arch is not amd64
ifneq ($(ARCH), amd64)
CMAKEFLAGS += -DWITHOUT_TOKUDB=true
2012-01-23 12:20:16 +01:00
endif
2016-10-09 22:39:01 +02:00
# Add support for verbose builds
MAKEFLAGS += VERBOSE=1
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_auto_clean:
2012-01-23 12:20:16 +01:00
@echo "RULES.$@"
dh_testdir
dh_testroot
[ ! -d mysql-test/var ] || rm -rf mysql-test/var
rm -rf $(BUILDDIR)
2016-10-09 22:39:01 +02:00
debconf-updatepo # Update po-files when clean runs before each build
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_prep:
# Don't clean /tmp/ away, it is needed by all binary packages
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_auto_configure:
2012-01-23 12:20:16 +01:00
@echo "RULES.$@"
dh_testdir
2016-10-09 22:39:01 +02:00
# Versioned symbols are only available on Linux.
# Remove symbols file on kFreeBSD builds so that
# dpkg-gensymbols will not fail the build.
ifneq (,$(filter $(ARCH), kfreebsd-i386 kfreebsd-amd64))
rm debian/libmariadbclient18.symbols
endif
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && \
sh -c 'PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \
CC=${CC} \
CXX=${CXX} \
cmake -DCMAKE_INSTALL_PREFIX=/usr \
$(CMAKEFLAGS) \
-DCOMPILATION_COMMENT="mariadb.org binary distribution" \
-DMYSQL_SERVER_SUFFIX="-$(DEBVERSION)" \
-DSYSTEM_TYPE="debian-$(DEB_BUILD_GNU_SYSTEM)" \
-DCMAKE_SYSTEM_PROCESSOR=$(DEB_BUILD_ARCH) \
-DBUILD_CONFIG=mysql_release \
-DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
-DINSTALL_PLUGINDIR=lib/mysql/plugin \
-DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test \
-DDEB=$(DISTRIBUTION) ..'
touch $@
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
# This is needed, otherwise 'make test' will run before binaries have been built
override_dh_auto_build:
@echo "RULES.$@"
# Print build env info to help debug builds on different platforms
dpkg-architecture
cd $(BUILDDIR) && $(MAKE)
touch $@
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_auto_test:
@echo "RULES.$@"
dh_testdir
# Skip unstable tests if such are defined for arch
[ ! -f debian/unstable-tests.$(ARCH) ] || cat debian/unstable-tests.$(ARCH) >> mysql-test/unstable-tests
# Run testsuite
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
cd $(BUILDDIR)/mysql-test && ./mtr --force --mem --parallel=$(NUMJOBS) --skip-rpl --suite=main --skip-test-list=unstable-tests || $(TESTSUITE_FAIL_CMD) ;
endif
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_auto_install:
@echo "RULES.$@"
dh_testdir
dh_testroot
2012-01-26 12:55:12 +01:00
2016-10-09 22:39:01 +02:00
# If TokuDB plugin was not built skip the package
2016-10-09 17:00:57 +02:00
[ -f $(BUILDDIR)/storage/tokudb/ha_tokudb.so ] || sed -i -e "/Package: mariadb-plugin-tokudb/,+14d" debian/control
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
# If Mroonga plugin was not built skip the package
2016-10-09 17:00:57 +02:00
[ -f $(BUILDDIR)/storage/mroonga/ha_mroonga.so ] || sed -i -e "/Package: mariadb-plugin-mroonga/,+13d" debian/control
2012-01-23 12:20:16 +01:00
2016-10-09 15:48:17 +02:00
# If libthrift-dev was available (manually installed, as it is
# not in Debian) and ha_cassandra.so was thus built, create package,
# otherwise skip it.
2016-10-09 17:00:57 +02:00
[ -f $(BUILDDIR)/storage/cassandra/ha_cassandra.so ] || sed -i -e "/Package: mariadb-plugin-cassandra/,+16d" debian/control
2016-10-09 15:48:17 +02:00
# If Spider plugin was not built skip the package
2016-10-09 17:00:57 +02:00
[ -f $(BUILDDIR)/storage/spider/ha_spider.so ] || sed -i -e "/Package: mariadb-plugin-spider/,+14d" debian/control
2016-10-09 15:48:17 +02:00
2016-10-09 22:39:01 +02:00
# make install
cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP)
2012-01-28 21:22:14 +01:00
2016-10-29 01:17:14 +02:00
# Delete runnable files we don't want to have in the test data package.
# This avoids triggering multiple Lintian errors.
rm -rf $(TMP)/usr/share/mysql/mysql-test/plugin/tokudb/tokudb/*.py
rm -rf $(TMP)/usr/share/mysql/mysql-test/plugin/tokudb/tokudb/t/*.py
2016-10-09 22:39:01 +02:00
# nm numeric soft is not enough, therefore extra sort in command
# to satisfy Debian reproducible build requirements
nm --defined-only $(BUILDDIR)/sql/mysqld | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.2/mysqld.sym.gz
2012-01-23 12:20:16 +01:00
2015-11-20 18:43:22 +01:00
# For 5.0 -> 10.2 transition
2012-01-23 12:20:16 +01:00
d=$(TMP)/usr/share/mysql-common/internal-use-only/; \
mkdir -p $$d; \
2015-11-20 18:43:22 +01:00
cp debian/mariadb-server-10.2.mysql.init $$d/_etc_init.d_mysql; \
cp debian/mariadb-server-10.2.mysql-server.logrotate $$d/_etc_logrotate.d_mysql-server; \
2012-01-23 12:20:16 +01:00
cp debian/additions/debian-start $$d/_etc_mysql_debian-start;
2016-10-09 22:39:01 +02:00
# rename and install AppArmor profile
2012-01-23 12:20:16 +01:00
install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld
# install Apport hook
2015-11-20 18:43:22 +01:00
install -D -m 644 debian/mariadb-server-10.2.py $(TMP)/usr/share/apport/package-hooks/source_mariadb-10.2.py
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
touch $@
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_installlogrotate-arch:
dh_installlogrotate --name mysql-server
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
# 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:
2016-10-10 10:28:26 +02:00
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
2016-10-09 22:39:01 +02:00
dh_installinit --name=mysql -- defaults 19 21
2016-10-10 10:28:26 +02:00
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
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
override_dh_installcron-arch:
dh_installcron --name mysql-server
2012-01-23 12:20:16 +01:00
get-orig-source:
2016-10-09 22:39:01 +02:00
uscan --force-download --verbose
2012-01-23 12:20:16 +01:00
2016-10-09 22:39:01 +02:00
%:
2016-10-11 16:26:22 +02:00
dh $@ --parallel --with dpatch
2012-01-23 12:20:16 +01:00
# vim: ts=8