postfix.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 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.1.1
  27. %define V_tls 0.8.18-2.1.0-0.9.7d
  28. %define V_pflogsumm 1.1.0
  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
  37. Class: BASE
  38. Group: Mail
  39. License: IPL
  40. Version: %{V_postfix}
  41. Release: 20040507
  42. # package options
  43. %option with_fsl yes
  44. %option with_ssl no
  45. %option with_sasl no
  46. %option with_mysql no
  47. %option with_ldap no
  48. %option with_whoson no
  49. %option with_fdsetsize no
  50. # list of sources
  51. Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
  52. Source1: ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-%{V_tls}.tar.gz
  53. Source2: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
  54. Source3: etc.tar
  55. Source4: fsl.postfix
  56. Source5: 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 >= 20040130, perl
  64. PreReq: OpenPKG, openpkg >= 20040130, 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_ssl}" == "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. %track
  109. prog postfix = {
  110. version = %{V_postfix}
  111. url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
  112. regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz
  113. }
  114. prog postfix:pfixtls = {
  115. version = %{V_tls}
  116. url = ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/
  117. regex = pfixtls-([^-]+-[^-]+-[^-]+)\.tar\.gz
  118. }
  119. prog postfix:pflogsumm = {
  120. version = %{V_pflogsumm}
  121. url = http://jimsun.linxnet.com/postfix_contrib.html
  122. regex = pflogsumm-(__VER__)\.tar\.gz
  123. }
  124. prog postfix:whoson = {
  125. version = %{V_whoson}
  126. url = ftp://victor.teaser.fr/pub/lwa/postfix/
  127. regex = postfix-(__VER__)-whoson.patch
  128. }
  129. %prep
  130. # unpack distribution files
  131. %setup -q
  132. %if "%{with_ssl}" == "yes"
  133. %setup -q -T -D -a 1
  134. %endif
  135. %setup -q -T -D -a 2
  136. %setup -q -T -D -a 3
  137. # apply vendor SSL/TLS patch
  138. %if "%{with_ssl}" == "yes"
  139. %{l_patch} -p1 <pfixtls-%{V_tls}/pfixtls.diff
  140. %endif
  141. # apply OpenPKG patches
  142. %patch -p0
  143. ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 <%{PATCH1} ) || exit $?
  144. # apply vendor WHOSON patch
  145. %if "%{with_whoson}" == "yes"
  146. %patch -p0 -P 2
  147. %endif
  148. %build
  149. # configure Postfix (hard-core part I)
  150. %{l_shtool} subst \
  151. -e 's/var_config_dir, /var_command_dir, /' \
  152. src/postfix/postfix.c
  153. %{l_shtool} subst \
  154. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  155. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  156. conf/postfix-script
  157. %{l_shtool} subst \
  158. -e 's;/usr/include;%{l_prefix}/include;g' \
  159. makedefs
  160. # configure Postfix (regular part)
  161. unset LD_LIBRARY_PATH || true
  162. CCARGS=""
  163. CCARGS="$CCARGS %{l_cflags -O}"
  164. CCARGS="$CCARGS %{l_cppflags}"
  165. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
  166. AUXLIBS=""
  167. AUXLIBS="$AUXLIBS %{l_ldflags}"
  168. CCARGS="$CCARGS -DHAS_DB"
  169. AUXLIBS="$AUXLIBS -ldb"
  170. CCARGS="$CCARGS -DHAS_PCRE"
  171. AUXLIBS="$AUXLIBS -lpcre"
  172. %if "%{with_mysql}" == "yes"
  173. CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
  174. AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
  175. %endif
  176. %if "%{with_sasl}" == "yes"
  177. CCARGS="$CCARGS -DUSE_SASL_AUTH %{l_cppflags sasl .}"
  178. AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
  179. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  180. AUXLIBS="$AUXLIBS -ldl"
  181. fi
  182. %endif
  183. %if "%{with_ssl}" == "yes"
  184. CCARGS="$CCARGS -DHAS_SSL"
  185. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  186. %endif
  187. %if "%{with_ldap}" == "yes"
  188. CCARGS="$CCARGS -DHAS_LDAP"
  189. AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
  190. %endif
  191. %if "%{with_fsl}" == "yes"
  192. AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
  193. CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
  194. %endif
  195. %if "%{with_fdsetsize}" != "no"
  196. %if "%{with_fdsetsize}" == "yes"
  197. CCARGS="$CCARGS -DFD_SETSIZE=1024"
  198. %else
  199. CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
  200. %endif
  201. %endif
  202. %{l_make} %{l_mflags} makefiles \
  203. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  204. # configure Postfix (hard-core part II)
  205. %{l_shtool} subst \
  206. -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
  207. -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
  208. src/util/sys_defs.h
  209. # build Postfix
  210. %{l_make} %{l_mflags}
  211. %install
  212. rm -rf $RPM_BUILD_ROOT
  213. # perform standard installation procedure
  214. %{l_shtool} subst -e "s;chown;true;" postfix-install
  215. sh postfix-install -non-interactive \
  216. install_root=$RPM_BUILD_ROOT \
  217. config_directory=%{l_prefix}/etc/postfix \
  218. daemon_directory=%{l_prefix}/libexec/postfix \
  219. command_directory=%{l_prefix}/sbin \
  220. queue_directory=%{l_prefix}/var/postfix \
  221. sendmail_path=%{l_prefix}/sbin/sendmail \
  222. newaliases_path=%{l_prefix}/sbin/newaliases \
  223. mailq_path=%{l_prefix}/sbin/mailq \
  224. manpage_directory=%{l_prefix}/man \
  225. mail_user=%{l_musr} \
  226. setgid_group=%{l_rgrp}
  227. # post-adjust binaries
  228. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  229. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  230. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  231. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  232. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  233. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  234. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  235. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  236. # post-adjust configuration
  237. %{l_shtool} subst \
  238. -e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
  239. $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
  240. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
  241. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
  242. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  243. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  244. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  245. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  246. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  247. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
  248. %{l_shtool} mkdir -f -p -m 755 sample
  249. for cfg in access aliases canonical header_checks \
  250. relocated transport virtual \
  251. main.cf master.cf main.cf.default; do
  252. mv $cfg sample/
  253. done
  254. ) || exit $?
  255. # install default configuration
  256. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  257. etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  258. # pre-create variable stuff
  259. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  260. %{l_shtool} mkdir -f -p -m 700 \
  261. active bounce corrupt defer deferred \
  262. flush incoming private saved
  263. %{l_shtool} mkdir -f -p -m 730 maildrop
  264. %{l_shtool} mkdir -f -p -m 710 public
  265. %{l_shtool} mkdir -f -p -m 755 log pid
  266. ) || exit $?
  267. # install addons
  268. %{l_shtool} install -c -m 755 \
  269. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  270. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  271. %{l_shtool} install -c -m 755 \
  272. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  273. -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \
  274. auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape
  275. %{l_shtool} install -c -m 644 \
  276. man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8
  277. ( cd pflogsumm-%{V_pflogsumm}
  278. %{l_shtool} install -c -m 755 \
  279. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  280. pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  281. %{l_shtool} install -c -m 644 \
  282. pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  283. ) || exit $?
  284. # install run-command script
  285. %{l_shtool} mkdir -f -p -m 755 \
  286. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  287. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  288. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  289. # adjust installation to avoid file name conflicts
  290. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  291. mv master.8 postfix_master.8
  292. ) || exit $?
  293. # install OSSP fsl configuration
  294. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  295. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  296. %{SOURCE fsl.postfix} \
  297. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  298. # generate file list
  299. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  300. %{l_files_std} \
  301. '%not %dir %{l_prefix}/etc/fsl' \
  302. '%config %{l_prefix}/etc/fsl/fsl.postfix' \
  303. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
  304. '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  305. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  306. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  307. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  308. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
  309. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  310. %files -f files
  311. %clean
  312. rm -rf $RPM_BUILD_ROOT
  313. %pre
  314. # before upgrade, save status and stop service
  315. [ $1 -eq 2 ] || exit 0
  316. eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
  317. %{l_rc} postfix stop 2>/dev/null
  318. exit 0
  319. %post
  320. if [ $1 -eq 1 ]; then
  321. # after install, generate configuration
  322. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
  323. fi
  324. if [ $1 -eq 2 ]; then
  325. # after upgrade, regenerate configuration
  326. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
  327. # after upgrade, restore status
  328. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
  329. [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
  330. fi
  331. exit 0
  332. %preun
  333. # before erase, stop service and remove log files
  334. [ $1 -eq 0 ] || exit 0
  335. %{l_rc} postfix stop 2>/dev/null
  336. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
  337. # remove generated configuration files
  338. ( cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true ) || true
  339. # remove generated run-time files and directories
  340. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  341. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  342. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  343. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  344. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  345. xargs rmdir >/dev/null 2>&1 || true
  346. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  347. xargs rmdir >/dev/null 2>&1 || true
  348. exit 0