postfix.spec 12 KB

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