rules 8.58 KB
Newer Older
1 2 3
#!/usr/bin/make -f

export DH_VERBOSE=1
4 5 6

# enable Debian Hardening
# see: https://wiki.debian.org/Hardening
7
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
8
DPKG_EXPORT_BUILDFLAGS = 1
9
include /usr/share/dpkg/default.mk
10 11 12 13 14
# CPPFLAGS are nor read by CMake, so copy them to CXXFLAGS
# See why at https://cmake.org/Bug/view.php?id=12928
# This is needed for e.g. all automatic Debian hardening flags to apply on all cmake builds.
CFLAGS+=$(CPPFLAGS)
CXXFLAGS+=$(CPPFLAGS)
15

16 17 18 19 20
# Only do a strict symbol checking on Linux
ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
  DPKG_GENSYMBOLS_CHECK_LEVEL := 4
endif

21
BUILDDIR := builddir
22
DEB_VERSION_REVISION := $(shell echo $(DEB_VERSION) | sed -e 's/^.*-//')
23
RELEASE := $(shell lsb_release -r -s) # Use changelog based DEB_DISTRIBUTION instead?
24 25
TMP:=$(CURDIR)/debian/tmp

26 27 28
CC := $(DEB_HOST_GNU_TYPE)-gcc
CXX := $(DEB_HOST_GNU_TYPE)-g++

29
# Parallel build support as advised
30 31 32 33
# 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)
34 35 36
else
    # NUMJOBS cannot be empty as it is used as a parameter to mtr, default to 1.
    NUMJOBS = 1
37 38
endif

39
# Ignore test suite exit code on unstable platforms
40
ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),mips mipsel mips64el alpha powerpc sh4 hurd-i386 sparc64 kfreebsd-i386 kfreebsd-amd64))
41 42 43 44 45
    TESTSUITE_FAIL_CMD:=true
else
    TESTSUITE_FAIL_CMD:=exit 1
endif

46 47 48 49
ifeq (32,$(DEB_HOST_ARCH_BITS))
    CMAKEFLAGS += -DWITHOUT_ROCKSDB=true
endif

50
# Skip TokuDB if arch is not amd64 (also disable for kfreebsd-amd64 as it FTBFS)
51 52
# Skipped on the x32 ABI too; untested, but unlikely to work given i386 is not
# supported.
53
ifneq ($(DEB_HOST_ARCH),amd64)
54
    CMAKEFLAGS += -DWITHOUT_TOKUDB=true
55 56
endif

57
# Add support for verbose builds
58
MAKEFLAGS += VERBOSE=1
59

60 61 62 63
override_dh_auto_clean:
	@echo "RULES.$@"
	dh_testdir
	dh_testroot
64 65 66
	rm -rf mysql-test/var
	rm -f storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result
	rm -f storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result
67 68
	rm -f debian/mariadb-server-10.3.mariadb.service
	rm -f debian/mariadb-server-10.3.mariadb@.service
69
	rm -rf $(BUILDDIR) builddir-native
70

71 72 73
	[ ! -f debian/mysql-test-unstable-tests.orig ] || \
	    mv debian/mysql-test-unstable-tests.orig mysql-test/unstable-tests

74
	debconf-updatepo # Update po-files when clean runs before each build
75

76
override_dh_auto_configure:
77 78
	@echo "RULES.$@"
	dh_testdir
79

80 81 82 83 84 85 86
	# Versioned symbols are only available on Linux.
	# Remove symbols file on kFreeBSD builds so that
	# dpkg-gensymbols will not fail the build.
ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-i386 kfreebsd-amd64))
	rm debian/libmariadb3.symbols
endif

87 88 89 90 91
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_configure --builddirectory=builddir-native
	dh_auto_build --builddirectory=builddir-native -- import_executables
endif

92 93
	# Remove -DWITH_SSL=bundle if you want to use system OpenSSL, otherwise
	# the server will use YaSSL and Connector/C will use GnuTLS
94
	mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && \
95
	sh -c  'PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \
96 97
	    	CC=${CC} \
	    	CXX=${CXX} \
98
	    cmake -DCMAKE_INSTALL_PREFIX=/usr \
99
	    $(CMAKEFLAGS) \
100
	    $(if $(filter $(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)),,-DIMPORT_EXECUTABLES=$(CURDIR)/builddir-native/import_executables.cmake) \
101 102
	    -DCOMPILATION_COMMENT="$(DEB_VENDOR) $(RELEASE)" \
	    -DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \
103 104
	    -DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \
	    -DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \
105 106
	    -DBUILD_CONFIG=mysql_release \
	    -DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
