commit 1a95a71: [Minor] Rework debian packages build system

Vsevolod Stakhov vsevolod at rspamd.com
Fri Feb 17 19:56:04 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-02-17 19:53:21 +0000
URL: https://github.com/rspamd/rspamd/commit/1a95a71658ee6c667423f427359a3af507f3ab50 (HEAD -> master)

[Minor] Rework debian packages build system

---
 debian/control | 23 ++++++++++++++++++++---
 debian/rules   | 58 +++++++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 61 insertions(+), 20 deletions(-)

diff --git a/debian/control b/debian/control
index 97211dbc6..46fcff85d 100644
--- a/debian/control
+++ b/debian/control
@@ -6,10 +6,7 @@ Build-Depends: cmake,
                debhelper (>= 10),
                libcurl4-openssl-dev,
                libglib2.0-dev,
-               libhyperscan-dev [amd64 i386],
                libicu-dev,
-               libjemalloc-dev,
-               libluajit-5.1-dev [amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el] | liblua5.1-dev,
                libmagic-dev,
                libpcre2-dev,
                libsodium-dev,
@@ -26,15 +23,35 @@ Vcs-Browser: https://github.com/vstakhov/rspamd
 
 Package: rspamd
 Architecture: any
+Conflicts: rspamd-asan
+Provides: rspamd
 Depends: adduser, lsb-base, ca-certificates, ${misc:Depends}, ${shlibs:Depends}
 Description: Rapid spam filtering system
  Rspamd is a rapid, modular and lightweight spam filter. It is designed to work
  with big amount of mail and can be easily extended with own filters written in
  Lua.
 
+Package: rspamd-asan
+Architecture: any
+Conflicts: rspamd
+Provides: rspamd
+Depends: adduser, lsb-base, ca-certificates, ${misc:Depends}, ${shlibs:Depends}
+Description: Rapid spam filtering system
+ Rspamd is a rapid, modular and lightweight spam filter. It is designed to work
+ with big amount of mail and can be easily extended with own filters written in
+ Lua. This package is build with no compile optimisations and with ASAN library
+ to be used when there is a need to debug Rspamd.
+
 Package: rspamd-dbg
 Architecture: any
 Section: debug
 Depends: rspamd (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends}
 Description: debugging symbols for rspamd
  This package contains the debugging symbols for rspamd.
+
+Package: rspamd-dbg-asan
+Architecture: any
+Section: debug
+Depends: rspamd-asan (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends}
+Description: debugging symbols for rspamd-asan
+ This package contains the debugging symbols for rspamd-asan.
diff --git a/debian/rules b/debian/rules
index f702e46de..f4c922447 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,26 +5,39 @@ export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
 export ASAN_OPTIONS=detect_leaks=0
 
 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+builddir = debian/build/flavor-
+FLAVORS = release asan
+CONFIG_asan = -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=address -DENABLE_LTO=OFF
+CONFIG_release = -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LTO=ON
 
 ifneq ($(filter $(DEB_HOST_ARCH),amd64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el),)
-	ENABLE_LUAJIT := ON
+	ENABLE_LUAJIT := -DENABLE_LUAJIT=ON -DLUA_ROOT=/luajit-build
 else
-	ENABLE_LUAJIT := OFF
+	ENABLE_LUAJIT := -DENABLE_LUAJIT=OFF
 endif
 
 # Can be filled by a build system
 EXTRA_ARGS :=
+ENABLE_JEMALLOC := -DENABLE_JEMALLOC=OFF
 
-ifneq ($(filter $(DEB_HOST_ARCH),amd64 i386),)
+ifneq ($(filter $(DEB_HOST_ARCH),amd64 i386 arm64),)
+ifeq ($(filter $(DEB_HOST_ARCH),arm64),)
+	ENABLE_JEMALLOC := -DENABLE_JEMALLOC=ON
+	ENABLE_HYPERSCAN := -DENABLE_HYPERSCAN=ON -DHYPERSCAN_ROOT_DIR=/vectorscan
+else
 	ENABLE_HYPERSCAN := -DENABLE_HYPERSCAN=ON
+endif
 else
-	ENABLE_HYPERSCAN :=
+	ENABLE_HYPERSCAN := -DENABLE_HYPERSCAN=OFF
 endif
+
 %:
 	dh $@ --with systemd --parallel
 
-override_dh_auto_configure:
-	dh_auto_configure -- -DCONFDIR=/etc/rspamd \
+override_dh_auto_configure: $(patsubst %,configure_%,$(FLAVORS))
+configure_%:
+	mkdir -p $(builddir)$*
+	cd $(builddir)$* && cmake ../../../  -DCONFDIR=/etc/rspamd -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 \
 		-DMANDIR=/usr/share/man \
 		-DRUNDIR=/run/rspamd \
 		-DDBDIR=/var/lib/rspamd \
@@ -33,11 +46,9 @@ override_dh_auto_configure:
 		-DLIBDIR=/usr/lib/rspamd \
 		-DINCLUDEDIR=/usr/include \
 		-DSYSTEMDDIR=/lib/systemd/system \
-		-DCMAKE_BUILD_TYPE=None \
+		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
 		-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-		-DENABLE_LTO=ON \
 		-DDEBIAN_BUILD=1 \
-		-DENABLE_JEMALLOC=ON \
 		-DENABLE_PCRE2=ON \
 		-DENABLE_LUAJIT=$(ENABLE_LUAJIT) \
 		-DENABLE_LIBUNWIND=ON \
@@ -45,20 +56,33 @@ override_dh_auto_configure:
 		-DENABLE_STATIC_LIBCXX=OFF \
 		-DENABLE_LIBCXX=OFF \
 		$(ENABLE_HYPERSCAN) \
+		$(ENABLE_LUAJIT) \
+		$(ENABLE_JEMALLOC) \
+		$(CONFIG_$*) \
 		$(EXTRA_ARGS)
 
-override_dh_strip:
-	dh_strip --dbg-package=rspamd-dbg
+override_dh_auto_build: $(patsubst %,build_%,$(FLAVORS))
+build_%:
+	dh_auto_build --sourcedirectory=$(builddir)$*
+
+override_dh_strip: $(patsubst %,strip_%,$(FLAVORS))
+strip_%:
+	if [ "$*" = "asan" ]; then \
+		dh_strip --dbg-package=rspamd-dbg-asan ; \
+	else \
+		dh_strip --dbg-package=rspamd-dbg ; \
+	fi
 
 override_dh_makeshlibs:
 	dh_makeshlibs -Xrspamd-actrie
 
-override_dh_auto_install:
-	dh_auto_install --destdir=debian/rspamd
-
-override_dh_auto_clean:
-	dh_auto_clean
-	rm -f src/modules.c
+override_dh_auto_install: $(patsubst %,install_%,$(FLAVORS))
+install_%:
+	if [ "$*" = "asan" ]; then \
+		cd $(builddir)$* && make install DESTDIR=../../../debian/rspamd-asan ; \
+	else \
+		cd $(builddir)$* && make install DESTDIR=../../../debian/rspamd ; \
+	fi
 
 override_dh_fixperms:
 	dh_fixperms


More information about the Commits mailing list