summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 011862472bbb36a6d31f53fc927187eeae241f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/make -f

export DH_VERBOSE=1

# enable Debian Hardening
# see: https://wiki.debian.org/Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk


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

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

# 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)
else
    # NUMJOBS cannot be empty as it is used as a parameter to mtr, default to 1.
    NUMJOBS = 1
endif

# Ignore test suite exit code on unstable platforms
ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),mips mipsel alpha powerpc sh4 hurd-i386))
    TESTSUITE_FAIL_CMD:=true
else
    TESTSUITE_FAIL_CMD:=exit 1
endif

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

# Disable jemalloc on mips* due to #843926
ifneq (,$(filter $(DEB_HOST_ARCH), illumos-amd64 mips mipsel mips64 mips64el))
    CMAKEFLAGS += -DWITH_JEMALLOC=no
endif

# Add support for verbose builds
MAKEFLAGS += VERBOSE=1

with :=
ifeq (linux,$(DEB_HOST_ARCH_OS))
with += systemd
endif
ifeq (illumos,$(DEB_HOST_ARCH_OS))
with += smf
CMAKEFLAGS += -DENABLE_DTRACE=no
endif

# Not packages, but tries to build when JDK is found:
CMAKEFLAGS += -DCONNECT_WITH_JDBC=OFF

dh_with := $(with:%=--with %)

override_dh_auto_clean:
	@echo "RULES.$@"
	dh_testdir
	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
	rm -f debian/mariadb-server-10.1.mariadb.service
	rm -f debian/mariadb-server-10.1.mariadb@.service
	rm -rf $(BUILDDIR)

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

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

override_dh_auto_configure:
	@echo "RULES.$@"
	dh_testdir

	mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && \
	sh -c  'PATH=$${MYSQL_BUILD_PATH:-"/usr/local/bin:/usr/bin:/bin"} \
	    	CC=${CC} \
	    	CXX=${CXX} \
	    cmake -DCMAKE_INSTALL_PREFIX=/usr \
	    $(CMAKEFLAGS) \
	    -DWITH_SSL=bundled \
	    -DCOMPILATION_COMMENT="$(DEB_VENDOR) $(RELEASE)" \
	    -DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \
	    -DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \
	    -DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \
	    -DBUILD_CONFIG=mysql_release \
	    -DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
	    -DINSTALL_PLUGINDIR=lib/$(DEB_HOST_MULTIARCH)/mariadb18/plugin \
	    -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test \
	    -DPLUGIN_AUTH_SOCKET=STATIC \
	    -DDEB=$(DEB_VENDOR) ..'

# 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)

override_dh_auto_test:
	@echo "RULES.$@"
	dh_testdir
	# Skip unstable tests if such are defined for arch
	cp mysql-test/unstable-tests debian/mysql-test-unstable-tests.orig
	[ ! -f debian/unstable-tests.$(DEB_HOST_ARCH) ] || cat debian/unstable-tests.$(DEB_HOST_ARCH) >> mysql-test/unstable-tests
	# Run testsuite
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd $(BUILDDIR)/mysql-test && ./mtr --force --testcase-timeout=30 --suite-timeout=540 --retry=3 --parallel=$(NUMJOBS) --skip-test-list=unstable-tests  || $(TESTSUITE_FAIL_CMD) ;
endif

override_dh_auto_install:
	@echo "RULES.$@"
	dh_testdir
	dh_testroot

ifeq (linux,$(DEB_HOST_ARCH_OS))
	# Copy systemd files to a location available for dh_installinit
	cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.1.mariadb.service
	cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.1.mariadb@.service
endif

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

	# 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

	# 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.1/mysqld.sym.gz

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

override_dh_installlogrotate-arch:
	dh_installlogrotate --name mysql-server

ifeq (linux,$(DEB_HOST_ARCH_OS))
override_dh_systemd_enable:
	dh_systemd_enable --name=mariadb
	dh_systemd_enable --no-enable --name=mariadb@

# Disable dh_systemd_start due /etc/init.d/mysql messing with the automatic snippets
override_dh_systemd_start:
	:
endif

ifneq (illumos,$(DEB_HOST_ARCH_OS))
# 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:
	dh_installinit --name=mysql --no-start -- defaults 19 21

override_dh_installcron-arch:
	dh_installcron --name mysql-server
endif

get-orig-source:
	uscan --force-download --verbose

%:
	dh $@ --parallel $(dh_with) --fail-missing

# vim: ts=8