311 lines
11 KiB
Makefile
Executable file
311 lines
11 KiB
Makefile
Executable file
#!/usr/bin/make -f
|
|
# -*- makefile -*-
|
|
#
|
|
# Robert Leslie <rob@mars.org>
|
|
# modified for Postfix by LaMont Jones <lamont@debian.org>
|
|
# rewritten by Michael Tokarev <mjt@tls.msk.ru>
|
|
|
|
export SHELL = /bin/sh -e
|
|
|
|
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
|
|
|
|
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
|
|
include /usr/share/dpkg/vendor.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 mysql pcre pgsql sqlite
|
|
|
|
# sed ERE for postfix-files to select files for the doc package
|
|
docfiles-re = \$$(sample|readme|html)_directory
|
|
|
|
# common defines
|
|
CCARGS = \
|
|
-DDEBIAN \
|
|
-DMYORIGIN_FROM_FILE
|
|
CONFARGS = \
|
|
CC="${CC}" \
|
|
DEBUG='' \
|
|
OPT="${CPPFLAGS} ${CFLAGS} ${LDFLAGS}"
|
|
AUXLIBS =
|
|
|
|
# shared libs and dynamic modules
|
|
# can add SHLIB_CFLAGS SHLIB_SUFFIX
|
|
CONFARGS += \
|
|
PLUGIN_LD="${CC} -shared ${LDFLAGS}" \
|
|
SHLIB_RPATH="-Wl,-rpath,${prvlibdir} ${LDFLAGS}" \
|
|
shlib_directory=${prvlibdir} \
|
|
shared=yes pie=yes dynamicmaps=yes
|
|
|
|
# optional stuff
|
|
CCARGS += \
|
|
-DHAS_PCRE=2 $(shell pcre2-config --cflags) \
|
|
-DHAS_LDAP \
|
|
-DUSE_LDAP_SASL \
|
|
-DHAS_SQLITE \
|
|
-DHAS_CDB \
|
|
-DHAS_LMDB \
|
|
-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 \
|
|
|
|
CONFARGS += \
|
|
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" \
|
|
|
|
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
|
|
|
|
CCARGS += -DUSE_TLSRPT
|
|
AUXLIBS += -ltlsrpt
|
|
|
|
%:
|
|
dh $@
|
|
|
|
|
|
override_dh_auto_configure:
|
|
${MAKE} \
|
|
CCARGS="${CCARGS}" \
|
|
${CONFARGS} \
|
|
AUXLIBS="${AUXLIBS}" \
|
|
daemon_directory=${daemondir} \
|
|
manpage_directory=/usr/share/man \
|
|
readme_directory=${docdir} \
|
|
html_directory=${docdir}/html \
|
|
makefiles
|
|
|
|
override_dh_auto_build-arch:
|
|
@echo "blhc: ignore-line-regexp: .*for i in single_server\.o multi_server\.o trigger_server\.o master_proto\.o mail_flow\.o event_server\.o dgram_server\.o"
|
|
|
|
dh_auto_build -a
|
|
|
|
# remove unreproducible paths from makedefs.out
|
|
# '-ffile-prefix-map=/tmp/reprotest.DMXrtR/const_build_path/const_build_path=.'
|
|
# 'SHLIB_ENV = LD_LIBRARY_PATH=/tmp/reprotest.DMXrtR/const_build_path/const_build_path/lib'
|
|
sed -i 's@\s\+-ffile-prefix-map=\S\+=.\s\+@ @g' conf/makedefs.out
|
|
sed -i 's@SHLIB_ENV = LD_LIBRARY_PATH=\S\+@SHLIB_ENV = /debian-build-path/lib@g' conf/makedefs.out
|
|
|
|
sed "s:@DEB_VENDOR@:${DEB_VENDOR}:g" < debian/main.cf.in > meta/main.cf.debian
|
|
sed "s:@DEB_VENDOR@:${DEB_VENDOR}:g" < conf/main.cf > meta/main.cf.dist
|
|
|
|
override_dh_auto_build-indep:
|
|
# man/Makefile.in does not support parallel builds
|
|
# on debian we can not create the same contents of the docs,
|
|
# since html2text on debian has -nobs forcibly enabled
|
|
${MAKE} -j1 manpages meta/postfix-files
|
|
|
|
override_dh_auto_install:
|
|
# do nothing
|
|
|
|
override_dh_install-indep:
|
|
# note: actual docs goes to postfix package doc dir instead of postix-doc
|
|
# (dh_installdocs & dh_installexamples etc does magic on this)
|
|
cp -p AAAREADME meta/README # rename
|
|
dh_installdocs -p ${package}-doc \
|
|
-XULTRIX_README -XMakefile \
|
|
meta/README \
|
|
RELEASE_NOTES-* \
|
|
README_FILES/*_README \
|
|
README_FILES/OVERVIEW \
|
|
COMPATIBILITY \
|
|
PORTING \
|
|
html
|
|
dh_installexamples -p ${package}-doc examples/smtpd-policy \
|
|
conf/access conf/aliases conf/canonical conf/generic conf/relocated \
|
|
conf/transport conf/virtual conf/header_checks debian/mailqfmt.pl
|
|
|
|
define install-map
|
|
install lib/postfix-$1.so -Dt ${base}-$1${prvlibdir}/
|
|
grep '/postfix-$1\.so' meta/postfix-files > meta/$1.files
|
|
install -m0644 meta/$1.files -Dt ${base}-$1/etc/postfix/postfix-files.d/
|
|
{ echo '. /usr/share/postfix/postinst.functions' ; \
|
|
echo '[ configure != "$$1" ] || addmap $1' ; \
|
|
} > ${base}-$1.postinst.debhelper
|
|
{ echo '. /usr/share/postfix/postinst.functions' ; \
|
|
echo '[ remove != "$$1" -a purge != "$$1" ] || delmap $1' ; \
|
|
} > ${base}-$1.prerm.debhelper
|
|
dh_installdocs -p ${package}-$1 --link-doc=${package}
|
|
# lintian: maintainer-script-should-not-use-dpkg-maintscript-helper
|
|
for s in preinst postinst prerm postrm; do \
|
|
echo 'dpkg"-"maintscript-helper dir_to_symlink /usr/share/doc/${package}-$1 ${package} 3.9.1-7~ -- "$$@"' \
|
|
>> ${base}-$1.$$s.debhelper ; \
|
|
done
|
|
|
|
endef
|
|
|
|
override_dh_install-arch:
|
|
# base dirs
|
|
dh_installdirs -p ${package} \
|
|
etc/postfix \
|
|
var/lib/postfix \
|
|
var/spool/postfix \
|
|
usr/sbin usr/bin \
|
|
usr/share/postfix \
|
|
${prvlibdir} \
|
|
${daemondir} \
|
|
etc/postfix/postfix-files.d \
|
|
etc/postfix/sasl \
|
|
var/spool/postfix/dev $(# for rsyslogd socket, #1094571) \
|
|
|
|
# main binaries and libs:
|
|
install -m0755 libexec/[a-z]* -t ${base}${daemondir}/
|
|
# these 2 are hard links (see conf/postfix-files):
|
|
ln ${base}${daemondir}/smtp ${base}${daemondir}/lmtp
|
|
ln ${base}${daemondir}/qmgr ${base}${daemondir}/nqmgr
|
|
install -m0755 bin/[a-z]* -t ${base}/usr/sbin/
|
|
install -m0755 lib/libpostfix-*.so -t ${base}${prvlibdir}/
|
|
# additional links
|
|
dh_link -p ${package} \
|
|
usr/sbin/sendmail usr/bin/newaliases \
|
|
usr/sbin/sendmail usr/bin/mailq \
|
|
usr/sbin/sendmail usr/lib/sendmail \
|
|
usr/sbin/rmail usr/bin/rmail
|
|
# configs etc
|
|
install -m0644 \
|
|
conf/makedefs.out \
|
|
meta/main.cf.dist \
|
|
meta/main.cf.debian \
|
|
debian/main.cf.tls \
|
|
meta/dynamicmaps.cf \
|
|
-t ${base}/usr/share/postfix/
|
|
install -m0644 conf/master.cf \
|
|
-T ${base}/usr/share/postfix/master.cf.dist
|
|
install -m0644 meta/main.cf.debian \
|
|
-T ${base}/etc/postfix/main.cf.proto
|
|
install -m0644 conf/master.cf \
|
|
-T ${base}/etc/postfix/master.cf.proto
|
|
# postfix-files initial: omit docs, dynamic maps, LICENSE & TLS_LICENSE,
|
|
# various empty config files, makedefs.out and dynamicmaps.cf.d
|
|
grep -E -v \
|
|
-e '${docfiles-re}' \
|
|
-e 'shlib_directory/postfix-[a-z]*\.so:' \
|
|
-e 'config_directory/(LICENSE|TLS_LICENSE)' \
|
|
-e 'config_directory/(access|aliases|canonical|generics?|relocated|transport|virtual)' \
|
|
-e 'config_directory/(bounce\.cf|install\.cf|header_checks|main\.cf\.default|postfix-script|post-install)' \
|
|
-e 'config_directory/(cidr|pcre|regexp|tcp)_table' \
|
|
-e 'meta_directory/makedefs\.out' \
|
|
-e 'meta_directory/dynamicmaps\.cf\.d' \
|
|
meta/postfix-files > debian/postfix-files
|
|
# manpages
|
|
dh_installman -p ${package} -Xmakedefs \
|
|
man/man1/*.1 man/man5/*.5 man/man8/*.8 \
|
|
rmail/rmail.8
|
|
# fix manpage names in postfix-files
|
|
sed -r -i \
|
|
-e 's|(manpage_directory/man[158]/[^:]+\.[158]):|\1.gz:|' \
|
|
debian/postfix-files
|
|
# list of files
|
|
install -m0644 debian/postfix-files -Dt ${base}/etc/postfix/
|
|
# docs
|
|
dh_installdocs -p ${package} RELEASE_NOTES
|
|
dh_installchangelogs -p ${package} HISTORY
|
|
# dynamic maps
|
|
$(foreach m, ${maps}, $(call install-map,$m))
|
|
# postfix-files final
|
|
install -m0644 debian/postfix-files -Dt ${base}/etc/postfix/
|
|
rm -f debian/postfix-files
|
|
# debian-specific and extra addons
|
|
install -m0644 debian/functions -T ${base}/usr/share/postfix/postinst.functions
|
|
sed 's/@MULTIARCH@/${DEB_HOST_MULTIARCH}/' debian/configure-instance.in > \
|
|
${base}${prvlibdir}/configure-instance.sh
|
|
chmod 0755 ${base}${prvlibdir}/configure-instance.sh
|
|
echo ${package}:Provides=default-mta \
|
|
>> debian/${package}.substvars
|
|
install -m0644 debian/postfix.ufw.profile -DT ${base}/etc/ufw/applications.d/postfix
|
|
install -m0644 debian/rsyslog.conf -DT ${base}/etc/rsyslog.d/postfix.conf
|
|
install -m0644 debian/postfix.insserv.conf -DT ${base}/etc/insserv.conf.d/postfix
|
|
for file in \
|
|
/etc/ppp/ip-up.d/postfix /etc/ppp/ip-down.d/postfix \
|
|
/etc/network/if-up.d/postfix /etc/network/if-down.d/postfix \
|
|
/etc/resolvconf/update-libc.d/postfix \
|
|
/usr/lib/networkd-dispatcher/routable.d/postfix \
|
|
/usr/lib/networkd-dispatcher/off.d/postfix \
|
|
/usr/lib/NetworkManager/dispatcher.d/postfix \
|
|
; do \
|
|
install -m0755 debian/update-resolvconf -DT ${base}$$file; \
|
|
done
|
|
$(if $(filter ${DEB_VENDOR},Ubuntu),\
|
|
install -m0644 debian/postfix.apport -DT ${base}/usr/share/apport/package-hooks/postfix.py)
|
|
install -m0755 auxiliary/collate/collate.pl -T ${base}/usr/sbin/postfix-collate
|
|
txt2man -t postfix-collate -r postfix-$(DEB_VERSION_UPSTREAM) \
|
|
-d '$(shell date -d @$(SOURCE_DATE_EPOCH))' -s 1 \
|
|
auxiliary/collate/README \
|
|
> ${base}/usr/share/man/man1/postfix-collate.1
|
|
install -m0755 auxiliary/qshape/qshape.pl -T ${base}/usr/sbin/qshape
|
|
install -m0755 debian/postfix-add-filter debian/postfix-add-policy -t ${base}/usr/sbin/
|
|
dh_installman -p ${package} debian/postfix-add-filter.8 debian/postfix-add-policy.8
|
|
|
|
override_dh_installsystemd-arch:
|
|
# postfix is (re)started by a dpkg trigger, so --no-start
|
|
# (but needs manual stop in preinst & prerm due to dh_installsystemd limitation)
|
|
patch -i debian/postfix@.service.diff -o debian/postfix@.service debian/postfix.service
|
|
dh_installsystemd -p ${package} --no-start postfix.service
|
|
rm debian/postfix@.service
|
|
{ echo '[ -z "$${DPKG_ROOT:-}" ] && [ upgrade = "$$1" ] && [ -d /run/systemd/system ] &&' ; \
|
|
echo ' deb-systemd-invoke stop postfix.service >/dev/null || :' ; } >> ${base}.preinst.debhelper
|
|
{ echo '[ -z "$${DPKG_ROOT:-}" ] && [ remove = "$$1" ] && [ -d /run/systemd/system ] &&' ; \
|
|
echo ' deb-systemd-invoke stop postfix.service >/dev/null || :'; } >> ${base}.prerm.debhelper
|
|
dh_installinit -p ${package} --no-start
|
|
{ echo '[ -z "$${DPKG_ROOT:-}" ] && [ upgrade = "$$1" ] && [ -x /etc/init.d/postfix ] &&' ; \
|
|
echo ' invoke-rc.d --skip-systemd-native postfix stop || :' ; } >> ${base}.preinst.debhelper
|
|
{ echo '[ -z "$${DPKG_ROOT:-}" ] && [ remove = "$$1" ] && [ -x /etc/init.d/postfix ] &&' ; \
|
|
echo ' invoke-rc.d --skip-systemd-native postfix stop || :' ; } >> ${base}.prerm.debhelper
|
|
dh_installsystemd -p ${package} --no-enable --no-start --name postfix-resolvconf
|
|
|
|
override_dh_installinit: # done in installsystemd
|
|
|
|
execute_after_dh_installdeb-arch:
|
|
# 3.9.1-4:
|
|
echo remove-on-upgrade /etc/postfix/postfix-script >>${base}/DEBIAN/conffiles
|
|
echo remove-on-upgrade /etc/postfix/post-install >>${base}/DEBIAN/conffiles
|
|
# 3.9.1-8: this was one-release typo in 3.9.1-6 (remove before trixie)
|
|
echo remove-on-upgrade /etc/network/ip-down.d/postfix >>${base}/DEBIAN/conffiles
|
|
|
|
execute_after_dh_installdeb-indep:
|
|
# 3.9.1-10 (remove this removal before trixie)
|
|
echo remove-on-upgrade /etc/postfix/postfix-files.d/doc.files >> debian/postfix-doc/DEBIAN/conffiles
|
|
|
|
clean:
|
|
[ ! -f conf/makedefs.out ] || ${MAKE} tidy
|
|
dh_clean
|
|
|
|
# Below here is fairly generic really
|
|
|
|
newtemplate:
|
|
debconf-updatepo
|
|
|
|
msgstats:
|
|
@cd debian/po && for i in *.po; do x=$$(msgfmt --statistics $$i 2>&1); echo $$i $$x; done; rm -f messages.mo *.po~
|
|
|
|
msg-email:
|
|
@podebconf-report-po
|