postfix.spec 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. ##
  2. ## postfix.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package versions
  25. %define V_postfix 2.4.2
  26. %define V_pflogsumm 1.1.1
  27. %define V_whoson 2.4.0
  28. # package information
  29. Name: postfix
  30. Summary: Mail Transfer Agent (MTA)
  31. URL: http://www.postfix.org/
  32. Vendor: Wietse Venema
  33. Packager: OpenPKG Foundation e.V.
  34. Distribution: OpenPKG Community
  35. Class: BASE
  36. Group: Mail
  37. License: IPL
  38. Version: %{V_postfix}
  39. Release: 20070531
  40. # package options
  41. %option with_fsl yes
  42. %option with_ssl no
  43. %option with_sasl no
  44. %option with_mysql no
  45. %option with_pgsql 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: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
  52. Source2: postfix.txt
  53. Source3: fsl.postfix
  54. Source4: rc.postfix
  55. Patch0: postfix.patch
  56. Patch1: postfix.patch.pfls
  57. Patch2: ftp://ftp.openpkg.org/sources/CPY/postfix/postfix-%{V_whoson}-whoson.patch
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20060823, perl, gcc
  62. PreReq: OpenPKG, openpkg >= 20060823, perl, procmail, perl-time
  63. BuildPreReq: make, pcre, db
  64. PreReq: make, pcre, db
  65. %if "%{with_fsl}" == "yes"
  66. BuildPreReq: fsl >= 1.3.0
  67. PreReq: fsl >= 1.3.0
  68. %endif
  69. %if "%{with_ssl}" == "yes"
  70. BuildPreReq: openssl
  71. PreReq: openssl
  72. %endif
  73. %if "%{with_sasl}" == "yes"
  74. BuildPreReq: sasl
  75. PreReq: sasl
  76. %endif
  77. %if "%{with_mysql}" == "yes"
  78. BuildPreReq: mysql
  79. PreReq: mysql
  80. %endif
  81. %if "%{with_pgsql}" == "yes"
  82. BuildPreReq: postgresql, openssl
  83. PreReq: postgresql, openssl
  84. %endif
  85. %if "%{with_ldap}" == "yes"
  86. BuildPreReq: openldap, openssl
  87. PreReq: openldap, openssl
  88. %endif
  89. %if "%{with_whoson}" == "yes"
  90. BuildPreReq: whoson
  91. PreReq: whoson
  92. %endif
  93. AutoReq: no
  94. AutoReqProv: no
  95. Provides: MTA
  96. Conflicts: exim, sendmail, ssmtp
  97. %description
  98. Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
  99. replace the Sendmail MTA. It is fully standards compliant and
  100. supports SMTP, ESMTP, LMTP over IPv4/IPv6 with optional TLS/SASL.
  101. Local specifics in this OpenPKG version:
  102. o Postfix delivers locally via Procmail
  103. o Postfix logs directly to the filesystem via OSSP fsl
  104. o Berkeley-DB dictionary support
  105. o PCRE matching support
  106. o Optional STARTTLS encryption support (see package options)
  107. o Optional SASL2 authentication support (see package options)
  108. o Optional MySQL dictionary support (see package options)
  109. o Optional PostgreSQL dictionary support (see package options)
  110. o Optional OpenLDAP dictionary support (see package options)
  111. o Optional WHOSON dictionary support (see package options)
  112. %track
  113. prog postfix = {
  114. version = %{V_postfix}
  115. url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
  116. regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz
  117. }
  118. prog postfix:pflogsumm = {
  119. version = %{V_pflogsumm}
  120. url = http://jimsun.linxnet.com/postfix_contrib.html
  121. regex = pflogsumm-(__VER__)\.tar\.gz
  122. }
  123. prog postfix:whoson = {
  124. version = %{V_whoson}
  125. url = ftp://ftp.openpkg.org/sources/CPY/postfix/
  126. regex = postfix-(__VER__)-whoson.patch
  127. }
  128. %prep
  129. # unpack distribution files
  130. %setup -q
  131. %setup -q -T -D -a 1
  132. # apply OpenPKG patches
  133. %patch -p0
  134. ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 -b <%{PATCH1} ) || exit $?
  135. # apply vendor WHOSON patch
  136. %if "%{with_whoson}" == "yes"
  137. %patch -p0 -P 2
  138. %endif
  139. %build
  140. # configure Postfix (hard-core part I)
  141. %{l_shtool} subst \
  142. -e 's/var_config_dir, /var_command_dir, /' \
  143. src/postfix/postfix.c
  144. %{l_shtool} subst \
  145. -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
  146. -e 's;config_directory/post-install;command_directory/postfix-install;' \
  147. conf/postfix-script
  148. %{l_shtool} subst \
  149. -e 's;/usr/include;%{l_prefix}/include;g' \
  150. makedefs
  151. # configure Postfix (regular part)
  152. unset LD_LIBRARY_PATH || true
  153. CCARGS=""
  154. CCARGS="$CCARGS %{l_cflags -O}"
  155. CCARGS="$CCARGS %{l_cppflags}"
  156. CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
  157. AUXLIBS=""
  158. AUXLIBS="$AUXLIBS %{l_ldflags}"
  159. CCARGS="$CCARGS -DHAS_DB"
  160. AUXLIBS="$AUXLIBS -ldb"
  161. CCARGS="$CCARGS -DHAS_PCRE"
  162. AUXLIBS="$AUXLIBS -lpcre"
  163. %if "%{with_mysql}" == "yes"
  164. CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
  165. AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
  166. %endif
  167. %if "%{with_pgsql}" == "yes"
  168. CCARGS="$CCARGS -DHAS_PGSQL %{l_cppflags postgresql .}"
  169. AUXLIBS="$AUXLIBS -lpq -lssl -lcrypto -lcrypt"
  170. %endif
  171. %if "%{with_sasl}" == "yes"
  172. CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL %{l_cppflags sasl .}"
  173. AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
  174. if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
  175. AUXLIBS="$AUXLIBS -ldl"
  176. fi
  177. %endif
  178. %if "%{with_ssl}" == "yes"
  179. CCARGS="$CCARGS -DUSE_TLS"
  180. AUXLIBS="$AUXLIBS -lssl -lcrypto"
  181. %endif
  182. %if "%{with_ldap}" == "yes"
  183. CCARGS="$CCARGS -DHAS_LDAP"
  184. AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
  185. %endif
  186. %if "%{with_fsl}" == "yes"
  187. AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
  188. CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
  189. %endif
  190. %if "%{with_fdsetsize}" != "no"
  191. %if "%{with_fdsetsize}" == "yes"
  192. CCARGS="$CCARGS -DFD_SETSIZE=1024"
  193. %else
  194. CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
  195. %endif
  196. %endif
  197. case "%{l_platform -t}" in
  198. *-sunos* ) AUXLIBS="$AUXLIBS -lrt" ;;
  199. esac
  200. %{l_make} %{l_mflags} -f Makefile.init makefiles \
  201. CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
  202. # configure Postfix (hard-core part II)
  203. %{l_shtool} subst \
  204. -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
  205. -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
  206. src/util/sys_defs.h
  207. # build Postfix
  208. %{l_make} %{l_mflags}
  209. %install
  210. rm -rf $RPM_BUILD_ROOT
  211. # perform standard installation procedure
  212. %{l_shtool} subst -e "s;chown;true;" postfix-install
  213. sh postfix-install -non-interactive \
  214. install_root=$RPM_BUILD_ROOT \
  215. config_directory=%{l_prefix}/etc/postfix \
  216. daemon_directory=%{l_prefix}/libexec/postfix \
  217. command_directory=%{l_prefix}/sbin \
  218. queue_directory=%{l_prefix}/var/postfix \
  219. sendmail_path=%{l_prefix}/sbin/sendmail \
  220. newaliases_path=%{l_prefix}/sbin/newaliases \
  221. mailq_path=%{l_prefix}/sbin/mailq \
  222. manpage_directory=%{l_prefix}/man \
  223. mail_user=%{l_musr} \
  224. setgid_group=%{l_rgrp}
  225. # post-adjust binaries
  226. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  227. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  228. $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
  229. rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  230. ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
  231. $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
  232. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  233. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
  234. # post-adjust configuration
  235. for cfg in \
  236. *LICENSE makedefs.out bounce.cf.default access aliases \
  237. canonical header_checks relocated transport virtual \
  238. main.cf master.cf main.cf.default; do
  239. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/$cfg
  240. done
  241. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
  242. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
  243. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
  244. mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
  245. $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
  246. # install default configuration
  247. for name in `grep "^<file" %{SOURCE postfix.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
  248. (echo ""; cat %{SOURCE postfix.txt}; echo "") |\
  249. sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
  250. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  251. $name $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
  252. done
  253. # pre-create variable stuff
  254. ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
  255. %{l_shtool} mkdir -f -p -m 700 \
  256. active bounce corrupt defer deferred \
  257. flush incoming private saved
  258. %{l_shtool} mkdir -f -p -m 730 maildrop
  259. %{l_shtool} mkdir -f -p -m 710 public
  260. %{l_shtool} mkdir -f -p -m 755 log pid
  261. ) || exit $?
  262. # install addons
  263. %{l_shtool} install -c -m 755 \
  264. -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  265. auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
  266. %{l_shtool} install -c -m 755 \
  267. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  268. -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \
  269. auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape
  270. %{l_shtool} install -c -m 644 \
  271. man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8
  272. ( cd pflogsumm-%{V_pflogsumm}
  273. %{l_shtool} install -c -m 755 \
  274. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  275. pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
  276. %{l_shtool} install -c -m 644 \
  277. pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  278. ) || exit $?
  279. # install run-command script
  280. %{l_shtool} mkdir -f -p -m 755 \
  281. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  282. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  283. %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  284. # adjust installation to avoid file name conflicts
  285. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
  286. mv master.8 postfix_master.8
  287. ) || exit $?
  288. # install OSSP fsl configuration
  289. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  290. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  291. %{SOURCE fsl.postfix} \
  292. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  293. # generate file list
  294. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  295. %{l_files_std} \
  296. '%not %dir %{l_prefix}/etc/fsl' \
  297. '%config %{l_prefix}/etc/fsl/fsl.postfix' \
  298. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
  299. '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
  300. '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
  301. '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
  302. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
  303. '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
  304. '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
  305. %files -f files
  306. %clean
  307. rm -rf $RPM_BUILD_ROOT
  308. %pre
  309. # before upgrade, save status and stop service
  310. [ $1 -eq 2 ] || exit 0
  311. eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
  312. %{l_rc} postfix stop 2>/dev/null
  313. exit 0
  314. %post
  315. if [ $1 -eq 1 ]; then
  316. # after install, generate configuration
  317. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
  318. fi
  319. if [ $1 -eq 2 ]; then
  320. # after upgrade, regenerate configuration
  321. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
  322. # after upgrade, restore status
  323. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
  324. [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
  325. fi
  326. exit 0
  327. %preun
  328. # before erase, stop service and remove log files
  329. [ $1 -eq 0 ] || exit 0
  330. %{l_rc} postfix stop 2>/dev/null
  331. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
  332. rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.sum* >/dev/null 2>&1 || true
  333. # remove generated configuration files
  334. ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean >/dev/null 2>&1; true ) || true
  335. # remove generated run-time files and directories
  336. rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
  337. rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
  338. rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
  339. rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
  340. find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
  341. xargs rmdir >/dev/null 2>&1 || true
  342. find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
  343. xargs rmdir >/dev/null 2>&1 || true
  344. exit 0