1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
#!/usr/bin/make -f
#------------------------------------------------------------------------------
# vim: syntax=make
#
# $Sendmail: rules,v 8.14.1 2007-05-27 18:30:00 cowboy Exp $
#------------------------------------------------------------------------------
# CDBS crud
#include /usr/share/cdbs/1/class/makefile.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk
# Overridden below, but needed now
#DEB_TAR_SRCDIR := .
#include /usr/share/cdbs/1/rules/tarball.mk
# Determine architecture
DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
# Make it even harder to exploit sendmail.
# Well, almost impossible now 8-)
# * Compile all with -fPIC (works for pic or pie objects)
# * Link with either -pie or -shared
dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" dpkg-buildflags
CFLAGS := $(shell $(dpkg_buildflags) --get CFLAGS)
CFLAGS += -fPIC
ifneq (,$(filter -fstack-protector,$(CFLAGS)))
CFLAGS += -fstack-protector-all
endif
CXXFLAGS := $(shell $(dpkg_buildflags) --get CXXFLAGS)
CPPFLAGS := $(shell $(dpkg_buildflags) --get CPPFLAGS)
LDFLAGS := $(shell $(dpkg_buildflags) --get LDFLAGS)
LDFLAGS += -Wl,-z,noexecstack -Wl,--warn-shared-textrel
LDFLAGS += -fpie
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
# Obtain package/version information from the path (debian/changelog is walkabout)
ifneq (y, $(shell test -f debian/changelog && echo 'y'))
DIRNAME = $(shell basename $(CURDIR))
DEB_SOURCE_PACKAGE = $(shell expr "$(DIRNAME)" : '\(.*\)-')
DEB_VERSION = $(shell expr "$(DIRNAME)" : '.*-\(.*\)')
DEB_NOEPOCH_VERSION = $(shell echo $(DEB_VERSION) | cut -d: -f2-)
DEB_UPSTREAM_VERSION = $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
endif
# strip of a optionally added data (ie: upstream+cvs-debian)
DEB_UPSTREAM_TARBALL_VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | sed 's/+[^-]*//')
DEB_TAR_SRCDIR := $(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_TARBALL_VERSION)
DEB_SRCDIR := build-tree/$(DEB_TAR_SRCDIR)
DEB_BUILDDIR := $(DEB_SRCDIR)
DEB_DESTDIR = $(CURDIR)/${PKG_TMP}
DEB_DBG_PACKAGES = libmilter$(sm_libmilter_version)-dbg
DEB_DBG_PACKAGE_libmilter$(sm_libmilter_version) = libmilter$(sm_libmilter_version)-dbg
DEB_DH_INSTALL_CRON_ARGS = --name=$(DEB_SOURCE_PACKAGE)
DEB_DH_INSTALLINIT_ARGS = --name=$(DEB_SOURCE_PACKAGE)
DEB_UPDATE_RCD_PARAMS = --update-rcd-params="defaults 21 19"
# autoconf/make are mine, not upstream (yet) :(
DEB_CONFIGURE_LIBEXECDIR ="\$${prefix}/lib/sm.bin"
DEB_AC_AUX_DIR = $(CURDIR)/debian/build
DEB_CONFIGURE_SCRIPT = $(CURDIR)/debian/configure
DEB_CONFIGURE_INVOKE = cd $(CURDIR)/debian \
&& $(DEB_CONFIGURE_SCRIPT_ENV) $(DEB_CONFIGURE_SCRIPT) $(DEB_CONFIGURE_NORMAL_ARGS)
DEB_MAKE_INVOKE =
DEB_MAKE_BUILD_TARGET =
DEB_MAKE_INSTALL_TARGET =
DEB_INSTALL_CHANGELOGS_ALL = $(DEB_SRCDIR)/RELEASE_NOTES
DEB_DH_BUGFILES_ARGS_DEFAULT = -A
version_string := ${DEB_VERSION}
version_full := $(shell expr "${version_string}" : '\([^-]*\)')
version_debian := $(shell expr "${version_string}" : '.*\(-.*\)$$')
version := ${version_full}
version_major := $(shell expr "${version_full}" : '\([0-9]*\.[0-9]*\)')
version_minor := $(shell expr "${version_full}" : '[0-9]*\.[0-9]*\.\(.*\)')
ifneq (, $(findstring +,${version_minor}))
beta_version := $(shell expr "${version_full}" : '.*[+~]\([0-9.].*\)')
beta_major := $(shell expr "${beta_version}" : '\([0-9]*\.[0-9]*\)')
beta_minor := $(shell expr "${beta_version}" : '[0-9]*\.[0-9]*\.\(.*\)')
ifneq (, $(beta_version))
version := ${beta_version}
version_major := ${beta_major}
version_minor := ${beta_minor}
endif
endif
# Some variables that should be removed in favour of DEB_* above
SRC_DIR := $(CURDIR)/debian
PKG_DIR := debian/${DEB_SOURCE_PACKAGE}-bin
PKG_DOC = debian/${DEB_SOURCE_PACKAGE}-doc${docdir}/${DEB_SOURCE_PACKAGE}-doc
SM_SUBDIRS := editmap libmilter mail.local mailstats \
makemap praliases rmail sendmail smrsh vacation
PKG_TMP = debian/tmp
# We want delayed interpretation of the options !
ifeq (y, $(shell test -x /usr/bin/debuild && echo 'y'))
DEB_BUILD = \
DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS}" \
debuild
else
DEB_BUILD = \
DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS}" \
dpkg-buildpackage
endif
# Now that all that is out of the way, read the desired configuration
# settings
CONF_NAME = debian/configure.options
$(eval CONFIG_OPTS := $(shell grep -v "^\#" ${CONF_NAME}))
DEB_CONFIGURE_EXTRA_FLAGS = $(CONFIG_OPTS)
# Include Debian Autoconf settings
ifeq (y, $(shell test -e debian/build/autoconf.mk && echo 'y'))
include debian/build/autoconf.mk
else
ifeq (y, $(shell test -e build/autoconf.mk && echo 'y'))
include build/autoconf.mk
else
include debian/build/autoconf.mk.in
endif
endif
include /usr/share/cdbs/1/rules/tarball.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk
DEB_PATCHDIRS = $(CURDIR)/debian/patches/${version_major}/${version_full}
#-------------
# Normalize CDBS rules
.PHONY: unpack
unpack:: pre-build
.PHONY: configure
configure:: common-configure-arch common-configure-indep
#-------------
# Maintainer only rule... refresh debian/configure, debian/*/Makefile.in, and debian/control
AUTOFOODUMMY = debian/AUTHORS debian/COPYING debian/ChangeLog debian/INSTALL debian/NEWS debian/README
AUTOMAKEARGS ?= --force
AUTOMAKEARGS ?= --force --force-missing --add-missing --copy
refresh-debian-configure:
touch $(AUTOFOODUMMY)
# unpack
-debian/rules configure
# regenerate
cd debian && aclocal -I ./build
cd debian && autoconf
cd debian && automake $(AUTOMAKEARGS)
# regenerate more, run twice in case debian/control gets updated
$(RM) debian/stamp-autotools
debian/rules configure || debian/rules configure
# cleanup
fakeroot debian/rules clean
$(RM) debian/aclocal.m4
for f in $(AUTOFOODUMMY) ; do if [ ! -s $$f ]; then $(RM) $$f ; fi; done
#-------------
# Maintainer only rule... cleanup & setup for general package
.PHONY: clean-debian
clean-debian::
@echo 'cleaning debian directory...';
#-(cd debian && $(MAKE) -f Makefile maintainer-clean;)
#-(cd debian && $(MAKE) -f Makefile distclean;)
find debian -name '*~' -o -name '\.*\.swp' \
| xargs -r $(RM);
$(RM) debian/*.sav debian/build/*.sav;
$(RM) debian/stamp-*;
#-------------
# Maintainer only rule... must be run in external debian directory
.PHONY: refresh-faq
refresh-faq::
@echo 'Refreshing FAQ'
@chmod u+w faq.txt;
(wget --passive-ftp --timestamping \
--cache=off http://www.sendmail.org/faq/faq.txt;);
@chmod a-w faq.txt;
@echo 'Refreshing Misc'
@chmod u+w cf/feature/rhsbl.m4;
(cd cf/feature && wget --passive-ftp --timestamping \
--cache=off http://www.megacity.org/software_downloads/rhsbl.m4;);
@chmod u-w cf/feature/rhsbl.m4;
#------------------------------------------------------------------------------
# Build/Package check rules
#------------------------------------------------------------------------------
#-------------
.PHONY: info
info:
#--------------------------------------------------------------------
# The following information will be used for this run:
# Source = ${DEB_SOURCE_PACKAGE}
# Package = ${DEB_SOURCE_PACKAGE} ${DEB_VERSION}
# ${version_string}${sm_custom_s}${version_debian}
# Upstream V = ${DEB_UPSTREAM_TARBALL_VERSION}
# BuildTree = ${DEB_SRCDIR}
# Arch = ${DEB_BUILD_ARCH} on ${DEB_HOST_ARCH}
# Options
# configure = ${CONFIG_OPTS}
# config opt = ${SM_CONF_OPT}
# ENABLE_INDEP= ${ENABLE_INDEP}
# ENABLE_ARCH = ${ENABLE_ARCH}
# ENABLE_DEV = ${ENABLE_DEV}
# ENABLE_DOC = ${ENABLE_DOC}
# compile opt = ${CC} ${CFLAGS} ${DEFINES}
# DEB_BUILD_OPTIONS = ${DEB_BUILD_OPTIONS}
# DH_VERBOSE = ${DH_VERBOSE}
# DH_OPTIONS = ${DH_OPTIONS}
# DH_COMPAT = ${DH_COMPAT}
#--------------------------------------------------------------------
#-------------
.PHONY: verify-tarball
verify-tarball::
#--------------------------------------------------------------------
# verify_tarball:
#
# Verifying the md5 summs and signed files
@dh_testdir;
@for file in $$(find . -maxdepth 1 -name '*.md5'); do \
echo "Checking MD5 source: $$file."; \
cat $$file; \
md5sum -c $$file; \
done;
@for file in $$(find . -maxdepth 1 -name '*.sig'); do \
echo "Checking signature file $$file."; \
part=$$(echo "$$file" | sed -e 's/\.sig$$//'); \
if [ -f $$part ]; then \
gpg --verify $$part.sig $$part || true; \
elif [ -f $$part.gz ]; then \
gunzip -c $$part.gz > $$part; \
gpg --verify $$part.sig $$part || true; \
rm $$part; \
fi; \
done;
#--------------------------------------------------------------------
#------------------------------------------------------------------------------
# User callable rules
#------------------------------------------------------------------------------
#-------------
.PHONY: clean
clean::
#--------------------------------------------------------------------
# clean:
#
# Local stuff
-if [ -f debian/Makefile ]; then \
(cd debian && $(MAKE) -f Makefile clean maintainer-clean;) \
fi;
# Debian stuff
$(RM) -r ${_cdbs_tarball_dir};
$(RM) sendmail*.tar.gz.cdbs-config_list
$(RM) \
debian/config.log \
debian/config.status \
debian/*.debhelper \
debian/control.new \
;
for file in tmp ${DEB_PACKAGES};do \
$(RM) -r debian/$$file; \
done;
#--------------------------------------------------------------------
#-------------
common-build-indep::
#--------------------------------------------------------------------
# build-indep:
#
# sendmail operations guide
(cd ${DEB_SRCDIR}/doc/op/ && GROFF_NO_SGR=1 make op.txt);
# Debian stuff
(cd debian && $(MAKE) -f Makefile build-indep;)
#--------------------------------------------------------------------
#-------------
common-install-indep::
#--------------------------------------------------------------------
# install-indep
#
# Correct some paths in upstream documentation
sed -i \
-e "s?/usr/libexec?${libexecdir}?g" \
-e "s?/usr/ucb/vacation?${libexecdir}/vacation.sendmail?g" \
-e "s?/usr/adm/sm.bin?${sysconfdir}/mail/smrsh?g" \
${DEB_SRCDIR}/smrsh/README
# sendmail operations guide and other documentation
${INSTALL} -d ${PKG_DOC}/op
$(INSTALL_DATA) ${DEB_SRCDIR}/doc/op/op.ps ${PKG_DOC}/op/
$(INSTALL_DATA) ${DEB_SRCDIR}/doc/op/op.txt ${PKG_DOC}/op/
$(INSTALL_DATA) ${DEB_SRCDIR}/README ${PKG_DOC}/
$(INSTALL_DATA) ${DEB_SRCDIR}/KNOWNBUGS ${PKG_DOC}/
$(INSTALL_DATA) ${DEB_SRCDIR}/cf/README ${PKG_DOC}/cf.README
${INSTALL} -d ${PKG_DOC}/sendmail
$(INSTALL_DATA) ${DEB_SRCDIR}/sendmail/README ${PKG_DOC}/sendmail/
$(INSTALL_DATA) ${DEB_SRCDIR}/sendmail/SECURITY ${PKG_DOC}/sendmail/
$(INSTALL_DATA) ${DEB_SRCDIR}/sendmail/TRACEFLAGS ${PKG_DOC}/sendmail/
$(INSTALL_DATA) ${DEB_SRCDIR}/sendmail/TUNING ${PKG_DOC}/sendmail/
$(INSTALL_DATA) ${DEB_SRCDIR}/smrsh/README ${PKG_DOC}/smrsh.README
$(INSTALL_DATA) debian/faq.txt ${PKG_DOC}/
${INSTALL} -d ${PKG_DOC}/libmilter/html
$(INSTALL_DATA) ${DEB_SRCDIR}/libmilter/README ${PKG_DOC}/libmilter/README
cp -a ${DEB_SRCDIR}/libmilter/docs/* ${PKG_DOC}/libmilter/html/
# Debian stuff
$(MAKE) -C debian/cf -f Makefile install-indep DESTDIR="${SRC_DIR}/sendmail-cf"
$(MAKE) -C debian/examples -f Makefile install-indep DESTDIR="${SRC_DIR}/sendmail-base"
$(MAKE) -C debian/local -f Makefile install-indep DESTDIR="${SRC_DIR}/sendmail-base"
#--------------------------------------------------------------------
#-------------
common-build-arch::
#--------------------------------------------------------------------
# build-arch
#
# Place our m4 configuration files for the sendmail build to use
cp -f debian/build/site.config.m4 \
${DEB_SRCDIR}/devtools/Site/; \
# Finally, build the whole enchilada (we'll let sendmail figure
# which, if any of the dependant libraries each component needs)
for subdir in ${SM_SUBDIRS}; do \
if [ -d ${DEB_SRCDIR}/$${subdir} ]; then \
(cd ${DEB_SRCDIR}/$${subdir} && ./Build -S;); \
fi; \
done;
# Debian stuff
(cd debian && $(MAKE) -f Makefile build-arch;)
# Remove our config m4 files
$(RM) ${DEB_SRCDIR}/devtools/Site/site.config.m4;
#--------------------------------------------------------------------
#-------------
common-install-arch::
#--------------------------------------------------------------------
# install-arch
#
# Correct some paths in upstream man pages
sed -i \
-e "s?/usr/adm/sm.bin?${sysconfdir}/mail/smrsh?g" \
${DEB_SRCDIR}/smrsh/smrsh.8
sed -i \
-e "s?/etc/mail/statistics?${localstatedir}/lib/sendmail/sendmail.st?g" \
${DEB_SRCDIR}/sendmail/sendmail.8
# sendmail install proper... with a little help ;-}
$(MAKE) -C ${DEB_SRCDIR} install DESTDIR="$(DEB_DESTDIR)"
$(MAKE) -C ${DEB_SRCDIR}/libmilter install DESTDIR="$(DEB_DESTDIR)"
$(MAKE) -C ${DEB_SRCDIR}/mail.local force-install DESTDIR="$(DEB_DESTDIR)"
# Debian stuff
$(MAKE) -C debian/sensible_mda install-arch DESTDIR="$(DEB_DESTDIR)"
# Handle man pages for the sendmail aliases
mv ${PKG_TMP}${mandir}/man5/aliases.5 \
${PKG_TMP}${mandir}/man5/aliases.sendmail.5
mv ${PKG_TMP}${mandir}/man1/mailq.1 \
${PKG_TMP}${mandir}/man1/mailq.sendmail.1
mv ${PKG_TMP}${mandir}/man1/newaliases.1 \
${PKG_TMP}${mandir}/man8/newaliases.sendmail.8
mv ${PKG_TMP}${mandir}/man8/sendmail.8 \
${PKG_TMP}${mandir}/man8/sendmail.sendmail.8
# Special handling of vacation - Debian has a seperate package
# with a different version (sigh) keep our copy just in case...
mv ${PKG_TMP}${libexecdir}/vacation \
${PKG_TMP}${libexecdir}/vacation.sendmail
mv ${PKG_TMP}${mandir}/man1/vacation.1 \
${PKG_TMP}${mandir}/man1/vacation.sendmail.1
#--------------------------------------------------------------------
#-------------
# CDBS host dh_fixperms fixup
binary-predeb/sendmail-bin::
#--------------------------------------------------------------------
# Proper ownership/modes
chown root:mail ${PKG_DIR}${libexecdir}/sendmail;
chmod 02755 ${PKG_DIR}${libexecdir}/sendmail;
chown root:mail ${PKG_DIR}${libexecdir}/mailstats;
chmod 02755 ${PKG_DIR}${libexecdir}/mailstats;
#--------------------------------------------------------------------
binary-predeb/sensible-mda::
#--------------------------------------------------------------------
# Proper ownership/modes
chmod 04755 debian/sensible-mda/usr/sbin/sensible-mda;
#--------------------------------------------------------------------
#-------------
# after the directories are created but before dh_compress is run.
common-binary-post-install-arch::
#--------------------------------------------------------------------
# Obtain build dependancy information
dh_buildinfo
#--------------------------------------------------------------------
binary-makedeb-IMPL/sendmail:: verify-tarball
|