postfix.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. # involved versions
  26. %define V_postfix 1.1.5
  27. %define V_tls 0.8.5-1.1.5-0.9.6c
  28. %define V_pflogsumm 1.0.4
  29. # build options
  30. %ifndef with_tls
  31. %define with_tls no
  32. %endif
  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: 20020314
  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: etc.tar
  49. Source4: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.pl
  50. Source5: rc.postfix
  51. # build information
  52. Prefix: %{l_prefix}
  53. BuildRoot: %{l_buildroot}
  54. BuildPreReq: OpenPKG, openpkg >= 20020206, perl
  55. PreReq: OpenPKG, openpkg >= 20020206, perl, procmail
  56. BuildPreReq: db, pcre
  57. %if "%{with_tls}" == "yes"
  58. BuildPreReq: openssl, patch
  59. %endif
  60. AutoReq: no
  61. AutoReqProv: no
  62. Provides: MTA
  63. %description
  64. Postfix is a new-generation Mail Transfer Agent (MTA) able to
  65. fully replace the Sendmail MTA.
  66. Local specifics in this OpenPKG version:
  67. o Postfix delivers locally via Procmail
  68. o Postfix logs directly to the filesystem and not via syslog(3)
  69. o Optional IPv6 support
  70. o Optional STARTTLS support
  71. o Optional Berkeley-DB lookup table support
  72. o Optional PCRE matching support
  73. Options: with_tls=%{with_tls}
  74. %prep
  75. %setup0 -q -c -a 0
  76. %if "%{with_tls}" == "yes"
  77. %setup1 -q -T -D -a 1
  78. %endif
  79. %setup2 -q -T -D -a 2
  80. %setup3 -q -T -D -a 3
  81. cd postfix-%{V_postfix}
  82. %if "%{with_tls}" == "yes"
  83. %{l_patch} -p1 < ../pfixtls-%{V_tls}/pfixtls.diff
  84. %endif
  85. %{l_shtool} subst \
  86. -e 's/var_config_dir, /var_command_dir, /' \
  87. src/postfix/postfix.c
  88. %{l_shtool} subst \
  89. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  90. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  91. conf/postfix-script*
  92. %{l_shtool} subst \
  93. -e 's;/usr/include;%{l_prefix}/include;g' \
  94. makedefs
  95. %{l_shtool} subst \
  96. -e 's;#define HAS_DB;;' \
  97. src/util/sys_defs.h
  98. %build
  99. # build faked syslog(3) library
  100. fakesyslogdir="`pwd`/fakesyslog"
  101. ( cd fakesyslog
  102. CC="%{l_cc}" \
  103. CFLAGS="%{l_cflags -O}" \
  104. ./configure \
  105. --with-logfile=%{l_prefix}/var/postfix/log/postfix.log
  106. %{l_make} %{l_mflags}
  107. )
  108. # configure Postfix
  109. cd postfix-%{V_postfix}
  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_tls}" == "yes"
  122. CCARGS="$CCARGS -DHAS_SSL"
  123. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  124. %endif
  125. AUXLIBS="$AUXLIBS -L$fakesyslogdir -lfakesyslog"
  126. %{l_make} %{l_mflags} makefiles \
  127. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  128. # build Postfix
  129. %{l_make} %{l_mflags -O}
  130. %install
  131. rm -rf $RPM_BUILD_ROOT
  132. # perform standard installation procedure
  133. (
  134. cd postfix-%{V_postfix}
  135. %{l_shtool} subst -e "s;chown;true;" postfix-install
  136. sh postfix-install -non-interactive \
  137. install_root=$RPM_BUILD_ROOT \
  138. config_directory=%{l_prefix}/etc/postfix \
  139. daemon_directory=%{l_prefix}/libexec/postfix \
  140. command_directory=%{l_prefix}/sbin \
  141. queue_directory=%{l_prefix}/var/postfix \
  142. sendmail_path=%{l_prefix}/sbin/sendmail \
  143. newaliases_path=%{l_prefix}/sbin/newaliases \
  144. mailq_path=%{l_prefix}/sbin/mailq \
  145. manpage_directory=%{l_prefix}/man \
  146. mail_user=%{l_musr} \
  147. setgid_group=%{l_rgrp}
  148. %{l_shtool} install -c -m 755 \
  149. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  150. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  151. )
  152. # post-adjust binaries
  153. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  154. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  155. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  156. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  157. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  158. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  159. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  160. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  161. # post-adjust configuration
  162. %{l_shtool} subst \
  163. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  164. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  165. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  167. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  168. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  169. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  170. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  171. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  172. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  173. %{l_shtool} mkdir -f -p -m 755 sample
  174. for cfg in access aliases canonical pcre_table regexp_table \
  175. relocated sample-* transport virtual \
  176. main.cf master.cf main.cf.default; do
  177. mv $cfg sample/
  178. done
  179. )
  180. # install default configuration
  181. %{l_shtool} install -c -m 644 \
  182. -e 's;@l_prefix@;%{l_prefix};g' \
  183. -e 's;@l_musr@;%{l_musr};g' \
  184. -e 's;@l_mgrp@;%{l_mgrp};g' \
  185. -e 's;@l_rusr@;%{l_rusr};g' \
  186. -e 's;@l_rgrp@;%{l_rgrp};g' \
  187. -e 's;@l_nusr@;%{l_nusr};g' \
  188. -e 's;@l_ngrp@;%{l_ngrp};g' \
  189. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  190. # pre-create variable stuff
  191. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  192. %{l_shtool} mkdir -f -p -m 700 active bounce corrupt defer deferred \
  193. flush incoming private saved
  194. %{l_shtool} mkdir -f -p -m 730 maildrop
  195. %{l_shtool} mkdir -f -p -m 710 public
  196. %{l_shtool} mkdir -f -p -m 755 log pid
  197. )
  198. # install addons
  199. %{l_shtool} install -c -m 755 \
  200. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  201. %{SOURCE4} $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  202. # install run-command script
  203. %{l_shtool} mkdir -f -p -m 755 \
  204. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  205. %{l_shtool} install -c -m 755 \
  206. -e 's;@l_prefix@;%{l_prefix};g' \
  207. -e 's;@l_susr@;%{l_susr};g' \
  208. -e 's;@l_musr@;%{l_musr};g' \
  209. -e 's;@l_mgrp@;%{l_mgrp};g' \
  210. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  211. # generate file list
  212. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  213. %{l_files_std} \
  214. '%attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix' \
  215. '%config %attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  216. '%attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  217. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  218. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  219. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/var/postfix' \
  220. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  221. %files -f files
  222. %clean
  223. rm -rf $RPM_BUILD_ROOT
  224. %post
  225. if [ $1 -eq 1 ]; then
  226. # generate logfile with correct owner and permissions
  227. if [ ! -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log ]; then
  228. $RPM_INSTALL_PREFIX/lib/openpkg/shtool \
  229. install -c -m 755 -o %{l_musr} -g %{l_mgrp} \
  230. /dev/null $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log
  231. fi
  232. # generate initial configuration
  233. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} all >/dev/null 2>&1 || true)
  234. elif [ $1 -gt 1 ]; then
  235. # re-genersate configuration
  236. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} clean all >/dev/null 2>&1 || true)
  237. # re-load daemon
  238. $RPM_INSTALL_PREFIX/etc/rc postfix reload >/dev/null 2>&1 || true
  239. fi
  240. %preun
  241. if [ $1 -eq 0 ]; then
  242. # stop daemon
  243. $RPM_INSTALL_PREFIX/etc/rc postfix stop >/dev/null 2>&1 || true
  244. # remove generated configuration files
  245. (cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true)
  246. # remove generated run-time files and directories
  247. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  248. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  249. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  250. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  251. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  252. xargs rmdir >/dev/null 2>&1 || true
  253. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  254. xargs rmdir >/dev/null 2>&1 || true
  255. fi