postfix.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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: 20020718
  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. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  142. AUXLIBS="$AUXLIBS -ldl"
  143. fi
  144. %endif
  145. AUXLIBS="$AUXLIBS -L$fakesyslogdir -lfakesyslog"
  146. %{l_make} %{l_mflags} makefiles \
  147. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  148. # build Postfix
  149. %{l_make} %{l_mflags}
  150. %install
  151. rm -rf $RPM_BUILD_ROOT
  152. # perform standard installation procedure
  153. (
  154. cd postfix-%{V_postfix}
  155. %{l_shtool} subst -e "s;chown;true;" postfix-install
  156. sh postfix-install -non-interactive \
  157. install_root=$RPM_BUILD_ROOT \
  158. config_directory=%{l_prefix}/etc/postfix \
  159. daemon_directory=%{l_prefix}/libexec/postfix \
  160. command_directory=%{l_prefix}/sbin \
  161. queue_directory=%{l_prefix}/var/postfix \
  162. sendmail_path=%{l_prefix}/sbin/sendmail \
  163. newaliases_path=%{l_prefix}/sbin/newaliases \
  164. mailq_path=%{l_prefix}/sbin/mailq \
  165. manpage_directory=%{l_prefix}/man \
  166. mail_user=%{l_musr} \
  167. setgid_group=%{l_rgrp}
  168. %{l_shtool} install -c -m 755 \
  169. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  170. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  171. )
  172. # post-adjust binaries
  173. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  174. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  175. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  176. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  177. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  178. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  179. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  180. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  181. # post-adjust configuration
  182. %{l_shtool} subst \
  183. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  184. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  185. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  186. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  187. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  188. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  189. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  190. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  191. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  192. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  193. %{l_shtool} mkdir -f -p -m 755 sample
  194. for cfg in access aliases canonical pcre_table regexp_table \
  195. relocated sample-* transport virtual \
  196. main.cf master.cf main.cf.default; do
  197. mv $cfg sample/
  198. done
  199. )
  200. # install default configuration
  201. %{l_shtool} install -c -m 644 \
  202. -e 's;@l_prefix@;%{l_prefix};g' \
  203. -e 's;@l_musr@;%{l_musr};g' \
  204. -e 's;@l_mgrp@;%{l_mgrp};g' \
  205. -e 's;@l_rusr@;%{l_rusr};g' \
  206. -e 's;@l_rgrp@;%{l_rgrp};g' \
  207. -e 's;@l_nusr@;%{l_nusr};g' \
  208. -e 's;@l_ngrp@;%{l_ngrp};g' \
  209. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  210. # pre-create variable stuff
  211. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  212. %{l_shtool} mkdir -f -p -m 700 active bounce corrupt defer deferred \
  213. flush incoming private saved
  214. %{l_shtool} mkdir -f -p -m 730 maildrop
  215. %{l_shtool} mkdir -f -p -m 710 public
  216. %{l_shtool} mkdir -f -p -m 755 log pid
  217. )
  218. # install addons
  219. %{l_shtool} install -c -m 755 \
  220. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  221. %{SOURCE4} $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  222. # install run-command script
  223. %{l_shtool} mkdir -f -p -m 755 \
  224. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  225. %{l_shtool} install -c -m 755 \
  226. -e 's;@l_prefix@;%{l_prefix};g' \
  227. -e 's;@l_susr@;%{l_susr};g' \
  228. -e 's;@l_musr@;%{l_musr};g' \
  229. -e 's;@l_mgrp@;%{l_mgrp};g' \
  230. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  231. # adjust installation to avoid file name conflicts
  232. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  233. mv master.8 postfix_master.8
  234. )
  235. # generate file list
  236. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  237. %{l_files_std} \
  238. '%attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix' \
  239. '%config %attr(-,root,%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  240. '%attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  241. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  242. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  243. '%dir %attr(-,root,%{l_mgrp}) %{l_prefix}/var/postfix' \
  244. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  245. %files -f files
  246. %clean
  247. rm -rf $RPM_BUILD_ROOT
  248. %post
  249. if [ $1 -eq 1 ]; then
  250. # generate logfile with correct owner and permissions
  251. if [ ! -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log ]; then
  252. $RPM_INSTALL_PREFIX/lib/openpkg/shtool \
  253. install -c -m 755 -o %{l_musr} -g %{l_mgrp} \
  254. /dev/null $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log
  255. fi
  256. # generate initial configuration
  257. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} all >/dev/null 2>&1 || true)
  258. elif [ $1 -gt 1 ]; then
  259. # re-genersate configuration
  260. (cd $RPM_INSTALL_PREFIX/etc/postfix; %{l_make} clean all >/dev/null 2>&1 || true)
  261. # re-load daemon
  262. $RPM_INSTALL_PREFIX/etc/rc postfix reload >/dev/null 2>&1 || true
  263. fi
  264. %preun
  265. if [ $1 -eq 0 ]; then
  266. # stop daemon
  267. $RPM_INSTALL_PREFIX/etc/rc postfix stop >/dev/null 2>&1 || true
  268. # remove generated configuration files
  269. (cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true)
  270. # remove generated run-time files and directories
  271. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  272. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  273. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  274. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  275. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  276. xargs rmdir >/dev/null 2>&1 || true
  277. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  278. xargs rmdir >/dev/null 2>&1 || true
  279. fi