#942742 Simplify package rebuild with custom set of optional features

#942742#5
Date:
2019-10-20 18:59:55 UTC
From:
To:
Dear maintainer,

In effort to simplify creation and maintenance of derivate packages with
custom set of optional features disabled, here are patches that
enabling/disabling of optional feature is matter of changing exactly one
line in debian/rules.

Applied together, these patches do not alter default configuration (e.g
what is generated by dpkg-buildpackage) is any way, they just make
futher modifications simplier.

From 3dd03142350bbdf8b7b676f4d0663f1f5da4bed5 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <KAction@debian.org>
Date: Sat, 7 Sep 2019 22:13:12 +0000
Subject: [PATCH 1/2] Adjust build system to make systemd integration
 configurable
---
 ...tem-to-make-systemd-integration-conf.patch | 39 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 40 insertions(+)

diff --git a/debian/patches/0002-Adjust-build-system-to-make-systemd-integration-conf.patch b/debian/patches/0002-Adjust-build-system-to-make-systemd-integration-conf.patch
new file mode 100644
index 0000000..e5aaa0f
--- /dev/null
+++ b/debian/patches/0002-Adjust-build-system-to-make-systemd-integration-conf.patch
@@ -0,0 +1,39 @@
+From: Dmitry Bogatov <KAction@debian.org>
+Date: Sat, 7 Sep 2019 21:50:16 +0000
+Subject: Adjust build system to make systemd integration configurable
+
+Previously, systemd integration was built-in depending on whether
+libsystemd-dev was installed or not, without any option to configure it
+on per-package basis.
+
+With this change, systemd integration must be enabled explicitly
+with `WANT_SD_NOTIFY` variable.
+---
+ CMakeLists.txt | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index adb8a7e..2eab8a2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -249,6 +249,8 @@ CHECK_CXX_SOURCE_COMPILES("${TESTSRC}" HAVE_PREAD)
+ FILE(READ test/build/HAVE_DAEMON.cc TESTSRC)
+ CHECK_CXX_SOURCE_COMPILES("${TESTSRC}" HAVE_DAEMON)
+
++if (WANT_SD_NOTIFY)
++
+ pkg_check_modules(lsd "libsystemd>=209")
+ # either part of the big library nowadays or in the helper library on older systems
+ if(NOT lsd_FOUND)
+@@ -258,6 +260,11 @@ _append(CFLAGS_DAEMON ${lsd_CFLAGS})
+ _append(LDFLAGS_DAEMON ${lsd_LDFLAGS})
+ set(HAVE_SD_NOTIFY ${lsd_FOUND})
+
++if (NOT HAVE_SD_NOTIFY)
++message(FATAL_ERROR "Systemd integration is requested, but required library is not found.")
++endif() # NOT HAVE_SD_NOTIFY
++endif() # WANT_SD_NOTIFY
++
+ SET(CMAKE_REQUIRED_FLAGS "${ACNG_COMPFLAGS} ${ACNG_CXXFLAGS}")
+ FILE(READ test/build/HAVE_MEMORY_SPTR.cc TESTSRC)
+ CHECK_CXX_SOURCE_COMPILES("${TESTSRC}" HAVE_MEMORY_SPTR)
diff --git a/debian/patches/series b/debian/patches/series
index 7bb8252..09a7f20 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 debian-changes
+0002-Adjust-build-system-to-make-systemd-integration-conf.patch

From e834fe321dcec1a1a8c54c70d6352c67f0e93cf2 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <KAction@debian.org>
Date: Sat, 7 Sep 2019 22:42:40 +0000
Subject: [PATCH 2/2] Build package with libsystemd by default
--- debian/config/systemd.mk | 3 +++ debian/rules | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/config/systemd.mk b/debian/config/systemd.mk new file mode 100644 index 0000000..d71fbb7 --- /dev/null +++ b/debian/config/systemd.mk @@ -0,0 +1,3 @@ +ifeq ($(DEB_HOST_ARCH_OS),linux) + EXTRA_LIBS += "-DWANT_SD_NOTIFY=yes" +endif diff --git a/debian/rules b/debian/rules index d6fe850..eba829d 100755 --- a/debian/rules +++ b/debian/rules @@ -1,4 +1,5 @@ #!/usr/bin/make -f +include debian/config/systemd.mk TGT=$(CURDIR)/debian/apt-cacher-ng CDIR=$(TGT)/etc/apt-cacher-ng @@ -15,7 +16,7 @@ DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) # libatomic provides 8-bytes atomic operation for 32-bit MIPS ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel)) - EXTRA_LIBS="-DEXTRA_LIBS_ACNG=-latomic" + EXTRA_LIBS += "-DEXTRA_LIBS_ACNG=-latomic" endif %: -- Note, that I send and fetch email in batch, once in a few days. Please, mention in body of your reply when you add or remove recepients.