View Single Post
  #5  
Old 21st April 2009, 17:15
tgxg00 tgxg00 is offline
Junior Member
 
Join Date: Apr 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

1 %define LDAP 2
2 %define MYSQL 1
3 %define PCRE 1
4 %define SASL 2
5 %define TLS 1
6 %define IPV6 1
7 %define POSTDROP_GID 90
8 %define PFLOGSUMM 1
9
10 # On Redhat 8.0.1 and earlier, LDAP is compiled with SASL V1 and won't w ork
11 # if postfix is compiled with SASL V2. So we drop to SASL V1 if LDAP is
12 # requested but use the preferred SASL V2 if LDAP is not requested.
13 # Sometime soon LDAP will build agains SASL V2 and this won't be needed.
14
15 %if %{LDAP} <= 1 && %{SASL} >= 2
16 %undefine SASL
17 %define SASL 1
18 %endif
19
20 %if %{PFLOGSUMM}
21 %define pflogsumm_ver 1.1.0
22 %endif
23
24 # Postfix requires one exlusive uid/gid and a 2nd exclusive gid for its own
25 # use. Let me know if the second gid collides with another package.
26 # Be careful: Redhat's 'mail' user & group isn't unique!
27 %define postfix_uid 89
28 %define postfix_user postfix
29 %define postfix_gid 89
30 %define postfix_group postfix
31 %define postdrop_group postdrop
32 %define maildrop_group %{postdrop_group}
33 %define maildrop_gid %{POSTDROP_GID}
34
35 %define postfix_config_dir %{_sysconfdir}/postfix
36 %define postfix_daemon_dir %{_libexecdir}/postfix
37 %define postfix_command_dir %{_sbindir}
38 %define postfix_queue_dir %{_var}/spool/postfix
39 %define postfix_doc_dir %{_docdir}/%{name}-%{version}
40 %define postfix_sample_dir %{postfix_doc_dir}/samples
41 %define postfix_readme_dir %{postfix_doc_dir}/README_FILES
42
43 Name: postfix
44 Summary: Postfix Mail Transport Agent
45 Version: 2.3.3
46 Release: 2.1%{?dist}
47 Epoch: 2
48 Group: System Environment/Daemons
49 URL: http://www.postfix.org
50 License: IBM Public License
51 PreReq: /sbin/chkconfig, /sbin/service, sh-utils
52 PreReq: fileutils, textutils,
53 PreReq: /usr/sbin/alternatives
54
55 PreReq: %{_sbindir}/groupadd, %{_sbindir}/useradd
56
57 Provides: MTA smtpd smtpdaemon /usr/bin/newaliases
58
59 Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/%{name }-%{version}.tar.gz
60 Source1: postfix-etc-init.d-postfix
61 Source3: README-Postfix-SASL-RedHat.txt
62
63 # Sources 50-99 are upstream [patch] contributions
64
65 %if %{PFLOGSUMM}
66 # Postfix Log Entry Summarizer: http://jimsun.linxnet.com/postfix_contri b.html
67 Source53: http://jimsun.linxnet.com/downloads/pflogsumm-%{pflogsumm_ver} .tar.gz
68 %endif
69
70 # Sources >= 100 are config files
71
72 Source100: postfix-sasl.conf
73 Source101: postfix-pam.conf
74
75 # Patches
76
77 Patch0: postfix-2.3.3-vda.patch
78 Patch1: postfix-2.1.1-config.patch
79 Patch3: postfix-alternatives.patch
80 Patch6: postfix-2.1.1-obsolete.patch
81 Patch7: postfix-2.1.5-aliases.patch
82 Patch8: postfix-large-fs.patch
83 Patch9: postfix-2.2.5-cyrus.patch
84 Patch10: postfix-CVE-2008-2936.patch
85
86 # Optional patches - set the appropriate environment variables to includ e
87 # them when building the package/spec file
88
89 BuildRoot: %{_tmppath}/%{name}-buildroot
90
91 # Determine the different packages required for building postfix
92 BuildRequires: gawk, perl, sed, ed, db4-devel, pkgconfig, zlib-devel
93
94 Requires: setup >= 2.5.36-1
95 BuildRequires: setup >= 2.5.36-1
96
97 %if %{LDAP}
98 BuildRequires: openldap >= 2.0.27, openldap-devel >= 2.0.27
99 Requires: openldap >= 2.0.27
100 %endif
101
102 %if %{SASL}
103 BuildRequires: cyrus-sasl >= 2.1.10, cyrus-sasl-devel >= 2.1.10
104 Requires: cyrus-sasl >= 2.1.10
105 %endif
106
107 %if %{PCRE}
108 Requires: pcre
109 BuildRequires: pcre, pcre-devel
110 %endif
111
112 %if %{MYSQL}
113 Requires: mysql
114 BuildRequires: mysql, mysql-devel
115 %endif
116
117 %if %{TLS}
118 Requires: openssl
119 BuildRequires: openssl-devel >= 0.9.6
120 %endif
121
122 Provides: /usr/sbin/sendmail /usr/bin/mailq /usr/bin/rmail
123
124 %description
125 Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SAS L),
126 TLS
127
128 %prep
129 umask 022
130
131 %setup -q
132 # Apply obligatory patches
133 %patch0 -pl -b .vda
134 %patch1 -p1 -b .config
135 %patch3 -p1 -b .alternatives
136 %patch6 -p1 -b .obsolete
137 %patch7 -p1 -b .aliases
138 %patch8 -p1 -b .large-fs
139 %patch9 -p1 -b .cyrus
140 %patch10 -p1 -b .CVE-2008-2936
141
142 %if %{PFLOGSUMM}
143 gzip -dc %{SOURCE53} | tar xf -
144 pushd pflogsumm-%{pflogsumm_ver}
145 patch -p0 < ../pflogsumm-conn-delays-dsn-patch
146 popd
147 %endif
148
149 # pflogsumm subpackage
150 %if %{PFLOGSUMM}
151 %package pflogsumm
152 Group: System Environment/Daemons
153 Summary: A Log Summarizer/Analyzer for the Postfix MTA
154 Requires: perl-Date-Calc
155 %description pflogsumm
156 Pflogsumm is a log analyzer/summarizer for the Postfix MTA. It is
157 designed to provide an over-view of Postfix activity. Pflogsumm
158 generates summaries and, in some cases, detailed reports of mail
159 server traffic volumes, rejected and bounced email, and server
160 warnings, errors and panics.
161
162 %endif
163
164 %build
165 umask 022
166
167 CCARGS=-fPIC
168 AUXLIBS=
169
170 %ifarch s390 s390x ppc
171 CCARGS="${CCARGS} -fsigned-char"
172 %endif
173
174 %if %{LDAP}
175 CCARGS="${CCARGS} -DHAS_LDAP -DLDAP_DEPRECATED=1"
176 AUXLIBS="${AUXLIBS} -L%{_libdir} -lldap -llber"
177 %endif
178 %if %{PCRE}
179 # -I option required for pcre 3.4 (and later?)
180 CCARGS="${CCARGS} -DHAS_PCRE -I/usr/include/pcre"
181 AUXLIBS="${AUXLIBS} -lpcre"
182 %endif
183 %if %{MYSQL}
184 CCARGS="${CCARGS} -DHAS_MYSQL -I/usr/include/mysql"
185 AUXLIBS="${AUXLIBS} -L%{_libdir}/mysql -lmysqlclient -lm"
186 %endif
187 %if %{SASL}
188 %define sasl_v1_lib_dir %{_libdir}/sasl
189 %define sasl_v2_lib_dir %{_libdir}/sasl2
190 CCARGS="${CCARGS} -DUSE_SASL_AUTH -DUSE_CYRUS_SASL"
191 %if %{SASL} <= 1
192 %define sasl_lib_dir %{sasl_v1_lib_dir}
193 AUXLIBS="${AUXLIBS} -L%{sasl_lib_dir} -lsasl"
194 %else
195 %define sasl_lib_dir %{sasl_v2_lib_dir}
196 CCARGS="${CCARGS} -I/usr/include/sasl"
197 AUXLIBS="${AUXLIBS} -L%{sasl_lib_dir} -lsasl2"
198 %endif
199 %endif
200 %if %{TLS}
201 if pkg-config openssl ; then
202 CCARGS="${CCARGS} -DUSE_TLS `pkg-config --cflags openssl`"
203 AUXLIBS="${AUXLIBS} `pkg-config --libs openssl`"
204 else
205 CCARGS="${CCARGS} -DUSE_TLS -I/usr/include/openssl"
206 AUXLIBS="${AUXLIBS} -lssl -lcrypto"
207 fi
208 %endif
209 %if %{IPV6} != 1
210 CCARGS="${CCARGS} -DNO_IPV6"
211 %endif
212
213 AUXLIBS="${AUXLIBS} -pie -Wl,-z,relro"
214
215 export CCARGS AUXLIBS
216 make -f Makefile.init makefiles
217
218 unset CCARGS AUXLIBS
219 make DEBUG="" OPT="$RPM_OPT_FLAGS"
220
221 %install
222 umask 022
223 /bin/rm -rf $RPM_BUILD_ROOT
224 /bin/mkdir -p $RPM_BUILD_ROOT
225
226 # install postfix into $RPM_BUILD_ROOT
227
228 # Move stuff around so we don't conflict with sendmail
229 mv man/man1/mailq.1 man/man1/mailq.postfix.1
230 mv man/man1/newaliases.1 man/man1/newaliases.postfix.1
231 mv man/man1/sendmail.1 man/man1/sendmail.postfix.1
232 mv man/man5/aliases.5 man/man5/aliases.postfix.5
233
234 sh postfix-install -non-interactive \
235 install_root=$RPM_BUILD_ROOT \
236 config_directory=%{postfix_config_dir} \
237 daemon_directory=%{postfix_daemon_dir} \
238 command_directory=%{postfix_command_dir} \
239 queue_directory=%{postfix_queue_dir} \
240 sendmail_path=%{postfix_command_dir}/sendmail.postfix \
241 newaliases_path=%{_bindir}/newaliases.postfix \
242 mailq_path=%{_bindir}/mailq.postfix \
243 mail_owner=%{postfix_user} \
244 setgid_group=%{maildrop_group} \
245 manpage_directory=%{_mandir} \
246 sample_directory=%{postfix_sample_dir} \
247 readme_directory=%{postfix_readme_dir} || exit 1
248
249 # This installs into the /etc/rc.d/init.d directory
250 /bin/mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
251 install -c %{_sourcedir}/postfix-etc-init.d-postfix \
252 $RPM_BUILD_ROOT/etc/rc.d/init.d/postfix
253
254 install -c auxiliary/rmail/rmail $RPM_BUILD_ROOT%{_bindir}/rmail.postfix
255
256 for i in active bounce corrupt defer deferred flush incoming private sav ed maildrop public pid saved trace; do
257 mkdir -p $RPM_BUILD_ROOT%{postfix_queue_dir}/$i
258 done
259
260 # install performance benchmark tools by hand
261 for i in smtp-sink smtp-source ; do
262 install -c -m 755 bin/$i $RPM_BUILD_ROOT%{postfix_command_dir}/
263 install -c -m 755 man/man1/$i.1 $RPM_BUILD_ROOT%{_mandir}/man1/
264 done
265
266 # RPM compresses man pages automatically.
267 # - Edit postfix-files to reflect this, so post-install won't get confus ed
268 # when called during package installation.
269 ed $RPM_BUILD_ROOT%{postfix_config_dir}/postfix-files <<EOF || exit 1
270 %s/\(\/man[158]\/.*\.[158]\):/\1.gz:/
271 %s/\$config_directory\/aliases:f/\#/
272 w
273 q
274 EOF
275
276 perl -i -pe 's:/cyrus/bin/deliver:/usr/lib/cyrus-imapd/deliver:' $RPM_BU ILD_ROOT%{postfix_config_dir}/master.cf
277
278 cat $RPM_BUILD_ROOT%{postfix_config_dir}/postfix-files
279 %if %{SASL}
280 # Install the smtpd.conf file for SASL support.
281 # See README-Postfix-SASL-RedHat.txt for why we need to set saslauthd_ve rsion
282 # in the v1 version of smtpd.conf
283 mkdir -p $RPM_BUILD_ROOT%{sasl_v1_lib_dir}
284 install -m 644 %{SOURCE100} $RPM_BUILD_ROOT%{sasl_v1_lib_dir}/smtpd.conf
285 echo "saslauthd_version: 2" >> $RPM_BUILD_ROOT%{sasl_v1_lib_dir}/smtpd.c onf
286
287 mkdir -p $RPM_BUILD_ROOT%{sasl_v2_lib_dir}
288 install -m 644 %{SOURCE100} $RPM_BUILD_ROOT%{sasl_v2_lib_dir}/smtpd.conf
289 %endif
290
291 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pam.d
292 install -m 644 %{SOURCE101} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/smtp.postfix
293
294 # Install Postfix Red Hat HOWTO.
295 mkdir -p $RPM_BUILD_ROOT%{postfix_doc_dir}
296 install -c %{SOURCE3} $RPM_BUILD_ROOT%{postfix_doc_dir}
297
298 %if %{PFLOGSUMM}
299 install -c -m 644 pflogsumm-%{pflogsumm_ver}/pflogsumm-faq.txt $RPM_BUIL D_ROOT%{postfix_doc_dir}/pflogsumm-faq.txt
300 install -c -m 644 pflogsumm-%{pflogsumm_ver}/pflogsumm.1 $RPM_BUILD_ROOT %{_mandir}/man1/pflogsumm.1
301 install -c pflogsumm-%{pflogsumm_ver}/pflogsumm.pl $RPM_BUILD_ROOT%{post fix_command_dir}/pflogsumm
302 %endif
303
304 # install qshape
305 mantools/srctoman - auxiliary/qshape/qshape.pl > qshape.1
306 install -c qshape.1 $RPM_BUILD_ROOT%{_mandir}/man1/qshape.1
307 install -c auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{postfix_command_d ir}/qshape
308
309 rm -f $RPM_BUILD_ROOT/etc/postfix/aliases
310
311 mkdir -p $RPM_BUILD_ROOT/usr/lib
312 pushd $RPM_BUILD_ROOT/usr/lib
313 ln -sf ../sbin/sendmail.postfix .
314 popd
315
316 %post
317 umask 022
318
319 /sbin/chkconfig --add postfix
320
321 # upgrade configuration files if necessary
322 %{_sbindir}/postfix set-permissions upgrade-configuration \
323 config_directory=%{postfix_config_dir} \
324 daemon_directory=%{postfix_daemon_dir} \
325 command_directory=%{postfix_command_dir} \
326 mail_owner=%{postfix_user} \
327 setgid_group=%{maildrop_group} \
328 manpage_directory=%{_mandir} \
329 sample_directory=%{postfix_sample_dir} \
330 readme_directory=%{postfix_readme_dir}
331
332 %{_sbindir}/alternatives --install %{postfix_command_dir}/sendmail mta % {postfix_command_dir}/sendmail.postfix 30 \
333 --slave %{_bindir}/mailq mta-mailq %{_bindir}/mailq.postfix \
334 --slave %{_bindir}/newaliases mta-newaliases %{_bindir}/newalias es.postfix \
335 --slave %{_sysconfdir}/pam.d/smtp mta-pam %{_sysconfdir}/pam.d/s mtp.postfix \
336 --slave %{_bindir}/rmail mta-rmail %{_bindir}/rmail.postfix \
337 --slave /usr/lib/sendmail mta-sendmail /usr/lib/sendmail.postfix \
338 --slave %{_mandir}/man1/mailq.1.gz mta-mailqman %{_mandir}/man1/ mailq.postfix.1.gz \
339 --slave %{_mandir}/man1/newaliases.1.gz mta-newaliasesman %{_man dir}/man1/newaliases.postfix.1.gz \
340 --slave %{_mandir}/man8/sendmail.8.gz mta-sendmailman %{_mandir} /man1/sendmail.postfix.1.gz \
341 --slave %{_mandir}/man5/aliases.5.gz mta-aliasesman %{_mandir}/m an5/aliases.postfix.5.gz \
342 --initscript postfix
343
344 %pre
345 # Add user and groups if necessary
346 %{_sbindir}/groupadd -g %{maildrop_gid} -r %{maildrop_group} 2>/dev/null
347 %{_sbindir}/groupadd -g %{postfix_gid} -r %{postfix_group} 2>/dev/null
348 %{_sbindir}/groupadd -g 12 -r mail 2>/dev/null
349 %{_sbindir}/useradd -d %{postfix_queue_dir} -s /sbin/nologin -g %{postfi x_group} -G mail -M -r -u %{postfix_uid} %{postfix_user} 2>/dev/null
350 exit 0
351
352 %preun
353 umask 022
354
355 if [ "$1" = 0 ]; then
356 # stop postfix silently, but only if it's running
357 /sbin/service postfix stop &>/dev/null
358 /sbin/chkconfig --del postfix
359 /usr/sbin/alternatives --remove mta %{postfix_command_dir}/sendmail. postfix
360 fi
361
362 exit 0
363
364 %postun
365 if [ "$1" != 0 ]; then
366 /sbin/service postfix condrestart 2>&1 > /dev/null
367 fi
368 exit 0
369
370 %clean
371 /bin/rm -rf $RPM_BUILD_ROOT
372
373
374 %files
375
376 # For correct directory permissions check postfix-install script.
377 # It reads the file postfix-files which defines the ownership
378 # and permissions for all files postfix installs, we avoid explicitly
379 # setting anything in the %files sections that is handled by
380 # the upstream install script so we don't have an issue with keeping
Reply With Quote