summaryrefslogtreecommitdiffstats
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules285
1 files changed, 154 insertions, 131 deletions
diff --git a/debian/rules b/debian/rules
index e9dee96..1b811ae 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,15 +1,11 @@
#!/usr/bin/make -f
# -*- makefile -*-
-# Debianrules for building a Debian package
-# Version 1.5
-#
-# These rules have been specifically designed NOT to require root to
-# run them. At any time root privileges are required, the command to be
-# executed will be made obvious and root's password will be prompted for.
-# Of course, root may still run this and no password will be required.
#
# 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
DISTRO:=$(shell (lsb_release -is 2>/dev/null || echo Debian) | sed s:Debian:Debian/GNU:)
@@ -21,17 +17,14 @@ include /usr/share/dpkg/buildtools.mk # for ${CC}
include /usr/share/dpkg/pkg-info.mk
package=postfix
-base=debian/$(package)
-docpkg=${package}-doc
-docdir=${base}-doc/usr/share/doc/$(package)
-chlogdir=${base}/usr/share/doc/$(package)
-sharedir=${base}/usr/share/postfix
-libdir=${base}/usr/lib/postfix
-plibdir=usr/lib/postfix
-sbindir=${base}/usr/sbin
-bindir=${base}/usr/bin
-confdir=${base}/etc/postfix
-sdgendir:=${base}$(shell pkg-config --variable=systemdsystemgeneratordir systemd)
+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
+
+# sed ERE for postfix-files to select files for the doc package
+docfiles-re = \$$(sample|readme|html)_directory
CCARGS += -DDEBIAN \
-DHAS_PCRE=2 $(shell pcre2-config --cflags) \
@@ -53,9 +46,6 @@ CCARGS += -DDEBIAN \
AUXLIBS += -lssl -lcrypto -lsasl2 -lpthread
-DOCFILES=README_FILES/*_README README_FILES/OVERVIEW COMPATIBILITY PORTING
-TLSDOCFILES=${TLSSRC}/TLS_TODO ${TLSSRC}/TLS_ACKNOWLEDGEMENTS
-
# Extra hardening flags
export DEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
@@ -65,7 +55,8 @@ export DEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
override_dh_auto_configure:
- ${MAKE} makefiles \
+ touch .makefiles-made
+ ${MAKE} \
CCARGS="${CCARGS}" \
DEBUG='' \
OPT="${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" \
@@ -79,20 +70,19 @@ override_dh_auto_configure:
AUXLIBS_PCRE="$(shell pcre2-config --libs8)" \
AUXLIBS_PGSQL="-lpq" \
AUXLIBS_SQLITE="-lsqlite3" \
- SHLIB_RPATH="-Wl,-rpath,/usr/lib/postfix ${LDFLAGS}" \
+ SHLIB_RPATH="-Wl,-rpath,${prvlibdir} ${LDFLAGS}" \
shared=yes pie=yes dynamicmaps=yes \
- daemon_directory=${CUR_DIR}/usr/lib/postfix/sbin \
- shlibs_directory=${CUR_DIR}/usr/lib/postfix manpage_directory=/usr/share/man \
- sample_directory=/usr/share/doc/postfix/examples readme_directory=/usr/share/doc/postfix \
- html_directory=/usr/share/doc/postfix/html
-
-
-override_dh_auto_build:
+ daemon_directory=${daemondir} \
+ shlib_directory=${prvlibdir} \
+ 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
- # man/Makefile.in does not support parallel builds
- dh_auto_build --no-parallel -- manpages
+ dh_auto_build -a
# remove unreproducible paths from makedefs.out
# '-ffile-prefix-map=/tmp/reprotest.DMXrtR/const_build_path/const_build_path=.'
@@ -104,125 +94,158 @@ override_dh_auto_build:
sed "s:@@DISTRO@@:$(DISTRO):g" < conf/main.cf > conf/main.cf.dist
-override_dh_auto_install:
- # do nothing
+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:
- install -m 0644 html/* $(docdir)/html
- rm -f $(docdir)/html/Makefile.in
- dh_installexamples -p ${docpkg} examples/qmail-local examples/smtpd-policy
- dh_installexamples -p ${docpkg} -Xmain.cf -Xmaster.cf -Xfiles conf/[a-z]*
- dh_installexamples -p ${docpkg} conf/main.cf.default debian/mailqfmt.pl
- install -m 0444 RELEASE_NOTES $(docdir)/RELEASE_NOTES
- install -m 0444 AAAREADME $(docdir)/README
- for file in */README; do \
- install -m 0444 $${file} $(docdir)/README.$${file%/README}; \
- done
- if [ ! -f meta/doc.files ] ; then \
- cd meta && for i in sample readme html ; do \
- grep $${i} postfix-files >> doc.files ; \
- done \
- fi
- rm -f $(docdir)/README.mantools
- for file in ${DOCFILES}; do \
- install -m 0444 $${file} $(docdir)/$${file##*/}; \
- done
- rm -f $(docdir)/ULTRIX_README
- cd meta && for h in ULTRIX MACOSX mantools ; do \
- grep -v $${h} doc.files > doc.files.$$ ; \
- mv doc.files.$$ doc.files ; \
- done
- mkdir -m 755 -p $(base)-doc/etc/postfix/postfix-files.d
- install -m 644 meta/doc.files ${base}-doc/etc/postfix/postfix-files.d
+# 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/qmail-local examples/smtpd-policy
+ dh_installexamples -p ${package}-doc -Xmain.cf -Xmaster.cf -Xbounce.cf -Xfiles conf/[a-z]*
+ dh_installexamples -p ${package}-doc debian/mailqfmt.pl
+# instead of grepping postfix-files, we can just create our own listing
+# based on what we actually installed, with all renames and other stuff
+ sed -nr -e '/ULTRIX|MACOSX|mantools/D' \
+ -e '/${docfiles-re}/p' \
+ meta/postfix-files > meta/doc.files
+ install -m0644 meta/doc.files -Dt ${base}-doc/etc/postfix/postfix-files.d/
override_dh_install-arch:
- install lib/lib* $(libdir)
- install debian/postfix_groups.pl $(libdir)
- install -m 0644 meta/postfix-files $(confdir)
- cd $(confdir) && for i in sample readme html LICENSE ; do \
- grep -v $${i} postfix-files > postfix-files.$$ ; \
- mv postfix-files.$$ postfix-files ; \
+# 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/dynamicmaps.cf.d \
+ etc/postfix/postfix-files.d \
+ etc/postfix/sasl
+# 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 \
+ conf/main.cf.dist \
+ conf/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/postfix-files -Dt ${base}/etc/postfix/
+ sed -i -r '/(${docfiles-re})|LICENSE:/D' \
+ ${base}/etc/postfix/postfix-files
+# manpages
+ dh_installman -p ${package} \
+ man/man1/*.1 man/man5/*.5 rmail/rmail.8
+ for f in man/man8/*.8; do \
+ sed '/^\.TH/s/ 8 / 8postfix /' $$f > ${base}/usr/share/$${f}postfix; \
done
- for j in cdb ldap lmdb mongodb mysql pcre pgsql sqlite ; do \
- mkdir -m 755 -p $(base)-$${j}/etc/postfix/postfix-files.d ; \
- grep $${j} $(confdir)/postfix-files >> $(base)-$${j}/etc/postfix/postfix-files.d/$${j}.files ; \
- grep -v $${j} $(confdir)/postfix-files > $(confdir)/postfix-files.$$ ; \
- mv $(confdir)/postfix-files.$$ $(confdir)/postfix-files ; \
- install lib/postfix-$${j}.so ${base}-$${j}/${plibdir} ; \
+ sed -i s'@.so man8/bounce.8@.so man8/bounce.8postfix@' \
+ ${base}/usr/share/man/man8/trace.8postfix \
+ ${base}/usr/share/man/man8/defer.8postfix
+# docs
+ dh_installdocs -p ${package} RELEASE_NOTES
+ dh_installchangelogs -p ${package} HISTORY
+# dynamic maps
+ for map in ${maps} ; do \
+ 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 > \
+ $$pkgdir/etc/postfix/postfix-files.d/$$map.files ; \
+ sed -i "/\\b$$map[._]/D" ${base}/etc/postfix/postfix-files ; \
+ { echo '. /usr/share/postfix/postinst.functions' ; \
+ echo "[ configure != \"\$$1\" ] || addmap \"$$map\"" ; \
+ } > debian/postfix-$$map.postinst.debhelper ; \
+ { echo '. /usr/share/postfix/postinst.functions' ; \
+ echo "[ remove != \"\$$1\" -a purge != \"\$$1\" ] || delmap \"$$map\"" ; \
+ } > debian/postfix-$$map.prerm.debhelper ; \
done
- install libexec/[a-z]* ${base}/${plibdir}/sbin
- install bin/[a-z]* ${sbindir}
- # See conf/postfix-files
- ln ${libdir}/sbin/smtp ${libdir}/sbin/lmtp
- ln ${libdir}/sbin/qmgr ${libdir}/sbin/nqmgr
- install debian/postfix-add-filter ${sbindir}
- install debian/postfix-add-policy ${sbindir}
- cp auxiliary/collate/collate.pl debian/postfix-collate
- install debian/postfix-collate ${sbindir}
- install auxiliary/qshape/qshape.pl ${sbindir}/qshape
- install -m 0444 HISTORY $(chlogdir)/changelog
- ln -s ../sbin/rmail $(bindir)/rmail
- ln -s ../sbin/sendmail $(bindir)/newaliases
- ln -s ../sbin/sendmail $(bindir)/mailq
- ln -s ../sbin/sendmail ${base}/usr/lib/sendmail
- install -m 0755 conf/postfix-script conf/post-install $(confdir)
- install -m 0644 conf/makedefs.out $(sharedir)
- install -m 0644 debian/functions $(sharedir)/postinst.functions
- install -m 0644 conf/master.cf $(sharedir)/master.cf.dist
- install -m 0644 conf/main.cf.dist $(sharedir)/main.cf.dist
- install -m 0644 conf/main.cf.debian $(sharedir)/main.cf.debian
- install -m 0644 conf/main.cf.tls $(sharedir)/main.cf.tls
- install -m 0644 meta/dynamicmaps.cf $(sharedir)/dynamicmaps.cf
- install -m644 debian/postfix.ufw.profile ${base}/etc/ufw/applications.d/postfix
- install -m644 debian/rsyslog.conf ${base}/etc/rsyslog.d/postfix.conf
- install -m644 debian/postfix.insserv.conf ${base}/etc/insserv.conf.d/postfix
- txt2man -t postfix-collate -r postfix-$(DEB_VERSION_UPSTREAM) -d '$(shell date -s @$(SOURCE_DATE_EPOCH))' -s 1 auxiliary/collate/README > ${base}/usr/share/man/man1/postfix-collate.1
- install man/man1/*.1 ${base}/usr/share/man/man1
- install man/man5/*.5 ${base}/usr/share/man/man5
- for j in ldap lmdb mongodb mysql pcre pgsql sqlite ; do \
- mkdir -m 755 -p $(base)-$${j}/usr/share/man/man5 ; \
- mv ${base}/usr/share/man/man5/$${j}_table.5 ${base}-$${j}/usr/share/man/man5 ; \
+# 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
-
- for f in man/man8/*.8; do \
- sed '/^\.TH/s/ 8 / 8postfix /' $${f}>${base}/usr/share/$${f}postfix; \
- chmod 644 ${base}/usr/share/$${f}postfix; \
- done
- install rmail/rmail.8 debian/*.8 ${base}/usr/share/man/man8
- sed -i s'@.so man8/bounce.8@.so man8/bounce.8postfix@' ${base}/usr/share/man/man8/trace.8postfix ${base}/usr/share/man/man8/defer.8postfix
-
- install debian/configure-instance.sh $(libdir)
- install -d -m 755 ${sdgendir}
- install debian/postfix-instance-generator ${sdgendir}
- install debian/ip-up.d ${base}/etc/ppp/ip-up.d/postfix
- install debian/ip-down.d ${base}/etc/ppp/ip-down.d/postfix
- install debian/ip-up.d ${base}/etc/network/if-up.d/postfix
- install debian/ip-down.d ${base}/etc/network/if-down.d/postfix
- install debian/ip-up.d ${base}/usr/lib/networkd-dispatcher/routable.d/postfix
- install debian/ip-down.d ${base}/usr/lib/networkd-dispatcher/off.d/postfix
- install debian/update-libc.d ${base}/etc/resolvconf/update-libc.d/postfix
-
+# 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}/
+ install -m0755 \
+ debian/postfix-add-filter \
+ debian/postfix-add-policy \
+ -t ${base}/usr/sbin/
+ 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
+ dh_installman -p ${package} debian/*.8
+ 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
+ install -m0755 debian/ip-up.d -DT ${base}/etc/ppp/ip-up.d/postfix
+ install -m0755 debian/ip-down.d -DT ${base}/etc/ppp/ip-down.d/postfix
+ install -m0755 debian/ip-up.d -DT ${base}/etc/network/if-up.d/postfix
+ install -m0755 debian/ip-down.d -DT ${base}/etc/network/if-down.d/postfix
+ install -m0755 debian/ip-up.d -DT ${base}/usr/lib/networkd-dispatcher/routable.d/postfix
+ install -m0755 debian/ip-down.d -DT ${base}/usr/lib/networkd-dispatcher/off.d/postfix
+ install -m0755 debian/update-libc.d -DT ${base}/etc/resolvconf/update-libc.d/postfix
if dpkg-vendor --is ubuntu; then \
- install -m 644 -D debian/postfix.apport ${base}/usr/share/apport/package-hooks/postfix.py; \
+ install -m0644 debian/postfix.apport -DT ${base}/usr/share/apport/package-hooks/postfix.py; \
fi
+ install -m0755 debian/postfix_groups.pl -t ${base}${prvlibdir}/
override_dh_installsystemd:
- dh_installsystemd -p postfix --no-enable --no-start --name postfix-resolvconf
- dh_installsystemd -p postfix --no-restart-after-upgrade postfix.service
+ dh_installsystemd -p ${package} --no-enable --no-start --name postfix-resolvconf
+ dh_installsystemd -p ${package} --no-restart-after-upgrade postfix.service
+ install -m0755 debian/postfix-instance-generator \
+ -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 postfix:Provides=default-mta >> debian/postfix.substvars
+ echo ${package}:Provides=default-mta \
+ >> debian/${package}.substvars
override_dh_auto_clean:
- ${MAKE} tidy
-
+ [ ! -f .makefiles-made ] || ${MAKE} tidy
+ rm -f .makefiles-made
# Below here is fairly generic really