mariadb/debian/rules

214 lines
8.8 KiB
Text
Raw Normal View History

#!/usr/bin/make -f
# Enable Debian Hardening
# https://wiki.debian.org/Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
# Include all defaults, including buildflags.mk
include /usr/share/dpkg/default.mk
# 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)
# Only do a strict symbol checking on Linux
ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
DPKG_GENSYMBOLS_CHECK_LEVEL := 4
endif
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
# According to Debian Policy version 4.2.0 builds should be as verbose as
# possible unless 'terse' is specifically passed.
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
export DH_VERBOSE=1
endif
# 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 'auto'.
NUMJOBS = auto
endif
# RocksDB cannot build on 32-bit platforms
ifeq (32,$(DEB_HOST_ARCH_BITS))
CMAKEFLAGS += -DPLUGIN_ROCKSDB=NO
endif
# ColumnStore can build only on amd64 and arm64
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),amd64 arm64))
CMAKEFLAGS += -DPLUGIN_COLUMNSTORE=NO
endif
# Cross building requires stack direction instruction
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),alpha amd64 arm arm64 i386 ia64 m68k mips64el mipsel powerpc ppc64 ppc64el riscv64 s390x sh4 sparc64))
CMAKEFLAGS += -DSTACK_DIRECTION=-1
endif
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),hppa))
CMAKEFLAGS += -DSTACK_DIRECTION=1
endif
endif
# Only attempt to build with PMEM on archs that have package libpmem-dev available
# See https://packages.debian.org/search?searchon=names&keywords=libpmem-dev
2022-03-18 07:36:53 +01:00
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),amd64 arm64 ppc64el riscv64))
CMAKEFLAGS += -DWITH_PMEM=yes
endif
# Add support for verbose builds
MAKEFLAGS += VERBOSE=1
override_dh_auto_clean:
@echo "RULES.$@"
dh_testdir
dh_testroot
rm -rf $(BUILDDIR) builddir-native mysql-test/unstable-tests
debconf-updatepo # Update po-files when clean runs before each build
override_dh_auto_configure:
@echo "RULES.$@"
dh_testdir
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
echo "server:Version=$(DEB_VERSION)" >> debian/substvars
# Don't build ColumnStore as part of the native build as it does not meet the
# quality standards in Debian. Also building it requires an extra 4 GB of disk
# space which makes native Debian builds fail as the total disk space needed
# for MariaDB becomes over 10 GB. Only build CS via autobake-deb.sh.
PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \
NO_UPDATE_BUILD_VERSION=1 \
dh_auto_configure --builddirectory=$(BUILDDIR) -- \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
$(CMAKEFLAGS) \
$(if $(filter $(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)),,-DIMPORT_EXECUTABLES=$(CURDIR)/builddir-native/import_executables.cmake) \
-DCOMPILATION_COMMENT="mariadb.org binary distribution" \
-DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \
-DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \
-DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \
-DBUILD_CONFIG=mysql_release \
-DCONC_DEFAULT_CHARSET=utf8mb4 \
-DPLUGIN_AWS_KEY_MANAGEMENT=NO \
-DPLUGIN_COLUMNSTORE=NO \
MDEV-24927: Deb: Use liburing-dev instead of libaio-dev Updating the debian/control file will automatically update the dependencies in all CI environments that directly read the debian/control file, such as Salsa-CI and buildbot.mariadb.org to some degree. (https://github.com/MariaDB/mariadb.org-tools/issues/43) On Debian/Ubuntu releases that don't have liburing-dev available, automatically downgrade to libaio-dev (just like libcurl4->3 is done). This ensures the debian/control file is always up-to-date and works for latest Debian and Ubuntu releases, while the backwards compatibility mods are maintained in autobake-deb.sh separately, and can be dropped from there once support for certain platforms end. Debian/Ubuntu availability visible at: - https://packages.debian.org/search?searchon=names&keywords=liburing-dev - https://packages.ubuntu.com/search?searchon=names&keywords=liburing-dev Also modify debian/rules to force a build without libaio. Use YES instead of ON to make the flag more logical (=turning libaio check "off"). Stop running Salsa-CI for Debian Stretch-backports, as it does not have liburing-dev available nor is the old-old Debian stable a relevant platform for MariaDB 10.6 to test against anymore. Since the Stretch-backports build can no longer be made, neither can the MySQL 5.7 on Bionic upgrade test be run, as it depended on the Stretch binary. This commit does not modify the .travis.yml file, as Travis-CI does not have new enough Ubuntu releases available yet. Also Travis-CI.org is practically dead now as build times have been shrunk to near zero. The scope of this change is also Debian/Ubuntu only. No RPM or Windows or Mac changes are included in this commit. This commit does not update the external libmariadb or ColumnStore CI pipelines, as those are maintained in different repositories.
2021-03-15 10:33:15 +01:00
-DIGNORE_AIO_CHECK=YES \
-DWITH_URING=yes \
-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) --output-sync=target
override_dh_auto_test:
@echo "RULES.$@"
dh_testdir
touch mysql-test/unstable-tests
[ ! -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 --mem \
--parallel=$(NUMJOBS) --skip-rpl --suite=main \
--skip-test-list=unstable-tests
endif
override_dh_auto_install:
@echo "RULES.$@"
dh_testdir
dh_testroot
ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
# Copy systemd files to a location available for dh_installinit
2022-02-08 19:25:42 +01:00
cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.9.mariadb.service
cp $(BUILDDIR)/support-files/mariadb.socket debian/mariadb-server-10.9.mariadb.socket
cp $(BUILDDIR)/support-files/mariadb-extra.socket debian/mariadb-server-10.9.mariadb-extra.socket
cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.9.mariadb@.service
cp $(BUILDDIR)/support-files/mariadb@.socket debian/mariadb-server-10.9.mariadb@.socket
cp $(BUILDDIR)/support-files/mariadb-extra@.socket debian/mariadb-server-10.9.mariadb-extra@.socket
endif
# Run 'make install' without output since it is uninteresting and
# silencing it helps to make overall build log shorter and more readable
@echo "Running $(MAKE) install DESTDIR=$(TMP) ..."
cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP) > /dev/null
# If mariadb-test package is removed, also remove most of it's files
grep --quiet "Package: mariadb-test" debian/control || rm -rf $(TMP)/usr/share/mysql/mysql-test
# Delete private files from libraries so they don't get shipped in the -dev packages
rm -r $(TMP)/usr/include/mariadb/server/private
# Don't ship sql-bench at all, just delete it completely even though it builds
rm -r $(TMP)/usr/sql-bench
# nm numeric soft is not enough, therefore extra sort in command
# to satisfy Debian reproducible build requirements
2022-02-08 19:25:42 +01:00
nm --defined-only $(BUILDDIR)/sql/mariadbd | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.9/mariadbd.sym.gz
# Rename and install AppArmor profile
install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mariadbd
# Install libmariadbclient18 compatibility links
ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so
ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so.18
# 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
# Install libmariadbclient.a compatibility link
ln -s libmariadb.a $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.a
# Symlink plugins that are used by both server and client and thus need to
# load from the libmariadb path as well
ln -s ../../../mysql/plugin/auth_test_plugin.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/auth_test_plugin.so
ln -s ../../../mysql/plugin/qa_auth_interface.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/qa_auth_interface.so
ln -s ../../../mysql/plugin/test_sql_service.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/test_sql_service.so
# Move test plugins that are only needed by the client to the libmariadb path
mv -v $(TMP)/usr/lib/mysql/plugin/qa_auth_client.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/
override_dh_installlogrotate-arch:
dh_installlogrotate --name mysql-server
override_dh_systemd_enable:
dh_systemd_enable --name=mariadb
dh_systemd_enable --no-enable --name=mariadb mariadb.socket
dh_systemd_enable --no-enable --name=mariadb-extra mariadb-extra.socket
dh_systemd_enable --no-enable --name=mariadb@ mariadb.socket
dh_systemd_enable --no-enable --name=mariadb-extra@ mariadb-extra.socket
dh_systemd_enable --no-enable --name=mariadb@ mariadb@.service
MDEV-5536: add systemd socket activation Systemd has a socket activation feature where a mariadb.socket definition defines the sockets to listen to, and passes those file descriptors directly to mariadbd to use when a connection occurs. The new functionality is utilized when starting as follows: systemctl start mariadb.socket The mariadb.socket definition only needs to contain the network information, ListenStream= directives, the mariadb.service definition is still used for service instigation. When mariadbd is started in this way, the socket, port, bind-address backlog are all assumed to be self contained in the mariadb.socket definition and as such the mariadb settings and command line arguments of these network settings are ignored. See man systemd.socket for how to limit this to specific ports. Extra ports, those specified with extra_port in socket activation mode, are those with a FileDescriptorName=extra. These need to be in a separate service name like mariadb-extra.socket and these require a Service={mariadb.service} directive to map to the original service. Extra ports need systemd v227 or greater (not RHEL/Centos7 - v219) when FileDescriptorName= was added, otherwise the extra ports are treated like ordinary ports. The number of sockets isn't limited when using systemd socket activation (except by operating system limits on file descriptors and a minimal amount of memory used per file descriptor). The systemd sockets passed can include any ownership or permissions, including those the mariadbd process wouldn't normally have the permission to create. This implementation is compatible with mariadb.service definitions. Those services started with: systemctl start mariadb.service does actually start the mariadb.service and used all the my.cnf settings of sockets and ports like it previously did.
2015-03-11 21:26:04 +01:00
# Start MariaDB 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=mariadb --no-start -- defaults 19 21
dh_systemd_start --restart-after-upgrade
override_dh_gencontrol:
dh_gencontrol -- -Tdebian/substvars
# 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'.
%:
dh $@ --parallel --with systemd --list-missing
# vim: ts=8