postfix.spec 10 KB

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