Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 export DH_VERBOSE=1
4
5 # enable Debian Hardening
6 # see: https://wiki.debian.org/Hardening
7 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
8 DPKG_EXPORT_BUILDFLAGS = 1
9 include /usr/share/dpkg/buildflags.mk
10
11 ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
12 ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
13 BUILDDIR := builddir
14 builddir = $(BUILDDIR)
15 DEBVERSION := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }' | sed 's/^.*-//' )
16 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
17 DEB_BUILD_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
18 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
19 DEB_SOURCE_PACKAGE ?= $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))
20 DEB_VERSION ?= $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
21 DEB_NOEPOCH_VERSION ?= $(shell echo $(DEB_VERSION) | cut -d: -f2-)
22 DEB_UPSTREAM_VERSION ?= $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
23 DEB_UPSTREAM_VERSION_MAJOR_MINOR := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -r -n 's/^([0-9]+\.[0-9]+).*/\1/p')
24 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
25 DISTRIBUTION := $(shell lsb_release -i -s)
26 EXPORTED_SOURCE_TARBALL := debian/mysql-source-8.0.tar.gz
27 TMP := $(CURDIR)/debian/tmp/
28 NUMJOBS=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
29 TESTJOBS=$(NUMJOBS)
30 # Some tests will fail on platforms that are not tested by upstream
31 ifneq (,$(filter $(ARCH), amd64 i386 armhf))
32 TESTSUITE_FAIL_CMD:=exit 1
33 else
34 TESTSUITE_FAIL_CMD:=true
35 endif
36
37 ifeq (,$(NUMJOBS))
38 NUMJOBS=1
39 endif
40
41 MAKEFLAGS += -j $(NUMJOBS)
42
43 # The below system setting constrains how many servers can be run in parallel
44 # A server with default config needs a bit over 5300 slots, so we assume 6000 to be sure
45 AIOMAX := $(shell cat /proc/sys/fs/aio-max-nr)
46 AIOPER := 6000
47 PARMAX := $(shell echo $$(( $(AIOMAX)/$(AIOPER))))
48
49 ifeq ($(shell test $(TESTJOBS) -gt $(PARMAX); echo $$?),0)
50 TESTJOBS:=$(shell echo $(PARMAX) )
51 endif
52
53 export MYSQL_BUILD_CC=$(DEB_HOST_GNU_TYPE)-gcc
54 export MYSQL_BUILD_CXX=$(DEB_HOST_GNU_TYPE)-g++
55
56 # The full upstream test suite takes a very long time to run, so we run
57 # only the main test suite unless fulltest is specified.
58 ifeq ($(findstring fulltest,$(DEB_BUILD_OPTIONS)),)
59 MTR_SUITE=--suite=main
60 endif
61
62
63 override_dh_auto_clean:
64 @echo "RULES.$@"
65 dh_testdir
66 dh_testroot
67 [ ! -d mysql-test/var ] || rm -rf mysql-test/var
68 rm -rf $(BUILDDIR)
69 debconf-updatepo
70 rm -f $(EXPORTED_SOURCE_TARBALL)
71
72 override_dh_prep:
73
74 override_dh_auto_configure: configure-stamp
75
76
77 configure-stamp:
78 @echo "RULES.$@"
79 dh_testdir
80 ( test -d $(builddir) || mkdir $(builddir) ) && cd $(builddir) && \
81 sh -c 'PATH=$${MYSQL_BUILD_PATH:-"/bin:/usr/bin"} \
82 CC=$${MYSQL_BUILD_CC:-gcc} \
83 CXX=$${MYSQL_BUILD_CXX:-g++} \
84 cmake -DCMAKE_INSTALL_PREFIX=/usr \
85 -DCMAKE_VERBOSE_MAKEFILE=ON \
86 -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
87 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
88 -DBUILD_CONFIG=mysql_release \
89 -DWITH_LIBWRAP=OFF \
90 -DWITH_SYSTEM_LIBS=ON \
91 -DWITH_MECAB=system \
92 -DWITH_ZLIB=system \
93 -DWITH_BOOST=../boost \
94 -DCOMPILATION_COMMENT="($(DISTRIBUTION))" \
95 -DMYSQL_SERVER_SUFFIX="-$(DEBVERSION)" \
96 -DINSTALL_LAYOUT=DEB \
97 -DINSTALL_DOCDIR=share/mysql/docs \
98 -DINSTALL_DOCREADMEDIR=share/mysql \
99 -DINSTALL_INCLUDEDIR=include/mysql \
100 -DINSTALL_INFODIR=share/mysql/docs \
101 -DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
102 -DINSTALL_MANDIR=share/man \
103 -DINSTALL_MYSQLSHAREDIR=share/mysql \
104 -DINSTALL_MYSQLTESTDIR=lib/mysql-test \
105 -DINSTALL_PLUGINDIR=lib/mysql/plugin \
106 -DINSTALL_SBINDIR=sbin \
107 -DINSTALL_SCRIPTDIR=bin \
108 -DINSTALL_SUPPORTFILESDIR=share/mysql \
109 -DSYSCONFDIR=/etc/mysql \
110 -DWITH_EMBEDDED_SERVER=ON \
111 -DWITH_ARCHIVE_STORAGE_ENGINE=ON \
112 -DWITH_BLACKHOLE_STORAGE_ENGINE=ON \
113 -DWITH_FEDERATED_STORAGE_ENGINE=ON \
114 -DWITH_INNODB_MEMCACHED=1 \
115 -DWITH_EXTRA_CHARSETS=all \
116 -DROUTER_INSTALL_LIBDIR=lib/mysql-router \
117 -DWITH_FIDO=bundled \
118 ..'
119 touch $@
120
121 override_dh_auto_build: build-stamp
122
123 # $(EXPORTED_SOURCE_TARBALL) must be built before the builds commence, since
124 # the builds change some of the files picked up by this tar invocation, and
125 # this can race against tar with an error like "tar:
126 # ./builddir-pic/strings/CMakeFiles/strings.dir: file changed as we read it".
127 # So define the rule for building it here, and have the build rules depend on
128 # it.
129 $(EXPORTED_SOURCE_TARBALL):
130 GZIP=-n tar -zcf $(EXPORTED_SOURCE_TARBALL) \
131 --exclude=debian . \
132 --transform="s,^\./,mysql-8.0/,"
133
134 build-stamp: $(EXPORTED_SOURCE_TARBALL)
135 @echo "RULES.$@"
136 cd $(builddir) && $(MAKE)
137 touch $@
138
139 override_dh_auto_test:
140 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
141 @echo "RULES.$@"
142 ifeq ($(ARCH_OS),hurd)
143 # Tests not fully working under Hurd, see
144 # http://bugs.mysql.com/bug.php?id=64685. Run unit tests only.
145 cd $(builddir) && $(MAKE) test || $(TESTSUITE_FAIL_CMD) ;
146 else
147 touch $(builddir)/mysql-test/skiplist
148 # Tests that are known to be unstable on all platforms are skipped
149 # http://bugs.mysql.com/bug.php?id=83340
150 echo "main.xa_prepared_binlog_off : BUG#00000 - unstable test" >> $(builddir)/mysql-test/skiplist
151 echo "main.mysql_client_test : BUG#100274 - unstable test" >> $(builddir)/mysql-test/skiplist
152 echo "main.type_float : BUG#92375 - fails on ppc64el. Ref https://bugs.mysql.com/bug.php?id=92375" >> $(builddir)/mysql-test/skiplist
153 echo "main.type_newdecimal : BUG#92375 - Same as above" >> $(builddir)/mysql-test/skiplist
154 echo "main.type_ranges : BUG#92375 - Same as above" >> $(builddir)/mysql-test/skiplist
155 # https://bugs.mysql.com/bug.php?id=86608
156 echo "main.mysqlpump_basic : BUG#00000 - needs openssl with zlib" >> $(builddir)/mysql-test/skiplist
157 # Test is broken for 32bit. Fixed upstream, so remove in 8.0.12+
158 echo "main.window_functions_explain : BUG#00000 - broken on i386" >> $(builddir)/mysql-test/skiplist
159 # New test in 8.0.26, needs investigation
160 echo "main.slow_log : BUG#00000 - broken" >> $(builddir)/mysql-test/skiplist
161 # Test is broken for 32bit.
162 echo "main.index_merge_myisam : BUG#00000 - broken on i386" >> $(builddir)/mysql-test/skiplist
163
164 # Skip replication tests since they are timing sensitive and may
165 # result in false positives.
166 cd $(builddir)/mysql-test && ./mtr --suite-timeout=600 --testcase-timeout=60 --report-unstable-tests --parallel=$(TESTJOBS) --skip-rpl $(MTR_SUITE) --force --skip-test-list=./skiplist || $(TESTSUITE_FAIL_CMD) ;
167 endif
168 endif
169
170 override_dh_auto_install: auto_install-stamp
171
172 auto_install-stamp:
173 @echo "RULES.$@"
174 dh_testdir
175 dh_testroot
176 # make install (trailing slash needed for innobase)
177 cd $(builddir) && $(MAKE) install DESTDIR=$(TMP)/
178 # After installing, remove rpath to make lintian happy.
179 set +e; \
180 find ./debian/tmp/ -type f -print0 \
181 | xargs -0 --no-run-if-empty chrpath -k 2>/dev/null \
182 | fgrep RPATH= \
183 | cut -d: -f 1 \
184 | xargs --no-run-if-empty chrpath -d; \
185 set -e
186 install -d -m 0755 -o root -g root $(TMP)/usr/lib/mysql
187 mkdir -p $(TMP)/usr/share/doc/mysql-server-8.0
188 nm -n $(BUILDDIR)/bin/mysqld |gzip -n -9 > $(TMP)/usr/share/doc/mysql-server-8.0/mysqld.sym.gz
189 # This seems to be the only safe place to fix permissions issues
190 # not handled by dh_fixperms.
191 install -m 0755 debian/additions/echo_stderr $(TMP)/usr/share/mysql/
192 mkdir -p $(TMP)/etc/mysql
193 install -m 0755 debian/additions/debian-start $(TMP)/etc/mysql/
194 install -m 0644 debian/additions/debian_create_root_user.sql $(TMP)/usr/share/mysql/
195 # install AppArmor profile
196 install -D -m 644 debian/additions/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld
197 touch $@
198
199
200 override_dh_installlogrotate-arch:
201 dh_installlogrotate --name mysql-server
202
203 override_dh_install:
204 dh_install \
205 -Xusr/share/man \
206 -Xusr/share/mysql/mysql.server \
207 -Xmysql.info
208 dh_apparmor -pmysql-server-8.0 --profile-name=usr.sbin.mysqld
209
210 override_dh_missing:
211 dh_missing --fail-missing \
212 -Xusr/share/man \
213 -Xusr/share/mysql/mysql.server \
214 -Xmysql.info
215
216 override_dh_installsystemd:
217 dh_installsystemd --name=mysql --no-restart-after-upgrade
218
219 override_dh_installcron-arch:
220 dh_installcron --name mysql-server
221
222 get-orig-source:
223 uscan --force-download --verbose
224
225 %:
226 dh $@ --parallel
227