postfix.spec 14 KB

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