Imported Debian patch 4.84-8
[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 combinedidbgpackage=exim4-config exim4
74 exim4dbg=exim4-dbg
75 dhstripparm=--dbg-package=$(exim4dbg)
76 exim4dev=exim4-dev
77 extraadbgpackage=$(basedaemonpackages) $(extradaemonpackages)
78 else
79 basedaemonpackages=
80 combinedadbgpackage=
81 combinedidbgpackage=
82 exim4dbg=
83 dhstripparm=
84 exim4dev=
85 extraadbgpackage=$(extradaemonpackages)
86 endif
87 #DEBUGOUT:=$(shell echo >&2 buildbasepackages $(buildbasepackages))
88 #DEBUGOUT:=$(shell echo >&2 extradaemonpackages $(extradaemonpackages))
89
90 # If you want to build with OpenSSL instead of GnuTLS, uncomment this
91 # OPENSSL:=1
92 # Please note that building exim4-daemon-heavy with OpenSSL is a GPL
93 # violation.
94
95
96 # list of all arch dependent packages to be built
97 buildpackages=$(combinedadbgpackage) $(extraadbgpackage) $(addsuffix -dbg,$(extraadbgpackage)) $(exim4dbg) $(exim4dev)
98 # generate -pexim4-base -peximon4 ... commandline for debhelper
99 dhbuildpackages=$(addprefix -p,$(buildpackages))
100 dhcombinedadbgpackage=$(addprefix -p,$(combinedadbgpackage))
101 dhcombinedidbgpackage=$(addprefix -p,$(combinedidbgpackage))
102
103 # exim4-daemon-heavy --> b-exim4-daemon-heavy/build-Linux-x86_64/exim
104 daemonbinaries=$(addprefix b-,$(addsuffix /build-$(buildname)/exim,$(extradaemonpackages)))
105 debiandaemonbinaries=$(addprefix $(DEBIAN)/,$(addsuffix /usr/sbin/exim4,$(extradaemonpackages)))
106 BDIRS=$(addprefix b-,$(extradaemonpackages) $(basedaemonpackages))
107
108
109 # get upstream-version from debian/changelog, i.e. anything until the first -
110 DEBVERSION := $(shell dpkg-parsechangelog | sed -n '/^Version: /s/^Version: //p')
111 UPSTREAMVERSION := $(shell echo $(DEBVERSION) | sed -n 's/\(.\+\)-[^-]\+/\1/p')
112 MTACONFLICTS := $(shell cat $(DEBIAN)/mtalist)
113
114 # set up build directory b-exim4-daemon-heavy/
115 $(addsuffix /Makefile,$(BDIRS)): %/Makefile:
116 mkdir $*
117 find . -mindepth 1 -maxdepth 1 \
118 -name debian -prune -o \
119 -name 'b-*' -o -print0 | \
120 xargs --no-run-if-empty --null \
121 cp -a --target-directory=$*
122
123
124 unpack-configs: unpack-configs-stamp
125 unpack-configs-stamp: src/EDITME exim_monitor/EDITME
126 patch -o EDITME.eximon exim_monitor/EDITME \
127 $(DEBIAN)/EDITME.eximon.diff
128 patch -o EDITME.exim4-light src/EDITME \
129 $(DEBIAN)/EDITME.exim4-light.diff
130 ifdef OPENSSL
131 patch EDITME.exim4-light $(DEBIAN)/EDITME.openssl.exim4-light.diff
132 endif
133 -for editme in $(DEBIAN)/EDITME.exim4-*.diff; do \
134 if [ "$$editme" != "$(DEBIAN)/EDITME.exim4-light.diff" ]; then \
135 TARGETNAME=`basename $$editme .diff`; \
136 echo patch -o $$TARGETNAME EDITME.exim4-light $$editme; \
137 patch -o $$TARGETNAME EDITME.exim4-light $$editme; \
138 fi; \
139 done
140 touch unpack-configs-stamp
141
142 pack-configs:
143 -diff -u src/EDITME EDITME.exim4-light \
144 > $(DEBIAN)/EDITME.exim4-light.diff
145 -for editme in EDITME.exim4-*; do \
146 if [ "$$editme" != "EDITME.exim4-light" ]; then \
147 echo diff -u EDITME.exim4-light $$editme; \
148 diff -u EDITME.exim4-light $$editme > $(DEBIAN)/$${editme}.diff; \
149 fi; \
150 done
151 -diff -u exim_monitor/EDITME EDITME.eximon \
152 > $(DEBIAN)/EDITME.eximon.diff
153
154 # only called manually by maintainer before upload.
155 update-mtaconflicts:
156 which grep-available > /dev/null && \
157 grep-available --show-field=Package --field=Provides \
158 mail-transport-agent --no-field-names \
159 /var/lib/apt/lists/*Packages | grep -v exim | sort -u | \
160 tr '\n' ',' | sed -e 's/,/, /g;s/, $$//' > $(DEBIAN)/mtalist
161
162 # Generate README.Debian as text/html ...
163 debian/README.Debian.html: debian/README.Debian.xml
164 xsltproc --nonet --stringparam section.autolabel 1 \
165 -o $@ \
166 /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl \
167 $<
168 # ... and text/plain
169 debian/README.Debian: debian/README.Debian.html
170 chmod 755 $(DEBIAN)/lynx-dump-postprocess
171 lynx -force_html -dump $< | $(DEBIAN)/lynx-dump-postprocess > $@.tmp
172 mv $@.tmp $@
173
174 configure: configure-stamp
175
176 configure-stamp: $(addsuffix /Makefile,$(BDIRS)) unpack-configs-stamp
177 dh_testdir
178 # Add here commands to configure the package.
179 # We currently do not want to build depend on debhelper 7.2.3 just to
180 # keep it from installing the wrong upstream changelog. 490937
181 rm -fv CHANGES
182 touch $@
183
184 # Build binaries for the base package, the eximon4 package, and the
185 # exim4-daemon-light package.
186 b-exim4-daemon-light/build-$(buildname)/exim: b-exim4-daemon-light/Makefile configure-stamp
187 @echo build $(<D)
188 dh_testdir
189
190 rm -rf $(@D)
191 mkdir -p $(<D)/Local
192 cp EDITME.exim4-light $(<D)/Local/Makefile
193 cp EDITME.eximon $(<D)/Local/eximon.conf
194 cd $(<D) && $(MAKE) FULLECHO=''
195
196 b-exim4-daemon-heavy/build-$(buildname)/exim: b-exim4-daemon-heavy/Makefile configure-stamp
197 @echo build $(<D)
198 dh_testdir
199
200 rm -rf $(@D)
201 mkdir -p $(<D)/Local
202 cp EDITME.exim4-heavy $(<D)/Local/Makefile
203 cd $(<D) && $(MAKE) FULLECHO=''
204
205 b-exim4-daemon-custom/build-$(buildname)/exim: b-exim4-daemon-custom/Makefile configure-stamp
206 @echo build $(<D)
207 dh_testdir
208
209 rm -rf $(@D)
210 mkdir -p $(<D)/Local
211 cp EDITME.exim4-custom $(<D)/Local/Makefile
212 cd $(<D) && $(MAKE) FULLECHO=''
213
214 build-indep: build-indep-stamp
215 build-indep-stamp:
216 dh_testdir
217
218 # Add here command to compile/build the arch indep package.
219 # It's ok not to do anything here, if you don't need to build
220 # anything for this package.
221 #/usr/bin/docbook-to-man $(DEBIAN)/exim.sgml > exim.1
222
223 touch build-indep-stamp
224
225 build-arch: build-arch-stamp test-stamp
226
227 ifeq ($(buildbasepackages),yes)
228 build-arch-stamp: b-exim4-daemon-light/build-$(buildname)/exim $(daemonbinaries)
229 else
230 build-arch-stamp: $(daemonbinaries)
231 endif
232 dh_testdir
233 # Which version of Berkeley DB are we building against?
234 printf '#include <db.h>\ninstdbversionis DB_VERSION_MAJOR DB_VERSION_MINOR\n' | \
235 cpp | grep instdbversionis |\
236 sed -e 's/[[:space:]]*instdbversionis[[:space:]]//' \
237 -e 's/[[:space:]][[:space:]]*/./' \
238 -e 's_^_s/^BDBVERSION=.*/BDBVERSION=_' \
239 -e 's_$$_/_' \
240 > $(DEBIAN)/berkeleydb.sed
241 # Store Berkeley DB version in postinst script.
242 sed -i -f $(DEBIAN)/berkeleydb.sed \
243 $(DEBIAN)/exim4-base.postinst
244 touch build-arch-stamp
245
246 test-stamp: build-arch-stamp
247 # it is not possible to run exim unless the compile-time specified
248 # user exists.
249 if id -u Debian-exim ; then \
250 echo Debian-exim user found, running minimal testsuite ; \
251 chmod +x debian/minimaltest ; \
252 rm -rf $(CURDIR)/test ; \
253 for i in b-exim4-daemon-light/build-$(buildname)/exim \
254 $(daemonbinaries) ;\
255 do mkdir $(CURDIR)/test && \
256 debian/minimaltest $(CURDIR)/test $$i || \
257 { echo testsuite error ; exit 1 ; } ; \
258 rm -rf $(CURDIR)/test ; \
259 done \
260 fi
261 touch $@
262
263 build: build-arch build-indep
264
265 clean: cleanfiles
266
267 cleanfiles:
268 dh_testdir
269 dh_testroot
270
271 debconf-updatepo
272
273 rm -f build-stamp configure-stamp installbase-stamp test-stamp
274
275 # Add here commands to clean up after the build process.
276 [ ! -f Makefile ] || $(MAKE) distclean
277 -rm -rf build-* doc/tmp test/
278 -rm -f EDITME.* unpack-configs-stamp
279 -rm -f $(DEBIAN)/debconf/exim4.conf.template $(DEBIAN)/files \
280 $(DEBIAN)/README.Debian $(DEBIAN)/README.Debian.html \
281 $(DEBIAN)/berkeleydb.sed
282
283 #these are identical for all daemon-* and therefore symlinked
284 @cd $(DEBIAN) && find . -maxdepth 1 \
285 -regex '^\./exim4-daemon-.*\.\(postinst\|prerm\)$$' \
286 -and -not -name 'exim4-daemon-light.*' -print0 \
287 | xargs -0r rm -v
288
289 #pwd
290 chmod 755 $(DEBIAN)/exim-gencert \
291 $(DEBIAN)/lynx-dump-postprocess $(DEBIAN)/script \
292 $(DEBIAN)/exim-adduser
293 dh_clean
294 rm -rf $(BDIRS)
295 # fix broken (0600) permissions in original tarball
296 #find OS doc scripts exim_monitor src util -perm -044 -or -print0 |\
297 # xargs -0r chmod -c og+r
298
299 installbase-stamp: b-exim4-daemon-light/build-$(buildname)/exim debian/README.Debian debian/README.Debian.html
300 dh_testdir
301 dh_testroot
302 dh_prep
303 dh_installdirs
304
305 cd b-exim4-daemon-light && \
306 $(MAKE) install FULLECHO='' \
307 INSTALL_ARG=-no_symlink \
308 inst_conf=$(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf \
309 inst_aliases=$(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/aliases \
310 inst_dest=$(DEBIAN)/exim4-base/usr/sbin
311 if [ -e "$(DEBIAN)/example.conf.md5" ] && [ "$$(< $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum)" != "$$(cat $(DEBIAN)/example.conf.md5)" ] ; then \
312 echo "upstream example configuration has changed, new md5sum:"; \
313 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum; \
314 echo "aborting build."; \
315 exit 1; \
316 fi
317 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf md5sum > $(DEBIAN)/example.conf.md5
318 sed -e 's,/[a-zA-Z/0-9.-]*exim4-base/examples/,/etc/,' \
319 < $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf \
320 > $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf.tmp
321 mv $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf.tmp \
322 $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples/example.conf
323 install -m755 b-exim4-daemon-light/build-$(buildname)/convert4r4 \
324 $(DEBIAN)/exim4-base/usr/sbin/exim_convert4r4
325 install -m755 \
326 b-exim4-daemon-light/build-$(buildname)/transport-filter.pl \
327 b-exim4-daemon-light/util/ratelimit.pl \
328 $(DEBIAN)/exim4-base/usr/share/doc/exim4-base/examples
329 mv $(DEBIAN)/exim4-base/usr/sbin/exim \
330 $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
331 # fix permissions of /usr/sbin/exim4 if running with restrictive umask,
332 # dh_fixperms sanitizes anything else
333 chmod 4755 $(DEBIAN)/exim4-daemon-light/usr/sbin/exim4
334 mv $(DEBIAN)/exim4-base/usr/sbin/eximon \
335 $(DEBIAN)/eximon4/usr/sbin
336 mv $(DEBIAN)/exim4-base/usr/sbin/eximon.bin \
337 $(DEBIAN)/eximon4/usr/lib/exim4
338 pod2man --center=EXIM4 --section=8 \
339 $(DEBIAN)/exim4-base/usr/sbin/exipick \
340 $(DEBIAN)/exim4-base/usr/share/man/man8/exipick.8
341 pod2man --center=EXIM4 --section=8 \
342 $(DEBIAN)/exim4-base/usr/sbin/eximstats \
343 $(DEBIAN)/exim4-base/usr/share/man/man8/eximstats.8
344 install -m755 $(DEBIAN)/syslog2eximlog $(DEBIAN)/exim4-base/usr/sbin/
345 pod2man --center=EXIM4 --section=8 \
346 $(DEBIAN)/syslog2eximlog \
347 $(DEBIAN)/exim4-base/usr/share/man/man8/syslog2eximlog.8
348 # if you change anything here, you will have to change
349 # config-custom/debian/rules as well
350 sed -e \
351 "s/^UPEX4C_version=\"\"/UPEX4C_version=\"$(DEBVERSION)\"/" \
352 < $(DEBIAN)/debconf/update-exim4.conf \
353 > $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
354 chmod 755 $(DEBIAN)/exim4-config/usr/sbin/update-exim4.conf
355 install -m 755 $(DEBIAN)/update-exim4defaults \
356 $(DEBIAN)/exim4-config/usr/sbin
357
358 cd $(DEBIAN)/debconf/conf.d && \
359 tar cf - `find \( -path '*/.svn/*' -prune \) -or \
360 \( -type f -print \)` | \
361 { cd $(DEBIAN)/exim4-config/etc/exim4/conf.d/ && \
362 tar xf - ; }
363
364 # ship a copy in examples
365 # install -m644 $(DEBIAN)/debconf/exim4.conf.template $(DEBIAN)/exim4-config/usr/share/doc/exim4-config/examples/exim4.conf.template.debconf
366 install -m644 $(DEBIAN)/email-addresses $(DEBIAN)/exim4-config/etc/
367 install -m640 -oroot -groot $(DEBIAN)/passwd.client \
368 $(DEBIAN)/exim4-config/etc/exim4/
369 chmod 755 $(DEBIAN)/debconf/update-exim4.conf.template
370 env CONFDIR=$(DEBIAN)/debconf \
371 $(DEBIAN)/debconf/update-exim4.conf.template --nobackup --run
372 # dh_movefiles
373 touch installbase-stamp
374
375
376 # This dependency expands to
377 # debian/exim4-daemon-heavy/usr/sbin/exim4: b-exim4-daemon-heavy/build-Linux-x86_64/exim
378 $(debiandaemonbinaries): $(DEBIAN)/%/usr/sbin/exim4: b-%/build-$(buildname)/exim
379 dh_testdir
380 dh_testroot
381 dh_installdirs
382 install -m4755 -oroot -groot $< $@
383
384
385 # Build architecture-independent files here.
386 # this is just exim4-config and exim4.
387 binary-indep: build $(install)
388 ifeq ($(buildbasepackages),yes)
389 dh_testdir -i
390 dh_testroot -i
391 # upstream changelog is only in exim4-base
392 dh_link -i
393 dh_installchangelogs -i -XCHANGES
394 dh_installdocs -i
395 dh_installexamples -i
396 #dh_installmenu -i
397 dh_installdebconf -i
398 dh_installlogrotate -i
399 # dh_installemacsen -i
400 #dh_installpam -i
401 #dh_installmime -i
402 # dh_installinit -i
403 dh_installcron -i
404 # dh_installinfo -i
405 # dh_undocumented -i
406 dh_installppp -i --name=exim4
407 dh_installman -i
408 dh_install -i
409 dh_lintian -i
410 dh_strip $(dhcombinedidbgpackage) $(dhstripparm)
411 #for pkg in $(extraidbgpackage); do \
412 # dh_strip -p$$pkg --dbg-package=$${pkg}-dbg; \
413 #done
414 dh_compress -i
415 dh_fixperms -i -X/etc/exim4/passwd.client
416 # dh_makeshlibs -i
417 dh_installdeb -i
418 # dh_perl -i
419 dh_shlibdeps -i
420 dh_gencontrol -i -- -VUpstream-Version=$(UPSTREAMVERSION) \
421 -VMTA-Conflicts="$(MTACONFLICTS)"
422 dh_md5sums -i
423 dh_builddeb -i
424 endif
425
426 # Build architecture-dependent files here.
427 ifeq ($(buildbasepackages),yes)
428 install=installbase-stamp $(debiandaemonbinaries)
429 else
430 install=$(debiandaemonbinaries)
431 endif
432
433 binary-arch: build $(install)
434 dh_testdir $(dhbuildpackages)
435 dh_testroot $(dhbuildpackages)
436 # symlink identical maintainerscripts
437 @for i in $(extradaemonpackages) ; do \
438 ln -sfv exim4-daemon-light.prerm \
439 "$(DEBIAN)/$$i.prerm" ; \
440 ln -sfv exim4-daemon-light.postinst \
441 "$(DEBIAN)/$$i.postinst" ; \
442 done
443 # upstream changelog is only in exim4-base, the other packages include
444 # a symlink
445 dh_installchangelogs -pexim4-base doc/ChangeLog
446 # remove "-pexim4-base" from "-pexim4-base -pexim4-daemon-light ..."
447 dh_installchangelogs $(subst -pexim4-base ,,$(dhbuildpackages)) \
448 -XCHANGES
449 dh_installdocs $(dhbuildpackages)
450 dh_installexamples $(dhbuildpackages)
451 dh_installmenu $(dhbuildpackages)
452 dh_installdebconf $(dhbuildpackages)
453 dh_installlogrotate $(dhbuildpackages)
454 dh_installlogrotate $(dhbuildpackages) --name=exim4-paniclog
455 # dh_installemacsen $(dhbuildpackages)
456 dh_installpam $(dhbuildpackages)
457 dh_installmime $(dhbuildpackages)
458 #dh_installinit $(dhbuildpackages) --noscripts --name=exim4
459 # work around #347577 (fixed in debhelper 5.0.15)
460 dh_installinit $(dhbuildpackages) -n --name=exim4
461 dh_installcron $(dhbuildpackages)
462 # dh_installinfo $(dhbuildpackages)
463 # dh_undocumented $(dhbuildpackages)
464 dh_installman $(dhbuildpackages)
465 dh_install $(dhbuildpackages)
466 # install config.h from daemon package, but not from exim4-daemon-light
467 dh_install -p exim4-dev \
468 $(shell ls -1 b-exim4-daemon-*/build-$(buildname)/config.h | grep -v ^b-exim4-daemon-light/) \
469 usr/include/exim4
470 dh_lintian $(dhbuildpackages)
471 dh_strip $(dhcombinedadbgpackage) $(dhstripparm)
472 for pkg in $(extraadbgpackage); do \
473 dh_strip -p$$pkg --dbg-package=$${pkg}-dbg; \
474 done
475 dh_link $(dhbuildpackages)
476 dh_compress $(dhbuildpackages)
477 dh_fixperms $(dhbuildpackages) -Xusr/sbin/exim4
478 # dh_makeshlibs $(dhbuildpackages)
479 dh_installdeb $(dhbuildpackages)
480 # dh_perl $(dhbuildpackages)
481 dh_shlibdeps $(dhbuildpackages)
482 dh_gencontrol $(dhbuildpackages) -- \
483 -VUpstream-Version=$(UPSTREAMVERSION) \
484 -VMTA-Conflicts="$(MTACONFLICTS)"
485 dh_md5sums $(dhbuildpackages)
486 dh_builddeb $(dhbuildpackages)
487
488 binary: binary-arch binary-indep
489 .PHONY: build clean binary-indep binary-arch binary install