postfix.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2003 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.13
  27. %define V_tls 0.8.15-2.0.13-0.9.7b
  28. %define V_pflogsumm 1.0.11
  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 [BASE]
  37. Group: Mail
  38. License: IPL
  39. Version: %{V_postfix}
  40. Release: 20030708
  41. # package options
  42. %option with_fsl yes
  43. %option with_tls no
  44. %option with_sasl no
  45. %option with_mysql no
  46. %option with_ldap no
  47. %option with_whoson no
  48. # list of sources
  49. Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
  50. Source1: ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-%{V_tls}.tar.gz
  51. Source2: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
  52. Source3: etc.tar
  53. Source4: fsl.postfix
  54. Source5: rc.postfix
  55. Patch0: pflogsumm.patch
  56. Patch1: postfix.patch
  57. Patch2: ftp://victor.teaser.fr/pub/lwa/postfix/postfix-%{V_whoson}-whoson.patch
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20030708, perl
  62. PreReq: OpenPKG, openpkg >= 20030708, perl, procmail, perl-time
  63. BuildPreReq: pcre, db
  64. PreReq: pcre, db
  65. %if "%{with_fsl}" == "yes"
  66. BuildPreReq: fsl
  67. PreReq: fsl
  68. %endif
  69. %if "%{with_tls}" == "yes"
  70. BuildPreReq: openssl
  71. PreReq: openssl
  72. %endif
  73. %if "%{with_sasl}" == "yes"
  74. BuildPreReq: sasl
  75. PreReq: sasl
  76. %endif
  77. %if "%{with_mysql}" == "yes"
  78. BuildPreReq: mysql
  79. PreReq: mysql
  80. %endif
  81. %if "%{with_ldap}" == "yes"
  82. BuildPreReq: openldap, openssl
  83. PreReq: openldap, openssl
  84. %endif
  85. %if "%{with_whoson}" == "yes"
  86. BuildPreReq: whoson
  87. PreReq: whoson
  88. %endif
  89. AutoReq: no
  90. AutoReqProv: no
  91. Provides: MTA
  92. Conflicts: sendmail, ssmtp, exim
  93. %description
  94. Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
  95. replace the Sendmail MTA.
  96. Local specifics in this OpenPKG version:
  97. o Postfix delivers locally via Procmail
  98. o Postfix logs directly to the filesystem and not via syslog(3)
  99. o Berkeley-DB lookup table support
  100. o PCRE matching support
  101. o Optional STARTTLS support (see package options below)
  102. o Optional SASL2 authentication support (see package options below)
  103. o Optional MySQL support (see package options below)
  104. o Optional OpenLDAP support (see package options below)
  105. o Optional WHOSON support (see package options below)
  106. %prep
  107. # unpack distribution files
  108. %setup0 -q
  109. %if "%{with_tls}" == "yes"
  110. %setup1 -q -T -D -a 1
  111. %endif
  112. %setup2 -q -T -D -a 2
  113. %setup3 -q -T -D -a 3
  114. # apply external TLS patches
  115. %if "%{with_tls}" == "yes"
  116. %{l_patch} -p1 <pfixtls-%{V_tls}/pfixtls.diff
  117. %endif
  118. # apply pflogsumm patch
  119. ( cd pflogsumm-%{V_pflogsumm}; %{l_patch} -p0 <%{SOURCE pflogsumm.patch} )
  120. # drop deprecated openldap API
  121. %patch1 -p0
  122. %if "%{with_whoson}" == "yes"
  123. %patch2 -p0
  124. %endif
  125. %build
  126. # configure Postfix (hard-core part I)
  127. %{l_shtool} subst \
  128. -e 's/var_config_dir, /var_command_dir, /' \
  129. src/postfix/postfix.c
  130. %{l_shtool} subst \
  131. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  132. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  133. conf/postfix-script
  134. %{l_shtool} subst \
  135. -e 's;/usr/include;%{l_prefix}/include;g' \
  136. makedefs
  137. # configure Postfix (regular part)
  138. unset LD_LIBRARY_PATH || true
  139. CCARGS=""
  140. CCARGS="$CCARGS %{l_cflags -O}"
  141. CCARGS="$CCARGS %{l_cppflags}"
  142. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
  143. AUXLIBS=""
  144. AUXLIBS="$AUXLIBS %{l_ldflags}"
  145. CCARGS="$CCARGS -DHAS_DB"
  146. AUXLIBS="$AUXLIBS -ldb"
  147. CCARGS="$CCARGS -DHAS_PCRE"
  148. AUXLIBS="$AUXLIBS -lpcre"
  149. %if "%{with_mysql}" == "yes"
  150. CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags . -mysql}"
  151. AUXLIBS="$AUXLIBS %{l_ldflags . -mysql} -lmysqlclient -lz -lm"
  152. %endif
  153. %if "%{with_sasl}" == "yes"
  154. CCARGS="$CCARGS -DUSE_SASL_AUTH %{l_cppflags . -sasl}"
  155. AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
  156. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  157. AUXLIBS="$AUXLIBS -ldl"
  158. fi
  159. %endif
  160. %if "%{with_tls}" == "yes"
  161. CCARGS="$CCARGS -DHAS_SSL"
  162. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  163. %endif
  164. %if "%{with_ldap}" == "yes"
  165. CCARGS="$CCARGS -DHAS_LDAP"
  166. AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
  167. %endif
  168. AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
  169. %{l_make} %{l_mflags} makefiles \
  170. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  171. # configure Postfix (hard-core part II)
  172. %{l_shtool} subst \
  173. -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
  174. -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
  175. src/util/sys_defs.h
  176. # build Postfix
  177. %{l_make} %{l_mflags}
  178. %install
  179. rm -rf $RPM_BUILD_ROOT
  180. # perform standard installation procedure
  181. %{l_shtool} subst -e "s;chown;true;" postfix-install
  182. sh postfix-install -non-interactive \
  183. install_root=$RPM_BUILD_ROOT \
  184. config_directory=%{l_prefix}/etc/postfix \
  185. daemon_directory=%{l_prefix}/libexec/postfix \
  186. command_directory=%{l_prefix}/sbin \
  187. queue_directory=%{l_prefix}/var/postfix \
  188. sendmail_path=%{l_prefix}/sbin/sendmail \
  189. newaliases_path=%{l_prefix}/sbin/newaliases \
  190. mailq_path=%{l_prefix}/sbin/mailq \
  191. manpage_directory=%{l_prefix}/man \
  192. mail_user=%{l_musr} \
  193. setgid_group=%{l_rgrp}
  194. %{l_shtool} install -c -m 755 \
  195. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  196. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  197. # post-adjust binaries
  198. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  199. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  200. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  201. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  202. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  203. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  204. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  205. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  206. # post-adjust configuration
  207. %{l_shtool} subst \
  208. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  209. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  210. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  211. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  212. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  213. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  214. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  215. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  216. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  217. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  218. %{l_shtool} mkdir -f -p -m 755 sample
  219. for cfg in access aliases canonical pcre_table regexp_table \
  220. relocated sample-* transport virtual \
  221. main.cf master.cf main.cf.default; do
  222. mv $cfg sample/
  223. done )
  224. # install default configuration
  225. %{l_shtool} install -c -m 644 \
  226. -e 's;@l_prefix@;%{l_prefix};g' \
  227. -e 's;@l_musr@;%{l_musr};g' \
  228. -e 's;@l_mgrp@;%{l_mgrp};g' \
  229. -e 's;@l_rusr@;%{l_rusr};g' \
  230. -e 's;@l_rgrp@;%{l_rgrp};g' \
  231. -e 's;@l_nusr@;%{l_nusr};g' \
  232. -e 's;@l_ngrp@;%{l_ngrp};g' \
  233. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  234. # pre-create variable stuff
  235. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  236. %{l_shtool} mkdir -f -p -m 700 \
  237. active bounce corrupt defer deferred \
  238. flush incoming private saved
  239. %{l_shtool} mkdir -f -p -m 730 maildrop
  240. %{l_shtool} mkdir -f -p -m 710 public
  241. %{l_shtool} mkdir -f -p -m 755 log pid )
  242. # install addons
  243. ( cd pflogsumm-%{V_pflogsumm}
  244. %{l_shtool} install -c -m 755 \
  245. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  246. pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  247. %{l_shtool} install -c -m 644 \
  248. pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/ )
  249. # install run-command script
  250. %{l_shtool} mkdir -f -p -m 755 \
  251. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  252. %{l_shtool} install -c -m 755 \
  253. -e 's;@l_prefix@;%{l_prefix};g' \
  254. -e 's;@l_susr@;%{l_susr};g' \
  255. -e 's;@l_musr@;%{l_musr};g' \
  256. -e 's;@l_mgrp@;%{l_mgrp};g' \
  257. -e 's;@l_rusr@;%{l_rusr};g' \
  258. -e 's;@l_rgrp@;%{l_rgrp};g' \
  259. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  260. # adjust installation to avoid file name conflicts
  261. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  262. mv master.8 postfix_master.8 )
  263. # install OSSP fsl configuration
  264. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  265. %{l_shtool} install -c -m 644 \
  266. -e 's;@l_prefix@;%{l_prefix};g' \
  267. %{SOURCE fsl.postfix} \
  268. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  269. # generate file list
  270. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  271. %{l_files_std} \
  272. '%not %dir %{l_prefix}/etc/fsl' \
  273. '%config %{l_prefix}/etc/fsl/fsl.postfix' \
  274. '%attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix' \
  275. '%config %attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  276. '%attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  277. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  278. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  279. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/var/postfix' \
  280. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  281. %files -f files
  282. %clean
  283. rm -rf $RPM_BUILD_ROOT
  284. %post
  285. if [ $1 -eq 1 ]; then
  286. # generate logfile with correct owner and permissions
  287. if [ ! -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log ]; then
  288. $RPM_INSTALL_PREFIX/lib/openpkg/shtool \
  289. install -c -m 755 -o %{l_musr} -g %{l_mgrp} \
  290. /dev/null $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log
  291. fi
  292. # generate initial configuration
  293. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} all >/dev/null 2>&1 || true)
  294. elif [ $1 -gt 1 ]; then
  295. # re-generate configuration
  296. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} clean all >/dev/null 2>&1 || true)
  297. # re-load daemon
  298. $RPM_INSTALL_PREFIX/etc/rc postfix reload >/dev/null 2>&1 || true
  299. fi
  300. %preun
  301. if [ $1 -eq 0 ]; then
  302. # stop daemon
  303. $RPM_INSTALL_PREFIX/etc/rc postfix stop >/dev/null 2>&1 || true
  304. # remove generated configuration files
  305. (cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true)
  306. # remove generated run-time files and directories
  307. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  308. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  309. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  310. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  311. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  312. xargs rmdir >/dev/null 2>&1 || true
  313. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  314. xargs rmdir >/dev/null 2>&1 || true
  315. fi