107
	    -DINSTALL_PLUGINDIR=lib/$(DEB_HOST_MULTIARCH)/mariadb19/plugin \
108
	    -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test \
109
	    -DPLUGIN_AUTH_SOCKET=STATIC \
110
			-DWITH_SSL=bundled \
111
	    -DPLUGIN_AWS_KEY_MANAGEMENT=NO \
112
	    -DWITH_INNODB_SNAPPY=ON \
113
	    -DDEB=$(DEB_VENDOR) ..'
114

115 116
# This is needed, otherwise 'make test' will run before binaries have been built
override_dh_auto_build:
117
	@echo "RULES.$@"
118 119
	# Print build env info to help debug builds on different platforms
	dpkg-architecture
120
	cd $(BUILDDIR) && $(MAKE)
121 122 123

override_dh_auto_test:
	@echo "RULES.$@"
124 125
	dh_testdir
	# Skip unstable tests if such are defined for arch
126
	cp mysql-test/unstable-tests debian/mysql-test-unstable-tests.orig
127
	[ ! -f debian/unstable-tests.$(DEB_HOST_ARCH) ] || cat debian/unstable-tests.$(DEB_HOST_ARCH) >> mysql-test/unstable-tests
128
	# Run testsuite
129
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
130 131 132
	# Don't use --mem here as official Debian builders and most Docker systems don't have a large mem device available and
	# would fail with errors on lack of disk space.
	cd $(BUILDDIR)/mysql-test && ./mtr --force --testcase-timeout=30 --suite-timeout=540 --retry=3 --parallel=$(NUMJOBS) --skip-rpl --suite=main --skip-test-list=unstable-tests  || $(TESTSUITE_FAIL_CMD) ;
133 134
endif

135
override_dh_auto_install:
136 137 138
	@echo "RULES.$@"
	dh_testdir
	dh_testroot
139

140
ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
141
	# Copy systemd files to a location available for dh_installinit
142 143
	cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.3.mariadb.service
	cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.3.mariadb@.service
144
endif
145

146 147
	# make install
	cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP)
148

149 150 151 152 153
	# 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

154
	# Remove test plugins
155 156 157 158 159 160 161 162 163 164 165 166 167 168
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/adt_null.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/auth_0x0100.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/auth_test_plugin.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/daemon_example.ini
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/debug_key_management.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/dialog_examples.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/example_key_management.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/ha_example.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/ha_test_sql_discovery.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/libdaemon_example.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/mypluglib.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/qa_auth_client.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/qa_auth_interface.so
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/qa_auth_server.so
169
	rm -f $(TMP)/usr/lib/*/mariadb19/plugin/test_versioning.so
170

171 172 173 174 175 176
	# Delete useless systemd files introduced in upstream commit
	# https://github.com/MariaDB/server/commit/7bbc6c14d1e8fcf1f4737e0a5fcf6237fe18bd23
	# They have no function in Debian systems and their path and usage is unstandardized.
	rm -rf $(TMP)/usr/lib/sysusers.d/sysusers.conf
	rm -rf $(TMP)/usr/lib/tmpfiles.d/tmpfiles.conf

177 178
	# nm numeric soft is not enough, therefore extra sort in command
	# to satisfy Debian reproducible build requirements
179
	nm --defined-only $(BUILDDIR)/sql/mysqld | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.3/mysqld.sym.gz
180

181
	# rename and install AppArmor profile
182
	install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld
183

184 185 186 187 188 189 190 191
	# Install libmariadbclient18 compatibility links
	ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so

	# Install libmysqlclientclientXX compatibility links
	ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.18
	ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.19
	ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmysqlclient.so.20

192 193 194
override_dh_installlogrotate-arch:
	dh_installlogrotate --name mysql-server

195 196 197 198
override_dh_systemd_enable:
	dh_systemd_enable --name=mariadb
	dh_systemd_enable --no-enable --name=mariadb@

199 200 201 202
# Disable dh_systemd_start due /etc/init.d/mysql messing with the automatic snippets
override_dh_systemd_start:
	:

203
# Start mysql at sequence number 19 before 20 where apache, proftpd etc gets
204 205
# started which might depend on a running database server.
override_dh_installinit-arch:
206
	dh_installinit --name=mysql --no-start -- defaults 19 21
207 208 209 210

override_dh_installcron-arch:
	dh_installcron --name mysql-server

211 212 213 214
# If a file is not supposed to be included anywhere, add it to the not-installed
# file and document the reason. Note that dh_install supports the above mentioned
# white list file only starting from Debian Stretch and Ubuntu Xenial.
# To find more, grep build logs for 'but is not installed to anywhere'.
215
%:
216
	dh $@ --parallel --with systemd --list-missing
217 218

# vim: ts=8