postfix.spec 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package versions
  26. %define V_postfix 2.0.18
  27. %define V_tls 0.8.16-2.0.18-0.9.7c
  28. %define V_pflogsumm 1.1.0
  29. %define V_whoson 2.0.0.2
  30. # package information
  31. Name: postfix
  32. Summary: Mail Transfer Agent (MTA)
  33. URL: http://www.postfix.org/
  34. Vendor: Wietse Venema
  35. Packager: The OpenPKG Project
  36. Distribution: OpenPKG
  37. Class: BASE
  38. Group: Mail
  39. License: IPL
  40. Version: %{V_postfix}
  41. Release: 20040209
  42. # package options
  43. %option with_fsl yes
  44. %option with_ssl no
  45. %option with_sasl no
  46. %option with_mysql no
  47. %option with_ldap no
  48. %option with_whoson no
  49. %option with_fdsetsize no
  50. # list of sources
  51. Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
  52. Source1: ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-%{V_tls}.tar.gz
  53. Source2: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
  54. Source3: http://sbserv.stahl.bau.tu-bs.de/~hildeb/postfix/scripts/qshape
  55. Source4: etc.tar
  56. Source5: fsl.postfix
  57. Source6: rc.postfix
  58. Patch0: postfix.patch
  59. Patch1: postfix.patch.pfls
  60. Patch2: ftp://victor.teaser.fr/pub/lwa/postfix/postfix-%{V_whoson}-whoson.patch
  61. # build information
  62. Prefix: %{l_prefix}
  63. BuildRoot: %{l_buildroot}
  64. BuildPreReq: OpenPKG, openpkg >= 20040130, perl
  65. PreReq: OpenPKG, openpkg >= 20040130, perl, procmail, perl-time
  66. BuildPreReq: pcre, db
  67. PreReq: pcre, db
  68. %if "%{with_fsl}" == "yes"
  69. BuildPreReq: fsl >= 1.3.0
  70. PreReq: fsl >= 1.3.0
  71. %endif
  72. %if "%{with_ssl}" == "yes"
  73. BuildPreReq: openssl
  74. PreReq: openssl
  75. %endif
  76. %if "%{with_sasl}" == "yes"
  77. BuildPreReq: sasl
  78. PreReq: sasl
  79. %endif
  80. %if "%{with_mysql}" == "yes"
  81. BuildPreReq: mysql
  82. PreReq: mysql
  83. %endif
  84. %if "%{with_ldap}" == "yes"
  85. BuildPreReq: openldap, openssl
  86. PreReq: openldap, openssl
  87. %endif
  88. %if "%{with_whoson}" == "yes"
  89. BuildPreReq: whoson
  90. PreReq: whoson
  91. %endif
  92. AutoReq: no
  93. AutoReqProv: no
  94. Provides: MTA
  95. Conflicts: exim, sendmail, ssmtp
  96. %description
  97. Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
  98. replace the Sendmail MTA.
  99. Local specifics in this OpenPKG version:
  100. o Postfix delivers locally via Procmail
  101. o Postfix logs directly to the filesystem and not via syslog(3)
  102. o Berkeley-DB lookup table support
  103. o PCRE matching support
  104. o Optional STARTTLS support (see package options below)
  105. o Optional SASL2 authentication support (see package options below)
  106. o Optional MySQL support (see package options below)
  107. o Optional OpenLDAP support (see package options below)
  108. o Optional WHOSON support (see package options below)
  109. %track
  110. prog postfix = {
  111. version = %{V_postfix}
  112. url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
  113. regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz
  114. }
  115. prog postfix:pfixtls = {
  116. version = %{V_tls}
  117. url = ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/
  118. regex = pfixtls-([^-]+-[^-]+-[^-]+)\.tar\.gz
  119. }
  120. prog postfix:pflogsumm = {
  121. version = %{V_pflogsumm}
  122. url = http://jimsun.linxnet.com/postfix_contrib.html
  123. regex = pflogsumm-(__VER__)\.tar\.gz
  124. }
  125. prog postfix:qshape = {
  126. disabled
  127. comment = "cs: no tracking possible"
  128. url = http://sbserv.stahl.bau.tu-bs.de/~hildeb/postfix/scripts/
  129. regex = qshape
  130. }
  131. prog postfix:whoson = {
  132. version = %{V_whoson}
  133. url = ftp://victor.teaser.fr/pub/lwa/postfix/
  134. regex = postfix-(__VER__)-whoson.patch
  135. }
  136. %prep
  137. # unpack distribution files
  138. %setup -q
  139. %if "%{with_ssl}" == "yes"
  140. %setup -q -T -D -a 1
  141. %endif
  142. %setup -q -T -D -a 2
  143. %setup -q -T -D -a 4
  144. # apply SSL/TLS patch
  145. %if "%{with_ssl}" == "yes"
  146. %{l_patch} -p1 <pfixtls-%{V_tls}/pfixtls.diff
  147. %endif
  148. # apply OpenLDAP API patch
  149. %patch -p0
  150. # apply pflogsumm patch
  151. ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 <%{PATCH1} ) || exit $?
  152. # apply WHOSON patch
  153. %if "%{with_whoson}" == "yes"
  154. %patch -p0 -P 2
  155. %endif
  156. %build
  157. # configure Postfix (hard-core part I)
  158. %{l_shtool} subst \
  159. -e 's/var_config_dir, /var_command_dir, /' \
  160. src/postfix/postfix.c
  161. %{l_shtool} subst \
  162. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  163. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  164. conf/postfix-script
  165. %{l_shtool} subst \
  166. -e 's;/usr/include;%{l_prefix}/include;g' \
  167. makedefs
  168. # configure Postfix (regular part)
  169. unset LD_LIBRARY_PATH || true
  170. CCARGS=""
  171. CCARGS="$CCARGS %{l_cflags -O}"
  172. CCARGS="$CCARGS %{l_cppflags}"
  173. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
  174. AUXLIBS=""
  175. AUXLIBS="$AUXLIBS %{l_ldflags}"
  176. CCARGS="$CCARGS -DHAS_DB"
  177. AUXLIBS="$AUXLIBS -ldb"
  178. CCARGS="$CCARGS -DHAS_PCRE"
  179. AUXLIBS="$AUXLIBS -lpcre"
  180. %if "%{with_mysql}" == "yes"
  181. CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
  182. AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
  183. %endif
  184. %if "%{with_sasl}" == "yes"
  185. CCARGS="$CCARGS -DUSE_SASL_AUTH %{l_cppflags sasl .}"
  186. AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
  187. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  188. AUXLIBS="$AUXLIBS -ldl"
  189. fi
  190. %endif
  191. %if "%{with_ssl}" == "yes"
  192. CCARGS="$CCARGS -DHAS_SSL"
  193. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  194. %endif
  195. %if "%{with_ldap}" == "yes"
  196. CCARGS="$CCARGS -DHAS_LDAP"
  197. AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
  198. %endif
  199. %if "%{with_fsl}" == "yes"
  200. AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
  201. CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
  202. %endif
  203. %if "%{with_fdsetsize}" != "no"
  204. %if "%{with_fdsetsize}" == "yes"
  205. CCARGS="$CCARGS -DFD_SETSIZE=1024"
  206. %else
  207. CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
  208. %endif
  209. %endif
  210. %{l_make} %{l_mflags} makefiles \
  211. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  212. # configure Postfix (hard-core part II)
  213. %{l_shtool} subst \
  214. -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
  215. -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
  216. src/util/sys_defs.h
  217. # build Postfix
  218. %{l_make} %{l_mflags}
  219. %install
  220. rm -rf $RPM_BUILD_ROOT
  221. # perform standard installation procedure
  222. %{l_shtool} subst -e "s;chown;true;" postfix-install
  223. sh postfix-install -non-interactive \
  224. install_root=$RPM_BUILD_ROOT \
  225. config_directory=%{l_prefix}/etc/postfix \
  226. daemon_directory=%{l_prefix}/libexec/postfix \
  227. command_directory=%{l_prefix}/sbin \
  228. queue_directory=%{l_prefix}/var/postfix \
  229. sendmail_path=%{l_prefix}/sbin/sendmail \
  230. newaliases_path=%{l_prefix}/sbin/newaliases \
  231. mailq_path=%{l_prefix}/sbin/mailq \
  232. manpage_directory=%{l_prefix}/man \
  233. mail_user=%{l_musr} \
  234. setgid_group=%{l_rgrp}
  235. %{l_shtool} install -c -m 755 \
  236. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  237. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  238. # post-adjust binaries
  239. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  240. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  241. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  242. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  243. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  244. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  245. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  246. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  247. # post-adjust configuration
  248. %{l_shtool} subst \
  249. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  250. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  251. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  252. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  253. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  254. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  255. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  256. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  257. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  258. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  259. %{l_shtool} mkdir -f -p -m 755 sample
  260. for cfg in access aliases canonical pcre_table regexp_table \
  261. relocated sample-* transport virtual \
  262. main.cf master.cf main.cf.default; do
  263. mv $cfg sample/
  264. done
  265. ) || exit $?
  266. # install default configuration
  267. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  268. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  269. # pre-create variable stuff
  270. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  271. %{l_shtool} mkdir -f -p -m 700 \
  272. active bounce corrupt defer deferred \
  273. flush incoming private saved
  274. %{l_shtool} mkdir -f -p -m 730 maildrop
  275. %{l_shtool} mkdir -f -p -m 710 public
  276. %{l_shtool} mkdir -f -p -m 755 log pid
  277. ) || exit $?
  278. # install addons
  279. ( cd pflogsumm-%{V_pflogsumm}
  280. %{l_shtool} install -c -m 755 \
  281. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  282. pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  283. %{l_shtool} install -c -m 644 \
  284. pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  285. ) || exit $?
  286. %{l_shtool} install -c -m 750 \
  287. -e 's;^#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \
  288. -e 's;/usr/sbin/postconf;%{l_prefix}/sbin/postconf;' \
  289. %{SOURCE qshape} $RPM_BUILD_ROOT%{l_prefix}/sbin/
  290. # install run-command script
  291. %{l_shtool} mkdir -f -p -m 755 \
  292. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  293. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  294. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  295. # adjust installation to avoid file name conflicts
  296. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  297. mv master.8 postfix_master.8
  298. ) || exit $?
  299. # install OSSP fsl configuration
  300. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  301. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  302. %{SOURCE fsl.postfix} \
  303. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  304. # generate file list
  305. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  306. %{l_files_std} \
  307. '%not %dir %{l_prefix}/etc/fsl' \
  308. '%config %{l_prefix}/etc/fsl/fsl.postfix' \
  309. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
  310. '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  311. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  312. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  313. '%attr(0750,%{l_susr},%{l_mgrp}) %{l_prefix}/sbin/qshape' \
  314. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  315. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
  316. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  317. %files -f files
  318. %clean
  319. rm -rf $RPM_BUILD_ROOT
  320. %pre
  321. # before upgrade, save status and stop service
  322. [ $1 -eq 2 ] || exit 0
  323. eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
  324. %{l_rc} postfix stop 2>/dev/null
  325. exit 0
  326. %post
  327. if [ $1 -eq 1 ]; then
  328. # after install, generate configuration
  329. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
  330. fi
  331. if [ $1 -eq 2 ]; then
  332. # after upgrade, regenerate configuration
  333. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
  334. # after upgrade, restore status
  335. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
  336. [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
  337. fi
  338. exit 0
  339. %preun
  340. # before erase, stop service and remove log files
  341. [ $1 -eq 0 ] || exit 0
  342. %{l_rc} postfix stop 2>/dev/null
  343. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
  344. # remove generated configuration files
  345. ( cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true ) || true
  346. # remove generated run-time files and directories
  347. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  348. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  349. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  350. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  351. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  352. xargs rmdir >/dev/null 2>&1 || true
  353. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  354. xargs rmdir >/dev/null 2>&1 || true
  355. exit 0