postfix.spec 12 KB

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