postfix.spec 11 KB

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