summaryrefslogtreecommitdiffstats
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules75
1 files changed, 40 insertions, 35 deletions
diff --git a/debian/rules b/debian/rules
index 1b811ae..3e7b051 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,46 +9,71 @@ export SHELL = /bin/sh -e
DISTRO:=$(shell (lsb_release -is 2>/dev/null || echo Debian) | sed s:Debian:Debian/GNU:)
-export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto future=+lfs
+# Extra hardening flags (level 3):
+# https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level
+# https://fedoraproject.org/wiki/Changes/Add_FORTIFY_SOURCE%3D3_to_distribution_build_flags
+export DEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
export DEB_LDFLAGS_MAINT_STRIP = -Wl,-Bsymbolic-functions
DPKG_EXPORT_BUILDFLAGS = 1
+
+include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/buildtools.mk # for ${CC}
include /usr/share/dpkg/pkg-info.mk
+# list of packages we build (cache it to avoid extra execs)
+export POSTFIX_PACKAGES_2BUILD ?= $(shell dh_listpackages)
+
package=postfix
base=debian/${package}
prvlibdir=/usr/lib/postfix
daemondir=/usr/lib/postfix/sbin
docdir=/usr/share/doc/${package}
-maps = cdb ldap lmdb mongodb mysql pcre pgsql sqlite
+
+maps = cdb ldap lmdb mysql pcre pgsql sqlite
# sed ERE for postfix-files to select files for the doc package
docfiles-re = \$$(sample|readme|html)_directory
-CCARGS += -DDEBIAN \
+CCARGS = \
+ -DDEBIAN \
-DHAS_PCRE=2 $(shell pcre2-config --cflags) \
-DHAS_LDAP \
-DUSE_LDAP_SASL \
-DHAS_SQLITE \
-DMYORIGIN_FROM_FILE \
- $(shell getconf LFS_CFLAGS) \
-DHAS_CDB \
-DHAS_LMDB \
- -DHAS_MONGODB -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 \
-DHAS_MYSQL -I/usr/include/mysql \
-DHAS_PGSQL -I$(shell pg_config --includedir) \
-DHAS_SQLITE \
-DHAS_SSL -I/usr/include/openssl \
-DUSE_SASL_AUTH -I/usr/include/sasl \
-DUSE_CYRUS_SASL \
- -DUSE_TLS
+ -DUSE_TLS \
-AUXLIBS += -lssl -lcrypto -lsasl2 -lpthread
+CONFARGS = \
+ DEBUG='' \
+ OPT="${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" \
+ PLUGIN_LD="${CC} -shared ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" \
+ SHLIB_RPATH="-Wl,-rpath,${prvlibdir} ${LDFLAGS}" \
+ AUXLIBS="${AUXLIBS}" \
+ AUXLIBS_CDB="-lcdb" \
+ AUXLIBS_LDAP="-lldap -llber" \
+ AUXLIBS_LMDB="-llmdb" \
+ AUXLIBS_MYSQL="-lmysqlclient" \
+ AUXLIBS_PCRE="$(shell pcre2-config --libs8)" \
+ AUXLIBS_PGSQL="-lpq" \
+ AUXLIBS_SQLITE="-lsqlite3" \
-# Extra hardening flags
-export DEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
+AUXLIBS = -lssl -lcrypto -lsasl2 -lpthread
+ifneq (,$(filter ${package}-mongodb,${POSTFIX_PACKAGES_2BUILD}))
+maps += mongodb
+CCARGS += -DHAS_MONGODB -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0
+CONFARGS += AUXLIBS_MONGODB="-lmongoc-1.0 -lbson-1.0"
+endif
%:
dh $@
@@ -58,19 +83,7 @@ override_dh_auto_configure:
touch .makefiles-made
${MAKE} \
CCARGS="${CCARGS}" \
- DEBUG='' \
- OPT="${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" \
- PLUGIN_LD="${CC} -shared ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" \
- AUXLIBS="${AUXLIBS}" \
- AUXLIBS_CDB="-lcdb" \
- AUXLIBS_LDAP="-lldap -llber" \
- AUXLIBS_LMDB="-llmdb" \
- AUXLIBS_MONGODB="-lmongoc-1.0 -lbson-1.0" \
- AUXLIBS_MYSQL="-lmysqlclient" \
- AUXLIBS_PCRE="$(shell pcre2-config --libs8)" \
- AUXLIBS_PGSQL="-lpq" \
- AUXLIBS_SQLITE="-lsqlite3" \
- SHLIB_RPATH="-Wl,-rpath,${prvlibdir} ${LDFLAGS}" \
+ ${CONFARGS} \
shared=yes pie=yes dynamicmaps=yes \
daemon_directory=${daemondir} \
shlib_directory=${prvlibdir} \
@@ -183,9 +196,9 @@ override_dh_install-arch:
pkgdir=${base}-$$map; \
install lib/postfix-$$map.so -D -t $$pkgdir${prvlibdir}/ ; \
mkdir -p $$pkgdir/etc/postfix/postfix-files.d ; \
- grep -E "\\b$$map[._]" ${base}/etc/postfix/postfix-files > \
+ grep "postfix-$$map\\.so" ${base}/etc/postfix/postfix-files > \
$$pkgdir/etc/postfix/postfix-files.d/$$map.files ; \
- sed -i "/\\b$$map[._]/D" ${base}/etc/postfix/postfix-files ; \
+ sed -i "/postfix-$$map\\.so/D" ${base}/etc/postfix/postfix-files ; \
{ echo '. /usr/share/postfix/postinst.functions' ; \
echo "[ configure != \"\$$1\" ] || addmap \"$$map\"" ; \
} > debian/postfix-$$map.postinst.debhelper ; \
@@ -193,16 +206,11 @@ override_dh_install-arch:
echo "[ remove != \"\$$1\" -a purge != \"\$$1\" ] || delmap \"$$map\"" ; \
} > debian/postfix-$$map.prerm.debhelper ; \
done
-# manpages for dynamic maps (there's no cdb_table manpage)
- for map in $(filter-out cdb, ${maps}); do \
- pkgdir=${base}-$$map; \
- mkdir -m755 -p $$pkgdir/usr/share/man/man5 ; \
- mv ${base}/usr/share/man/man5/$${map}_table.5 \
- $$pkgdir/usr/share/man/man5 ; \
- done
# debian-specific and extra addons
install -m0644 debian/functions -T ${base}/usr/share/postfix/postinst.functions
- install -m0755 debian/configure-instance.sh -t ${base}${prvlibdir}/
+ sed 's/@MULTIARCH@/${DEB_HOST_MULTIARCH}/' debian/configure-instance.in > \
+ ${base}${prvlibdir}/configure-instance.sh
+ chmod 0755 ${base}${prvlibdir}/configure-instance.sh
install -m0755 \
debian/postfix-add-filter \
debian/postfix-add-policy \
@@ -236,9 +244,6 @@ override_dh_installsystemd:
-Dt ${base}/$(shell pkg-config --variable=systemdsystemgeneratordir systemd)/
execute_before_dh_gencontrol:
- for i in $$(dh_listpackages) ; do \
- cat debian/vars.in >> debian/$$i.substvars ; \
- done
echo ${package}:Provides=default-mta \
>> debian/${package}.substvars