postfix.spec 12 KB

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