postfix.spec 10 KB

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