postfix.spec 13 KB

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