1#!/usr/bin/make -f 2 3export DH_VERBOSE=1 4export DEB_BUILD_HARDENING=1 5 6# enable Debian Hardening 7# see: https://wiki.debian.org/Hardening 8export DEB_BUILD_MAINT_OPTIONS = hardening=+all 9DPKG_EXPORT_BUILDFLAGS = 1 10include /usr/share/dpkg/default.mk 11 12BUILDDIR := builddir 13DEB_VERSION_REVISION := $(shell echo $(DEB_VERSION) | sed -e 's/^.*-//') 14RELEASE := $(shell lsb_release -r -s) # Use changelog based DEB_DISTRIBUTION instead? 15TMP:=$(CURDIR)/debian/tmp 16 17CC := $(DEB_HOST_GNU_TYPE)-gcc 18CXX := $(DEB_HOST_GNU_TYPE)-g++ 19 20# Parallel build support as advised 21# at https://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options 22ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 23 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 24 MAKEFLAGS += -j$(NUMJOBS) 25else 26 # NUMJOBS cannot be empty as it is used as a parameter to mtr, default to 1. 27 NUMJOBS = 1 28endif 29 30# Ignore test suite exit code on unstable platforms 31ifneq (,$(filter $(DEB_HOST_ARCH),mips mipsel mips64el alpha powerpc sh4 hurd-i386 sparc64 kfreebsd-i386 kfreebsd-amd64)) 32 TESTSUITE_FAIL_CMD:=true 33else 34 TESTSUITE_FAIL_CMD:=exit 1 35endif 36 37ifeq (32,$(DEB_HOST_ARCH_BITS)) 38 CMAKEFLAGS += -DWITHOUT_ROCKSDB=true 39endif 40 41# Skip TokuDB if arch is not amd64 (also disable for kfreebsd-amd64 as it FTBFS) 42# Skipped on the x32 ABI too; untested, but unlikely to work given i386 is not 43# supported. 44ifneq ($(DEB_HOST_ARCH),amd64) 45 CMAKEFLAGS += -DWITHOUT_TOKUDB=true 46endif 47 48# Disable jemalloc on mips* due to #843926 49ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel mips64 mips64el)) 50 CMAKEFLAGS += -DWITH_JEMALLOC=no 51endif 52 53# Add support for verbose builds 54MAKEFLAGS += VERBOSE=1 55 56override_dh_auto_clean: 57 @echo "RULES.$@" 58 dh_testdir 59 dh_testroot 60 [ ! -d mysql-test/var ] || rm -rf mysql-test/var 61 rm -rf $(BUILDDIR) 62 debconf-updatepo # Update po-files when clean runs before each build 63 64override_dh_prep: 65 # Don't clean /tmp/ away, it is needed by all binary packages 66 67override_dh_auto_configure: 68 @echo "RULES.$@" 69 dh_testdir 70 71 # Versioned symbols are only available on Linux. 72 # Remove symbols file on kFreeBSD builds so that 73 # dpkg-gensymbols will not fail the build. 74ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-i386 kfreebsd-amd64)) 75 rm debian/libmariadb3.symbols 76endif 77 78 mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && \ 79 sh -c 'PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \ 80 CC=${CC} \ 81 CXX=${CXX} \ 82 cmake -DCMAKE_INSTALL_PREFIX=/usr \ 83 $(CMAKEFLAGS) \ 84 -DCOMPILATION_COMMENT="mariadb.org binary distribution" \ 85 -DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \ 86 -DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \ 87 -DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \ 88 -DBUILD_CONFIG=mysql_release \ 89 -DPLUGIN_AWS_KEY_MANAGEMENT=NO \ 90 -DDEB=$(DEB_VENDOR) ..' 91 92# This is needed, otherwise 'make test' will run before binaries have been built 93override_dh_auto_build: 94 @echo "RULES.$@" 95 # Print build env info to help debug builds on different platforms 96 dpkg-architecture 97 cd $(BUILDDIR) && $(MAKE) 98 99override_dh_auto_test: 100 @echo "RULES.$@" 101 dh_testdir 102 # Skip unstable tests if such are defined for arch 103 [ ! -f debian/unstable-tests.$(DEB_HOST_ARCH) ] || cat debian/unstable-tests.$(DEB_HOST_ARCH) >> mysql-test/unstable-tests 104 # Run testsuite 105ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) 106 cd $(BUILDDIR)/mysql-test && ./mtr --force --mem --parallel=$(NUMJOBS) --skip-rpl --suite=main --skip-test-list=unstable-tests || $(TESTSUITE_FAIL_CMD) ; 107endif 108 109override_dh_auto_install: 110 @echo "RULES.$@" 111 dh_testdir 112 dh_testroot 113 114ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS))) 115 # Copy systemd files to a location available for dh_installinit 116 cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.3.mariadb.service 117 cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.3.mariadb@.service 118endif 119 120 # Run 'make install' without output since it is uninteresting and 121 # silencing it helps to make overall build log shorter and more readable 122 @echo "Running $(MAKE) install DESTDIR=$(TMP) ..." 123 cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP) > /dev/null 124 125 # If mariadb-test package is removed, also remove most of it's files 126 grep --quiet "Package: mariadb-test" debian/control || rm -rf $(TMP)/usr/share/mysql/mysql-test 127 128 # Delete runnable files we don't want to have in the test data package. 129 # This avoids triggering multiple Lintian errors. 130 rm -rf $(TMP)/usr/share/mysql/mysql-test/plugin/tokudb/tokudb/*.py 131 rm -rf $(TMP)/usr/share/mysql/mysql-test/plugin/tokudb/tokudb/t/*.py 132 133 # nm numeric soft is not enough, therefore extra sort in command 134 # to satisfy Debian reproducible build requirements 135 nm --defined-only $(BUILDDIR)/sql/mysqld | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.3/mysqld.sym.gz 136 137 # rename and install AppArmor profile 138 install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld 139 # install Apport hook 140 install -D -m 644 debian/mariadb-server-10.3.py $(TMP)/usr/share/apport/package-hooks/source_mariadb-10.3.py 141 142 # Install libmariadbclient18 compatibility links 143 ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so 144 ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so.18 145 146 # Install libmysqlclientclientXX compatibility links 147 ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.18 148 ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.19 149 ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.20 150 151 152override_dh_installlogrotate-arch: 153 dh_installlogrotate --name mysql-server 154 155override_dh_systemd_enable: 156 dh_systemd_enable --name=mariadb 157 dh_systemd_enable --no-enable --name=mariadb@ 158 159# Start mysql at sequence number 19 before 20 where apache, proftpd etc gets 160# started which might depend on a running database server. 161override_dh_installinit-arch: 162 dh_installinit --name=mysql -- defaults 19 21 163 dh_systemd_start --restart-after-upgrade 164 165override_dh_installcron-arch: 166 dh_installcron --name mysql-server 167 168get-orig-source: 169 uscan --force-download --verbose 170 171# If a file is not supposed to be included anywhere, add it to the not-installed 172# file and document the reason. Note that dh_install supports the above mentioned 173# white list file only starting from Debian Stretch and Ubuntu Xenial. 174# To find more, grep build logs for 'but is not installed to anywhere'. 175%: 176 dh $@ --parallel --with systemd --list-missing 177 178# vim: ts=8 179