# debian/rules for exim4
# This file is public domain software, originally written by Joey Hess.
#
-# Uncomment this to turn on verbose mode.
+# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
buildname := $(shell scripts/os-type)-$(shell scripts/arch-type)
DEBIAN := $(shell pwd)/debian
-ifeq ($(wildcard /usr/share/dpkg/buildflags.mk),)
-CFLAGS := -g
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-CFLAGS += -O0
-else
-CFLAGS += -O2
-endif
-else
-export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow,+pie
-DPKG_EXPORT_BUILDFLAGS := 1
+export DEB_BUILD_MAINT_OPTIONS := hardening=+all
include /usr/share/dpkg/buildflags.mk
-endif
+include /usr/share/dpkg/pkg-info.mk
+# SOURCE_DATE_EPOCH is exported by pkg-info.mk since dpkg 1.18.8/July 2016
+# fall back to current date otherwise.
+SOURCE_DATE_EPOCH ?= $(shell date '+%s')
+
# The build system ignores CPPFLAGS, append them to CFLAGS
-CFLAGS := $(CFLAGS) $(shell getconf LFS_CFLAGS) -D_LARGEFILE_SOURCE -fno-strict-aliasing -Wall $(CPPFLAGS)
+CFLAGS += $(shell getconf LFS_CFLAGS) -D_LARGEFILE_SOURCE \
+ -fno-strict-aliasing -Wall $(CPPFLAGS)
export CFLAGS
# LFLAGS is used where GNU would use LDFLAGS
-export LFLAGS += $(LDFLAGS)
+export LFLAGS = $(LDFLAGS)
LC_ALL=C
export LC_ALL
-# Which packages should we build?
-ifndef buildbasepackages
-buildbasepackages=yes
-endif
-
-ifndef extradaemonpackages
-extradaemonpackages=exim4-daemon-heavy
-endif
# If you want to build a daemon with a configuration tailored to YOUR special
-# needs, uncomment the two custom packages in debian/control
-# call "fakeroot debian/rules unpack-configs", copy EDITME.exim4-light
-# to EDITME.exim4-custom and modify it. Please note that you _need_ to
-# modify EDITME.exim4-custom or your build will fail due to #386188.
+# needs, uncomment the exim4-daemon-custom package in debian/control,
+# call "debian/rules unpack-configs", copy EDITME.exim4-light to
+# EDITME.exim4-custom and modify it, then call "debian/rules pack-configs".
+#
+# Afterwards EITHER uncomment the customdaemon definition below, or set it
+# to the desired value via the environment.
+# e.g run:
+# env customdaemon=exim4-daemon-custom dpkg-buildpackage -uc -us
#
# If you want to create multiple custom packages with different names, use
# the script debian/create-custom-package [suffix].
-#
-# Afterwards EITHER change the definition of extradaemonpackages above OR
-# simply set extradaemonpackages to the desired value via the environment.
-
-# If you want your changes to survive a debian/rules clean, call
-# "fakeroot debian/rules pack-configs" after customizing EDITME.exim4-custom
-
-# If you remove exim4-daemon-light from basedaemonpackages to prevent
-# exim4-daemon-light from being built, you need to modify the build
-# process to pull the helper binaries from the daemon package that you
-# actually build. If you simply remove exim4-daemon-light here, you will
-# end up with exim4-base sans binaries, which is most probably not what
-# you intend to have.
-#
-# combined[ai]dbgpackage has a list of packages whose debug information
-# goes into the combined debug package exim4-dbg, separated as arch
-# independent and arch dependent list.
-# extraadbgpackage has a list of packages whose debug information
-# goes into one debug package foo-dbg per package. This is currently
-# only implemented and needed for arch dependent packages.
-
-ifeq ($(buildbasepackages),yes)
-basedaemonpackages=exim4-daemon-light
-combinedadbgpackage=exim4-base eximon4
-exim4dbg=exim4-dbg
-dhstripparm=--dbg-package=$(exim4dbg)
-exim4dev=exim4-dev
-extraadbgpackage=$(basedaemonpackages) $(extradaemonpackages)
-else
-basedaemonpackages=
-combinedadbgpackage=
-exim4dbg=
-dhstripparm=
-exim4dev=
-extraadbgpackage=$(extradaemonpackages)
-endif
+
+# customdaemon = exim4-daemon-custom
+daemons = exim4-daemon-light exim4-daemon-heavy $(customdaemon)
# If you want to build with OpenSSL instead of GnuTLS, uncomment this
# OPENSSL:=1
# Please note that building exim4-daemon-heavy with OpenSSL is a GPL
# violation.
-
-# list of all arch dependent packages to be built
-buildpackages=$(combinedadbgpackage) $(extraadbgpackage) $(addsuffix -dbg,$(extraadbgpackage)) $(exim4dbg) $(exim4dev)
-# generate -pexim4-base -peximon4 ... commandline for debhelper
-dhbuildpackages=$(addprefix -p,$(buildpackages))
-dhcombinedadbgpackage=$(addprefix -p,$(combinedadbgpackage))
-
-# exim4-daemon-heavy --> b-exim4-daemon-heavy/build-Linux-x86_64/exim
-daemonbinaries=$(addprefix b-,$(addsuffix /build-$(buildname)/exim,$(extradaemonpackages)))
-debiandaemonbinaries=$(addprefix $(DEBIAN)/,$(addsuffix /usr/sbin/exim4,$(extradaemonpackages)))
-BDIRS=$(addprefix b-,$(extradaemonpackages) $(basedaemonpackages))
-
-
-# get upstream-version from debian/changelog, i.e. anything until the first -
-DEBVERSION := $(shell dpkg-parsechangelog | sed -n '/^Version: /s/^Version: //p')
-UPSTREAMVERSION := $(shell echo $(DEBVERSION) | sed -n 's/\(.\+\)-[^-]\+/\1/p')
-DEBTIME := $(shell dpkg-parsechangelog --show-field Date)
-REPBUILDDATE := \
- $(shell env LC_ALL=C TZ=UTC date --date="$(DEBTIME)" '+%b %e %Y')
-REPBUILDTIME := \
- $(shell env LC_ALL=C TZ=UTC date --date="$(DEBTIME)" '+%H:%M:%S')
-
PROVIDE_DEFAULT_MTA := $(shell if dpkg-vendor --is Ubuntu || \
dpkg-vendor --derives-from Ubuntu ; then : ; else \
echo "default-mta" ; fi)
unexport TZ
-# set up build directory b-exim4-daemon-heavy/
-$(addsuffix /Makefile,$(BDIRS)): %/Makefile:
- mkdir $*
- find . -mindepth 1 -maxdepth 1 \
- -name debian -prune -o \
- -name 'b-*' -o -print0 | \
- xargs --no-run-if-empty --null \
- cp -a --target-directory=$*
- printf '#define REPBUILDDATE "$(REPBUILDDATE)"\n' \
- > $*/src/repbuildtime.h && \
- printf '#define REPBUILDTIME "$(REPBUILDTIME)"\n' \
- >> $*/src/repbuildtime.h
-
-
unpack-configs: unpack-configs-stamp
+
unpack-configs-stamp: src/EDITME exim_monitor/EDITME
patch -o EDITME.eximon exim_monitor/EDITME \
$(DEBIAN)/EDITME.eximon.diff
-diff -u exim_monitor/EDITME EDITME.eximon \
> $(DEBIAN)/EDITME.eximon.diff
-# only called manually by maintainer before upload.
-update-mtaconflicts:
- which grep-available > /dev/null && \
- grep-available --show-field=Package --field=Provides \
- mail-transport-agent --no-field-names \
- /var/lib/apt/lists/*Packages | grep -v exim | sort -u | \
- tr '\n' ',' | sed -e 's/,/, /g;s/, $$//' > $(DEBIAN)/mtalist
-
-# Generate README.Debian as text/html ...
-debian/README.Debian.html: debian/README.Debian.xml
- xsltproc --nonet --stringparam section.autolabel 1 \
- -o $@ \
- /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl \
- $<
-# ... and text/plain
-debian/README.Debian: debian/README.Debian.html
- chmod 755 $(DEBIAN)/lynx-dump-postprocess
- lynx -force_html -dump $< | $(DEBIAN)/lynx-dump-postprocess > $@.tmp
- mv $@.tmp $@
-
-configure: configure-stamp
-
-configure-stamp: $(addsuffix /Makefile,$(BDIRS)) unpack-configs-stamp
- dh_testdir
- # Add here commands to configure the package.
- touch $@
-
-# Build binaries for the base package, the eximon4 package, and the
-# exim4-daemon-light package.
-b-exim4-daemon-light/build-$(buildname)/exim: b-exim4-daemon-light/Makefile configure-stamp
- @echo build $(<D)
- dh_testdir
-
- rm -rf $(@D)
- mkdir -p $(<D)/Local
- cp EDITME.exim4-light $(<D)/Local/Makefile
- cp EDITME.eximon $(<D)/Local/eximon.conf
- cd $(<D) && $(MAKE) FULLECHO=''
-
-b-exim4-daemon-heavy/build-$(buildname)/exim: b-exim4-daemon-heavy/Makefile configure-stamp
- @echo build $(<D)
- dh_testdir
-
- rm -rf $(@D)
- mkdir -p $(<D)/Local
- cp EDITME.exim4-heavy $(<D)/Local/Makefile
- cd $(<D) && $(MAKE) FULLECHO=''
-
-b-exim4-daemon-custom/build-$(buildname)/exim: b-exim4-daemon-custom/Makefile configure-stamp
- @echo build $(<D)
- dh_testdir
-
- rm -rf $(@D)
- mkdir -p $(<D)/Local
- cp EDITME.exim4-custom $(<D)/Local/Makefile
- cd $(<D) && $(MAKE) FULLECHO=''
-
-build-indep: build-indep-stamp
-build-indep-stamp: debian/README.Debian
- dh_testdir
+bdir-stamp: unpack-configs-stamp
+ for i in $(daemons) ; do \
+ mkdir b-$$i && \
+ find . -mindepth 1 -maxdepth 1 \
+ -name debian -prune -o \
+ -name 'b-*' -o -print0 | \
+ xargs --no-run-if-empty --null \
+ cp -a --target-directory=b-$$i ; \
+ done
touch $@
-build-arch: build-arch-stamp test-stamp
-
-ifeq ($(buildbasepackages),yes)
-build-arch-stamp: b-exim4-daemon-light/build-$(buildname)/exim $(daemonbinaries)
-else
-build-arch-stamp: $(daemonbinaries)
-endif
- dh_testdir
+override_dh_auto_configure: unpack-configs-stamp bdir-stamp
+ for i in $(daemons) ; do \
+ mkdir -p b-$$i/Local && \
+ cp EDITME.`echo $$i | sed -e s/exim4-daemon/exim4/` \
+ b-$$i/Local/Makefile && \
+ cp EDITME.eximon b-$$i/Local/eximon.conf ;\
+ done
+
+override_dh_auto_build:
+ for i in $(daemons) ; do \
+ echo building $$i; \
+ cd $(CURDIR)/b-$$i && \
+ $(MAKE) FULLECHO='' ; \
+ done
# Which version of Berkeley DB are we building against?
printf '#include <db.h>\ninstdbversionis DB_VERSION_MAJOR DB_VERSION_MINOR\n' | \
cpp -P | grep instdbversionis |\
# Store Berkeley DB version in postinst script.
sed -i -f $(DEBIAN)/berkeleydb.sed \
$(DEBIAN)/exim4-base.postinst
- touch build-arch-stamp
-
-test-stamp: build-arch-stamp
- # it is not possible to run exim unless the compile-time specified
- # user exists.
- if id -u Debian-exim ; then \
- echo Debian-exim user found, running minimal testsuite ; \
- chmod +x debian/minimaltest ; \
- rm -rf $(CURDIR)/test ; \
- for i in b-exim4-daemon-light/build-$(buildname)/exim \
- $(daemonbinaries) ;\
- do mkdir $(CURDIR)/test && \
- debian/minimaltest $(CURDIR)/test $$i || \
- { echo testsuite error ; exit 1 ; } ; \
- rm -rf $(CURDIR)/test ; \
- done \
- fi
- touch $@
-
-build: build-arch build-indep
-
-clean: cleanfiles
-
-cleanfiles:
- dh_testdir
- dh_testroot
-
- debconf-updatepo
-
- rm -f build-stamp configure-stamp installbase-stamp test-stamp
-
- # Add here commands to clean up after the build process.
- [ ! -f Makefile ] || $(MAKE) distclean
- -rm -rf build-* doc/tmp test/
- -rm -f EDITME.* unpack-configs-stamp
- -rm -f $(DEBIAN)/debconf/exim4.conf.template $(DEBIAN)/files \
- $(DEBIAN)/README.Debian $(DEBIAN)/README.Debian.html \
- $(DEBIAN)/berkeleydb.sed
-
- #these are identical for all daemon-* and therefore symlinked
- @cd $(DEBIAN) && find . -maxdepth 1 \
- -regex '^\./exim4-daemon-.*\.\(postinst\|prerm\)$$' \
- -and -not -name 'exim4-daemon-light.*' -print0 \
- | xargs -0r rm -v
-
- #pwd
- chmod 755 $(DEBIAN)/exim-gencert \
- $(DEBIAN)/lynx-dump-postprocess $(DEBIAN)/script \
- $(DEBIAN)/exim-adduser $(DEBIAN)/exim4_refresh_gnutls-params
- dh_clean
- rm -rf $(BDIRS)
-
-installbase-stamp: b-exim4-daemon-light/build-$(buildname)/exim debian/README.Debian debian/README.Debian.html
- dh_testdir
- dh_testroot
- dh_prep
- dh_installdirs
+ # symlink identical maintainerscripts
+ for i in `echo $(daemons) | sed -e s/exim4-daemon-light//` ; do \
+ ln -sfv exim4-daemon-light.prerm \
+ "$(DEBIAN)/$$i.prerm" ; \
+ ln -sfv exim4-daemon-light.postinst \
+ "$(DEBIAN)/$$i.postinst" ; \
+ done
+override_dh_auto_install-arch: debian/README.Debian
cd b-exim4-daemon-light && \
$(MAKE) install FULLECHO='' \
INSTALL_ARG=-no_symlink \
b-exim4-daemon-light/build-$(buildname)/transport-filter.pl \
b-exim4-daemon-light/util/ratelimit.pl \
$(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples
- mv $(DEBIAN)/exim4-base/usr/sbin/exim \
- $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
- # fix permissions of /usr/sbin/exim4 if running with restrictive umask,
- # dh_fixperms sanitizes anything else
- chmod 4755 $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
+ rm $(DEBIAN)/exim4-base/usr/sbin/exim
mv $(DEBIAN)/exim4-base/usr/sbin/eximon \
$(DEBIAN)/eximon4/usr/sbin
mv $(DEBIAN)/exim4-base/usr/sbin/eximon.bin \
pod2man --center=EXIM4 --section=8 \
$(DEBIAN)/syslog2eximlog \
$(DEBIAN)/exim4-base/usr/share/man/man8/syslog2eximlog.8
+ for i in b-exim4-daemon-*/build-$(buildname)/exim ; do \
+ install -m4755 -oroot -groot $$i \
+ $(DEBIAN)/`echo $$i | sed -e 's/^b-//' -e 's_/.*__'`/usr/sbin/exim4 ; \
+ done
+
+override_dh_auto_install-indep: debian/README.Debian
# if you change anything here, you will have to change
# config-custom/debian/rules as well
sed -e \
- "s/^UPEX4C_version=\"\"/UPEX4C_version=\"$(DEBVERSION)\"/" \
+ "s/^UPEX4C_version=\"\"/UPEX4C_version=\"$(DEB_VERSION)\"/" \
< $(DEBIAN)/debconf/update-exim4.conf \
> $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
chmod 755 $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
chmod 755 $(DEBIAN)/debconf/update-exim4.conf.template
env CONFDIR=$(DEBIAN)/debconf \
$(DEBIAN)/debconf/update-exim4.conf.template --nobackup --run
- touch $@
+# only called manually by maintainer before upload.
+update-mtaconflicts:
+ which grep-aptavail > /dev/null && \
+ grep-aptavail --show-field=Package --field=Provides \
+ mail-transport-agent --no-field-names \
+ | grep -v exim | sort -u | \
+ tr '\n' ',' | sed -e 's/,/, /g;s/, $$//' > $(DEBIAN)/mtalist
-# This dependency expands to
-# debian/exim4-daemon-heavy/usr/sbin/exim4: b-exim4-daemon-heavy/build-Linux-x86_64/exim
-$(debiandaemonbinaries): $(DEBIAN)/%/usr/sbin/exim4: b-%/build-$(buildname)/exim
- dh_testdir
- dh_testroot
- dh_installdirs
- install -m4755 -oroot -groot $< $@
-
+# Generate README.Debian as text/html ...
+debian/README.Debian.html: debian/README.Debian.xml
+ xsltproc --nonet --stringparam section.autolabel 1 \
+ -o $@ \
+ /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl \
+ $<
+# ... and text/plain
+debian/README.Debian: debian/README.Debian.html
+ chmod 755 $(DEBIAN)/lynx-dump-postprocess
+ lynx -force_html -dump $< | $(DEBIAN)/lynx-dump-postprocess > $@.tmp
+ mv $@.tmp $@
-ifeq ($(buildbasepackages),yes)
-install=installbase-stamp $(debiandaemonbinaries)
-else
-install=$(debiandaemonbinaries)
+override_dh_auto_test:
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+ # it is not possible to run exim unless the compile-time specified
+ # user exists.
+ if id -u Debian-exim ; then \
+ echo Debian-exim user found, running minimal testsuite ; \
+ chmod +x debian/minimaltest ; \
+ rm -rf $(CURDIR)/test ; \
+ for i in b-exim4-daemon*/build-$(buildname)/exim ;\
+ do mkdir $(CURDIR)/test && \
+ debian/minimaltest $(CURDIR)/test $$i || \
+ { echo testsuite error ; exit 1 ; } ; \
+ rm -rf $(CURDIR)/test ; \
+ done \
+ fi
endif
+override_dh_auto_clean:
+ debconf-updatepo
+
+ -rm -rf build-* doc/tmp test/ b-exim*
+ -rm -f EDITME.* unpack-configs-stamp bdir-stamp
+ -rm -f $(DEBIAN)/debconf/exim4.conf.template $(DEBIAN)/files \
+ $(DEBIAN)/README.Debian $(DEBIAN)/README.Debian.html \
+ $(DEBIAN)/berkeleydb.sed
+
+ #these are identical for all daemon-* and therefore symlinked
+ @cd $(DEBIAN) && find . -maxdepth 1 \
+ -regex '^\./exim4-daemon-.*\.\(postinst\|prerm\)$$' \
+ -and -not -name 'exim4-daemon-light.*' -delete
+ #pwd
+ chmod 755 $(DEBIAN)/exim-gencert \
+ $(DEBIAN)/lynx-dump-postprocess $(DEBIAN)/script \
+ $(DEBIAN)/exim-adduser $(DEBIAN)/exim4_refresh_gnutls-params
+
override_dh_installchangelogs:
dh_installchangelogs -pexim4-base doc/ChangeLog
dh_installchangelogs --no-package=exim4-base \
override_dh_installppp:
dh_installppp --name=exim4
-override_dh_strip-arch:
- dh_strip $(dhcombinedadbgpackage) $(dhstripparm)
- for pkg in $(extraadbgpackage); do \
- dh_strip -p$$pkg --dbg-package=$${pkg}-dbg; \
- done
-
override_dh_fixperms:
dh_fixperms -X/etc/exim4/passwd.client -Xusr/sbin/exim4
override_dh_gencontrol:
dh_gencontrol -- \
- -VUpstream-Version=$(UPSTREAMVERSION) \
+ -VUpstream-Version=$(DEB_VERSION_EPOCH_UPSTREAM) \
-VMTA-Conflicts="$(shell cat $(DEBIAN)/mtalist)" \
-Vdist:Provides:exim4-daemon-light="$(PROVIDE_DEFAULT_MTA)"
rm -rf debian/exim4/usr/share/doc/exim4
dh_link
-override_dh_auto_install:
- # disabled
-
-# Build architecture-independent files here.
-# this is just exim4-config and exim4.
-binary-indep: build $(install)
-ifeq ($(buildbasepackages),yes)
- dh binary-indep
-endif
-
-# Build architecture-dependent files here.
-binary-arch: build $(install)
- # symlink identical maintainerscripts
- @for i in $(extradaemonpackages) ; do \
- ln -sfv exim4-daemon-light.prerm \
- "$(DEBIAN)/$$i.prerm" ; \
- ln -sfv exim4-daemon-light.postinst \
- "$(DEBIAN)/$$i.postinst" ; \
- done
- dh binary-arch
+%:
+ dh $@ --no-parallel
-binary: binary-arch binary-indep
-.PHONY: build clean binary-indep binary-arch binary install
+.PHONY: pack-configs unpack-configs update-mtaconflicts