Import Debian changes 4.89-2+deb9u4
[hcoop/debian/exim4.git] / debian / rules
1 #!/usr/bin/make -f
2 # debian/rules for exim4
3 # This file is public domain software, originally written by Joey Hess.
4 #
5 # Uncomment this to turn on verbose mode.
6 # export DH_VERBOSE=1
7
8 buildname := $(shell scripts/os-type)-$(shell scripts/arch-type)
9 DEBIAN := $(shell pwd)/debian
10
11 ifeq ($(wildcard /usr/share/dpkg/buildflags.mk),)
12 CFLAGS := -g
13 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
14 CFLAGS += -O0
15 else
16 CFLAGS += -O2
17 endif
18 else
19 export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow,+pie
20 DPKG_EXPORT_BUILDFLAGS := 1
21 include /usr/share/dpkg/buildflags.mk
22 endif
23
24 # The build system ignores CPPFLAGS, append them to CFLAGS
25 CFLAGS := $(CFLAGS) $(shell getconf LFS_CFLAGS) -D_LARGEFILE_SOURCE -fno-strict-aliasing -Wall $(CPPFLAGS)
26 export CFLAGS
27 # LFLAGS is used where GNU would use LDFLAGS
28 export LFLAGS += $(LDFLAGS)
29
30 LC_ALL=C
31 export LC_ALL
32
33 # Which packages should we build?
34 ifndef buildbasepackages
35 buildbasepackages=yes
36 endif
37
38 ifndef extradaemonpackages
39 extradaemonpackages=exim4-daemon-heavy
40 endif
41 # If you want to build a daemon with a configuration tailored to YOUR special
42 # needs, uncomment the two custom packages in debian/control
43 # call "fakeroot debian/rules unpack-configs", copy EDITME.exim4-light
44 # to EDITME.exim4-custom and modify it. Please note that you _need_ to
45 # modify EDITME.exim4-custom or your build will fail due to #386188.
46 #
47 # If you want to create multiple custom packages with different names, use
48 # the script debian/create-custom-package [suffix].
49 #
50 # Afterwards EITHER change the definition of extradaemonpackages above OR
51 # simply set extradaemonpackages to the desired value via the environment.
52
53 # If you want your changes to survive a debian/rules clean, call
54 # "fakeroot debian/rules pack-configs" after customizing EDITME.exim4-custom
55
56 # If you remove exim4-daemon-light from basedaemonpackages to prevent
57 # exim4-daemon-light from being built, you need to modify the build
58 # process to pull the helper binaries from the daemon package that you
59 # actually build. If you simply remove exim4-daemon-light here, you will
60 # end up with exim4-base sans binaries, which is most probably not what
61 # you intend to have.
62 #
63 # combined[ai]dbgpackage has a list of packages whose debug information
64 # goes into the combined debug package exim4-dbg, separated as arch
65 # independent and arch dependent list.
66 # extraadbgpackage has a list of packages whose debug information
67 # goes into one debug package foo-dbg per package. This is currently
68 # only implemented and needed for arch dependent packages.
69
70 ifeq ($(buildbasepackages),yes)
71 basedaemonpackages=exim4-daemon-light
72 combinedadbgpackage=exim4-base eximon4
73 exim4dbg=exim4-dbg
74 dhstripparm=--dbg-package=$(exim4dbg)
75 exim4dev=exim4-dev
76 extraadbgpackage=$(basedaemonpackages) $(extradaemonpackages)
77 else
78 basedaemonpackages=
79 combinedadbgpackage=
80 exim4dbg=
81 dhstripparm=
82 exim4dev=
83 extraadbgpackage=$(extradaemonpackages)
84 endif
85
86 # If you want to build with OpenSSL instead of GnuTLS, uncomment this
87 # OPENSSL:=1
88 # Please note that building exim4-daemon-heavy with OpenSSL is a GPL
89 # violation.
90
91
92 # list of all arch dependent packages to be built
93 buildpackages=$(combinedadbgpackage) $(extraadbgpackage) $(addsuffix -dbg,$(extraadbgpackage)) $(exim4dbg) $(exim4dev)
94 # generate -pexim4-base -peximon4 ... commandline for debhelper
95 dhbuildpackages=$(addprefix -p,$(buildpackages))
96 dhcombinedadbgpackage=$(addprefix -p,$(combinedadbgpackage))
97
98 # exim4-daemon-heavy --> b-exim4-daemon-heavy/build-Linux-x86_64/exim
99 daemonbinaries=$(addprefix b-,$(addsuffix /build-$(buildname)/exim,$(extradaemonpackages)))
100 debiandaemonbinaries=$(addprefix $(DEBIAN)/,$(addsuffix /usr/sbin/exim4,$(extradaemonpackages)))
101 BDIRS=$(addprefix b-,$(extradaemonpackages) $(basedaemonpackages))
102
103
104 # get upstream-version from debian/changelog, i.e. anything until the first -
105 DEBVERSION := $(shell dpkg-parsechangelog | sed -n '/^Version: /s/^Version: //p')
106 UPSTREAMVERSION := $(shell echo $(DEBVERSION) | sed -n 's/\(.\+\)-[^-]\+/\1/p')
107 DEBTIME := $(shell dpkg-parsechangelog --show-field Date)
108 REPBUILDDATE := \
109 $(shell env LC_ALL=C TZ=UTC date --date="$(DEBTIME)" '+%b %e %Y')
110 REPBUILDTIME := \
111 $(shell env LC_ALL=C TZ=UTC date --date="$(DEBTIME)" '+%H:%M:%S')
112
113 PROVIDE_DEFAULT_MTA := $(shell if dpkg-vendor --is Ubuntu || \
114 dpkg-vendor --derives-from Ubuntu ; then : ; else \
115 echo "default-mta" ; fi)
116 # for reproducible build. If set exim would use $TZ as default value for
117 # TIMEZONE_DEFAULT
118 undefine TZ
119 unexport TZ
120
121
122 # set up build directory b-exim4-daemon-heavy/
123 $(addsuffix /Makefile,$(BDIRS)): %/Makefile:
124 mkdir $*
125 find . -mindepth 1 -maxdepth 1 \
126 -name debian -prune -o \
127 -name 'b-*' -o -print0 | \
128 xargs --no-run-if-empty --null \
129 cp -a --target-directory=$*
130 printf '#define REPBUILDDATE "$(REPBUILDDATE)"\n' \
131 > $*/src/repbuildtime.h && \
132 printf '#define REPBUILDTIME "$(REPBUILDTIME)"\n' \
133 >> $*/src/repbuildtime.h
134
135
136 unpack-configs: unpack-configs-stamp
137 unpack-configs-stamp: src/EDITME exim_monitor/EDITME
138 patch -o EDITME.eximon exim_monitor/EDITME \
139 $(DEBIAN)/EDITME.eximon.diff
140 patch -o EDITME.exim4-light src/EDITME \
141 $(DEBIAN)/EDITME.exim4-light.diff
142 ifdef OPENSSL
143 patch EDITME.exim4-light $(DEBIAN)/EDITME.openssl.exim4-light.diff
144 endif
145 for editme in $(DEBIAN)/EDITME.exim4-*.diff; do \
146 if [ "$$editme" != "$(DEBIAN)/EDITME.exim4-light.diff" ]; then \
147 TARGETNAME=`basename $$editme .diff`; \
148 echo patch -o $$TARGETNAME EDITME.exim4-light $$editme; \
149 patch -o $$TARGETNAME EDITME.exim4-light $$editme || \
150 exit $$? ;\
151 fi; \
152 done
153 touch unpack-configs-stamp
154
155 pack-configs:
156 -diff -u src/EDITME EDITME.exim4-light \
157 > $(DEBIAN)/EDITME.exim4-light.diff
158 -for editme in EDITME.exim4-*; do \
159 if [ "$$editme" != "EDITME.exim4-light" ]; then \
160 echo diff -u EDITME.exim4-light $$editme; \
161 diff -u EDITME.exim4-light $$editme > $(DEBIAN)/$${editme}.diff; \
162 fi; \
163 done
164 -diff -u exim_monitor/EDITME EDITME.eximon \
165 > $(DEBIAN)/EDITME.eximon.diff
166
167 # only called manually by maintainer before upload.
168 update-mtaconflicts:
169 which grep-available > /dev/null && \
170 grep-available --show-field=Package --field=Provides \
171 mail-transport-agent --no-field-names \
172 /var/lib/apt/lists/*Packages | grep -v exim | sort -u | \
173 tr '\n' ',' | sed -e 's/,/, /g;s/, $$//' > $(DEBIAN)/mtalist
174
175 # Generate README.Debian as text/html ...
176 debian/README.Debian.html: debian/README.Debian.xml
177 xsltproc --nonet --stringparam section.autolabel 1 \
178 -o $@ \
179 /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl \
180 $<
181 # ... and text/plain
182 debian/README.Debian: debian/README.Debian.html
183 chmod 755 $(DEBIAN)/lynx-dump-postprocess
184 lynx -force_html -dump $< | $(DEBIAN)/lynx-dump-postprocess > $@.tmp
185 mv $@.tmp $@
186
187 configure: configure-stamp
188
189 configure-stamp: $(addsuffix /Makefile,$(BDIRS)) unpack-configs-stamp
190 dh_testdir
191 # Add here commands to configure the package.
192 touch $@
193
194 # Build binaries for the base package, the eximon4 package, and the
195 # exim4-daemon-light package.
196 b-exim4-daemon-light/build-$(buildname)/exim: b-exim4-daemon-light/Makefile configure-stamp
197 @echo build $(<D)
198 dh_testdir
199
200 rm -rf $(@D)
201 mkdir -p $(<D)/Local
202 cp EDITME.exim4-light $(<D)/Local/Makefile
203 cp EDITME.eximon $(<D)/Local/eximon.conf
204 cd $(<D) && $(MAKE) FULLECHO=''
205
206 b-exim4-daemon-heavy/build-$(buildname)/exim: b-exim4-daemon-heavy/Makefile configure-stamp
207 @echo build $(<D)
208 dh_testdir
209
210 rm -rf $(@D)
211 mkdir -p $(<D)/Local
212 cp EDITME.exim4-heavy $(<D)/Local/Makefile
213 cd $(<D) && $(MAKE) FULLECHO=''
214
215 b-exim4-daemon-custom/build-$(buildname)/exim: b-exim4-daemon-custom/Makefile configure-stamp
216 @echo build $(<D)
217 dh_testdir
218
219 rm -rf $(@D)
220 mkdir -p $(<D)/Local
221 cp EDITME.exim4-custom $(<D)/Local/Makefile
222 cd $(<D) && $(MAKE) FULLECHO=''
223
224 build-indep: build-indep-stamp
225 build-indep-stamp: debian/README.Debian
226 dh_testdir
227 touch $@
228
229 build-arch: build-arch-stamp test-stamp
230
231 ifeq ($(buildbasepackages),yes)
232 build-arch-stamp: b-exim4-daemon-light/build-$(buildname)/exim $(daemonbinaries)
233 else
234 build-arch-stamp: $(daemonbinaries)
235 endif
236 dh_testdir
237 # Which version of Berkeley DB are we building against?
238 printf '#include <db.h>\ninstdbversionis DB_VERSION_MAJOR DB_VERSION_MINOR\n' | \
239 cpp -P | grep instdbversionis |\
240 sed -e 's/[[:space:]]*instdbversionis[[:space:]]//' \
241 -e 's/[[:space:]][[:space:]]*/./' \
242 -e 's_^_s/^BDBVERSION=.*/BDBVERSION=_' \
243 -e 's_$$_/_' \
244 > $(DEBIAN)/berkeleydb.sed
245 # Store Berkeley DB version in postinst script.
246 sed -i -f $(DEBIAN)/berkeleydb.sed \
247 $(DEBIAN)/exim4-base.postinst
248 touch build-arch-stamp
249
250 test-stamp: build-arch-stamp
251 # it is not possible to run exim unless the compile-time specified
252 # user exists.
253 if id -u Debian-exim ; then \
254 echo Debian-exim user found, running minimal testsuite ; \
255 chmod +x debian/minimaltest ; \
256 rm -rf $(CURDIR)/test ; \
257 for i in b-exim4-daemon-light/build-$(buildname)/exim \
258 $(daemonbinaries) ;\
259 do mkdir $(CURDIR)/test && \
260 debian/minimaltest $(CURDIR)/test $$i || \
261 { echo testsuite error ; exit 1 ; } ; \
262 rm -rf $(CURDIR)/test ; \
263 done \
264 fi
265 touch $@
266
267 build: build-arch build-indep
268
269 clean: cleanfiles
270
271 cleanfiles:
272 dh_testdir
273 dh_testroot
274
275 debconf-updatepo
276
277 rm -f build-stamp configure-stamp installbase-stamp test-stamp
278
279 # Add here commands to clean up after the build process.
280 [ ! -f Makefile ] || $(MAKE) distclean
281 -rm -rf build-* doc/tmp test/
282 -rm -f EDITME.* unpack-configs-stamp
283 -rm -f $(DEBIAN)/debconf/exim4.conf.template $(DEBIAN)/files \
284 $(DEBIAN)/README.Debian $(DEBIAN)/README.Debian.html \
285 $(DEBIAN)/berkeleydb.sed
286
287 #these are identical for all daemon-* and therefore symlinked
288 @cd $(DEBIAN) && find . -maxdepth 1 \
289 -regex '^\./exim4-daemon-.*\.\(postinst\|prerm\)$$' \
290 -and -not -name 'exim4-daemon-light.*' -print0 \
291 | xargs -0r rm -v
292
293 #pwd
294 chmod 755 $(DEBIAN)/exim-gencert \
295 $(DEBIAN)/lynx-dump-postprocess $(DEBIAN)/script \
296 $(DEBIAN)/exim-adduser $(DEBIAN)/exim4_refresh_gnutls-params
297 dh_clean
298 rm -rf $(BDIRS)
299
300 installbase-stamp: b-exim4-daemon-light/build-$(buildname)/exim debian/README.Debian debian/README.Debian.html
301 dh_testdir
302 dh_testroot
303 dh_prep
304 dh_installdirs
305
306 cd b-exim4-daemon-light && \
307 $(MAKE) install FULLECHO='' \
308 INSTALL_ARG=-no_symlink \
309 inst_conf=$(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf \
310 inst_aliases=$(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/aliases \
311 inst_dest=$(DEBIAN)/exim4-base/usr/sbin
312 if [ -e "$(DEBIAN)/example.conf.md5" ] && [ "$$(< $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum)" != "$$(cat $(DEBIAN)/example.conf.md5)" ] ; then \
313 echo "upstream example configuration has changed, new md5sum:"; \
314 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum; \
315 echo "aborting build."; \
316 exit 1; \
317 fi
318 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum > $(DEBIAN)/example.conf.md5
319 sed -e 's,/[a-zA-Z/0-9.-]*exim4-base/examples/,/etc/,' \
320 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf \
321 > $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf.tmp
322 mv $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf.tmp \
323 $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf
324 install -m755 b-exim4-daemon-light/build-$(buildname)/convert4r4 \
325 $(DEBIAN)/exim4-base/usr/sbin/exim_convert4r4
326 install -m755 \
327 b-exim4-daemon-light/build-$(buildname)/transport-filter.pl \
328 b-exim4-daemon-light/util/ratelimit.pl \
329 $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples
330 mv $(DEBIAN)/exim4-base/usr/sbin/exim \
331 $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
332 # fix permissions of /usr/sbin/exim4 if running with restrictive umask,
333 # dh_fixperms sanitizes anything else
334 chmod 4755 $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
335 mv $(DEBIAN)/exim4-base/usr/sbin/eximon \
336 $(DEBIAN)/eximon4/usr/sbin
337 mv $(DEBIAN)/exim4-base/usr/sbin/eximon.bin \
338 $(DEBIAN)/eximon4/usr/lib/exim4
339 pod2man --center=EXIM4 --section=8 \
340 $(DEBIAN)/exim4-base/usr/sbin/exipick \
341 $(DEBIAN)/exim4-base/usr/share/man/man8/exipick.8
342 pod2man --center=EXIM4 --section=8 \
343 $(DEBIAN)/exim4-base/usr/sbin/eximstats \
344 $(DEBIAN)/exim4-base/usr/share/man/man8/eximstats.8
345 install -m755 $(DEBIAN)/syslog2eximlog $(DEBIAN)/exim4-base/usr/sbin/
346 pod2man --center=EXIM4 --section=8 \
347 $(DEBIAN)/syslog2eximlog \
348 $(DEBIAN)/exim4-base/usr/share/man/man8/syslog2eximlog.8
349 # if you change anything here, you will have to change
350 # config-custom/debian/rules as well
351 sed -e \
352 "s/^UPEX4C_version=\"\"/UPEX4C_version=\"$(DEBVERSION)\"/" \
353 < $(DEBIAN)/debconf/update-exim4.conf \
354 > $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
355 chmod 755 $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
356 install -m 755 $(DEBIAN)/update-exim4defaults \
357 $(DEBIAN)/exim4-config/usr/sbin
358
359 cd $(DEBIAN)/debconf/conf.d && \
360 tar cf - `find \( -path '*/.svn/*' -prune \) -or \
361 \( -type f -print \)` | \
362 { cd $(DEBIAN)/exim4-config/etc/exim4/conf.d/ && \
363 tar xf - ; }
364
365 install -m644 $(DEBIAN)/email-addresses $(DEBIAN)/exim4-config/etc/
366 install -m640 -oroot -groot $(DEBIAN)/passwd.client \
367 $(DEBIAN)/exim4-config/etc/exim4/
368 chmod 755 $(DEBIAN)/debconf/update-exim4.conf.template
369 env CONFDIR=$(DEBIAN)/debconf \
370 $(DEBIAN)/debconf/update-exim4.conf.template --nobackup --run
371 touch $@
372
373
374 # This dependency expands to
375 # debian/exim4-daemon-heavy/usr/sbin/exim4: b-exim4-daemon-heavy/build-Linux-x86_64/exim
376 $(debiandaemonbinaries): $(DEBIAN)/%/usr/sbin/exim4: b-%/build-$(buildname)/exim
377 dh_testdir
378 dh_testroot
379 dh_installdirs
380 install -m4755 -oroot -groot $< $@
381
382
383 ifeq ($(buildbasepackages),yes)
384 install=installbase-stamp $(debiandaemonbinaries)
385 else
386 install=$(debiandaemonbinaries)
387 endif
388
389 override_dh_installchangelogs:
390 dh_installchangelogs -pexim4-base doc/ChangeLog
391 dh_installchangelogs --no-package=exim4-base \
392 -XCHANGES -Xdoc/ChangeLog
393
394 override_dh_installppp:
395 dh_installppp --name=exim4
396
397 override_dh_strip-arch:
398 dh_strip $(dhcombinedadbgpackage) $(dhstripparm)
399 for pkg in $(extraadbgpackage); do \
400 dh_strip -p$$pkg --dbg-package=$${pkg}-dbg; \
401 done
402
403 override_dh_fixperms:
404 dh_fixperms -X/etc/exim4/passwd.client -Xusr/sbin/exim4
405
406 override_dh_gencontrol:
407 dh_gencontrol -- \
408 -VUpstream-Version=$(UPSTREAMVERSION) \
409 -VMTA-Conflicts="$(shell cat $(DEBIAN)/mtalist)" \
410 -Vdist:Provides:exim4-daemon-light="$(PROVIDE_DEFAULT_MTA)"
411
412 override_dh_installlogrotate:
413 dh_installlogrotate
414 dh_installlogrotate --name=exim4-paniclog
415
416 override_dh_installinit:
417 dh_installinit --noscripts --name=exim4
418
419 override_dh_install:
420 # install config.h from daemon package, but not from exim4-daemon-light
421 dh_install -p exim4-dev \
422 $(shell ls -1 b-exim4-daemon-*/build-$(buildname)/config.h | grep -v ^b-exim4-daemon-light/) \
423 usr/include/exim4
424 dh_install
425
426 override_dh_link:
427 rm -rf debian/exim4/usr/share/doc/exim4
428 dh_link
429
430 override_dh_auto_install:
431 # disabled
432
433 # Build architecture-independent files here.
434 # this is just exim4-config and exim4.
435 binary-indep: build $(install)
436 ifeq ($(buildbasepackages),yes)
437 dh binary-indep
438 endif
439
440 # Build architecture-dependent files here.
441 binary-arch: build $(install)
442 # symlink identical maintainerscripts
443 @for i in $(extradaemonpackages) ; do \
444 ln -sfv exim4-daemon-light.prerm \
445 "$(DEBIAN)/$$i.prerm" ; \
446 ln -sfv exim4-daemon-light.postinst \
447 "$(DEBIAN)/$$i.postinst" ; \
448 done
449 dh binary-arch
450
451 binary: binary-arch binary-indep
452 .PHONY: build clean binary-indep binary-arch binary install