postfix.spec 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 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. %define V_postfix 1.1.3
  26. %define V_ipv6 20010228pl04-v6-20010913a
  27. %define V_tls 0.7.13-20010228-pl08-0.9.6b
  28. %define V_pflogsumm 1.0.3
  29. # build options
  30. # (attention: ipv6 and tls at the same time conflicts!)
  31. %define with_ipv6 no
  32. %define with_tls no
  33. # package information
  34. Name: postfix
  35. Summary: Mail Transfer Agent (MTA)
  36. URL: http://www.postfix.org/
  37. Vendor: Wietse Venema
  38. Packager: The OpenPKG Project
  39. Distribution: OpenPKG [REL]
  40. Group: Mail
  41. License: IPL
  42. Version: %{V_postfix}
  43. Release: 20020205
  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: fakesyslog.tar.gz
  48. Source3: ftp://ftp.kame.net/pub/kame/misc/postfix-%{V_ipv6}.diff.gz
  49. Source4: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.pl
  50. Source5: rc.postfix
  51. Source6: etc.tar
  52. # build information
  53. Prefix: %{l_prefix}
  54. BuildRoot: %{l_buildroot}
  55. BuildPreReq: OpenPKG, openpkg >= 20020204, perl
  56. PreReq: OpenPKG, openpkg >= 20020204, perl, procmail
  57. BuildPreReq: db, pcre
  58. %if "%{with_tls}" == "yes"
  59. BuildPreReq: openssl
  60. %endif
  61. %if "%{with_ipv6}" == "yes" || "%{with_tls}" == "yes"
  62. BuildPreReq: patch
  63. %endif
  64. AutoReq: no
  65. AutoReqProv: no
  66. Provides: MTA
  67. %description
  68. Postfix is a new-generation Mail Transfer Agent (MTA) able to
  69. fully replace the Sendmail MTA.
  70. Local specifics in this OpenPKG version:
  71. o Postfix delivers locally via Procmail
  72. o Postfix logs directly to the filesystem and not via syslog(3)
  73. o Optional IPv6 support
  74. o Optional STARTTLS support
  75. o Optional Berkeley-DB lookup table support
  76. o Optional PCRE matching support
  77. %prep
  78. %setup0 -q -c -a 0
  79. %if "%{with_tls}" == "yes"
  80. %setup1 -q -T -D -a 1
  81. %endif
  82. %setup2 -q -T -D -a 2
  83. %setup6 -q -T -D -a 6
  84. cd postfix-%{V_postfix}
  85. %if "%{with_ipv6}" == "yes"
  86. %{l_gzip} -d -c %{SOURCE postfix-%{V_ipv6}.diff.gz} |\
  87. %{l_perl} -e 'my $c = ""; $c .= $_ while (<STDIN>);
  88. $c =~ s/(^|\n)diff[^\n]+(\.indent\.pro|\.cvsignore).+?(?=\ndiff)//sg;
  89. print $c;' |\
  90. %{l_patch} -p1
  91. %endif
  92. %if "%{with_tls}" == "yes"
  93. %{l_patch} -p1 < ../pfixtls-%{V_tls}/pfixtls.diff
  94. %endif
  95. %{l_shtool} subst \
  96. -e 's/var_config_dir, /var_command_dir, /' \
  97. src/postfix/postfix.c
  98. %{l_shtool} subst \
  99. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  100. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  101. conf/postfix-script*
  102. %{l_shtool} subst \
  103. -e 's;/usr/include;%{l_prefix}/include;g' \
  104. makedefs
  105. %{l_shtool} subst \
  106. -e 's;#define HAS_DB;;' \
  107. src/util/sys_defs.h
  108. %build
  109. # build faked syslog(3) library
  110. fakesyslogdir="`pwd`/fakesyslog"
  111. ( cd fakesyslog
  112. CC="%{l_cc}" \
  113. CFLAGS="%{l_cflags -O}" \
  114. ./configure \
  115. --with-logfile=%{l_prefix}/var/postfix/log/postfix.log
  116. %{l_make} %{l_mflags}
  117. )
  118. # configure Postfix
  119. cd postfix-%{V_postfix}
  120. unset LD_LIBRARY_PATH || true
  121. CCARGS=""
  122. CCARGS="$CCARGS %{l_cflags -O}"
  123. CCARGS="$CCARGS -I%{l_prefix}/include"
  124. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\\\\\"%{l_prefix}/etc/postfix\\\\\\\""
  125. AUXLIBS=""
  126. AUXLIBS="$AUXLIBS -L%{l_prefix}/lib"
  127. CCARGS="$CCARGS -DHAS_DB"
  128. AUXLIBS="$AUXLIBS -ldb"
  129. CCARGS="$CCARGS -DHAS_PCRE"
  130. AUXLIBS="$AUXLIBS -lpcre"
  131. %if "%{with_tls}" == "yes"
  132. CCARGS="$CCARGS -DHAS_SSL"
  133. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  134. %endif
  135. AUXLIBS="$AUXLIBS -L$fakesyslogdir -lfakesyslog"
  136. %{l_make} %{l_mflags} makefiles \
  137. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  138. # build Postfix
  139. %{l_make} %{l_mflags -O}
  140. %install
  141. rm -rf $RPM_BUILD_ROOT
  142. # perform standard installation procedure
  143. (
  144. cd postfix-%{V_postfix}
  145. %{l_shtool} subst -e "s;chown;true;" postfix-install
  146. sh postfix-install -non-interactive \
  147. install_root=$RPM_BUILD_ROOT \
  148. config_directory=%{l_prefix}/etc/postfix \
  149. daemon_directory=%{l_prefix}/libexec/postfix \
  150. command_directory=%{l_prefix}/sbin \
  151. queue_directory=%{l_prefix}/var/postfix \
  152. sendmail_path=%{l_prefix}/sbin/sendmail \
  153. newaliases_path=%{l_prefix}/sbin/newaliases \
  154. mailq_path=%{l_prefix}/sbin/mailq \
  155. manpages=%{l_prefix}/man \
  156. mail_user=%{l_musr} \
  157. setgid_group=%{l_rgrp}
  158. %{l_shtool} install -c -m 755 \
  159. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  160. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  161. )
  162. # post-adjust binaries
  163. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  164. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  165. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  167. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  168. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  169. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  170. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  171. # post-adjust configuration
  172. %{l_shtool} subst \
  173. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  174. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  175. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  176. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  177. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  178. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  179. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  180. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  181. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  182. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  183. %{l_shtool} mkdir -f -p -m 755 sample
  184. for cfg in access aliases canonical pcre_table regexp_table \
  185. relocated sample-* transport virtual \
  186. main.cf master.cf main.cf.default; do
  187. mv $cfg sample/
  188. done
  189. )
  190. # install default configuration
  191. %{l_shtool} install -c -m 644 \
  192. -e 's;@l_prefix@;%{l_prefix};g' \
  193. -e 's;@l_musr@;%{l_musr};g' \
  194. -e 's;@l_mgrp@;%{l_mgrp};g' \
  195. -e 's;@l_rusr@;%{l_rusr};g' \
  196. -e 's;@l_rgrp@;%{l_rgrp};g' \
  197. -e 's;@l_nusr@;%{l_nusr};g' \
  198. -e 's;@l_ngrp@;%{l_ngrp};g' \
  199. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  200. # pre-create variable stuff
  201. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  202. %{l_shtool} mkdir -f -p -m 700 active bounce corrupt defer deferred \
  203. flush incoming private saved
  204. %{l_shtool} mkdir -f -p -m 730 maildrop
  205. %{l_shtool} mkdir -f -p -m 710 public
  206. %{l_shtool} mkdir -f -p -m 755 log pid
  207. )
  208. # install addons
  209. %{l_shtool} install -c -m 755 \
  210. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  211. %{SOURCE4} $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  212. # install run-command script
  213. %{l_shtool} mkdir -f -p -m 755 \
  214. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  215. %{l_shtool} install -c -m 755 \
  216. -e 's;@l_prefix@;%{l_prefix};g' \
  217. -e 's;@l_susr@;%{l_susr};g' \
  218. -e 's;@l_musr@;%{l_musr};g' \
  219. -e 's;@l_mgrp@;%{l_mgrp};g' \
  220. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  221. # generate file list
  222. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  223. %{l_files_std} \
  224. '%attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix' \
  225. '%config %attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  226. '%attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  227. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  228. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  229. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/var/postfix' \
  230. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  231. %files -f files
  232. %clean
  233. rm -rf $RPM_BUILD_ROOT
  234. %post
  235. if [ $1 -eq 1 ]; then
  236. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} all >/dev/null 2>&1 || true)
  237. elif [ $1 -gt 1 ]; then
  238. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} clean all >/dev/null 2>&1 || true)
  239. $RPM_INSTALL_PREFIX/etc/rc postfix reload >/dev/null 2>&1 || true
  240. fi
  241. %preun
  242. if [ $1 -eq 0 ]; then
  243. $RPM_INSTALL_PREFIX/etc/rc postfix stop >/dev/null 2>&1 || true
  244. (cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true)
  245. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  246. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  247. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  248. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  249. fi