postfix.spec 15 KB

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