postfix.spec 12 KB

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