amavisd.spec 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. ##
  2. ## amavisd.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_amavis 2.5.0
  26. %define V_logsumm 0.6
  27. # package information
  28. Name: amavisd
  29. Summary: Interface Daemon between MTA and Content Checker
  30. URL: http://www.ijs.si/software/amavisd/
  31. Vendor: Mark Martinec
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: BASE
  35. Group: Mail
  36. License: GPL
  37. Version: %{V_amavis}
  38. Release: 20070423
  39. # package options
  40. %option with_milter no
  41. # list of sources
  42. Source0: http://www.ijs.si/software/amavisd/amavisd-new-%{version}.tar.gz
  43. Source1: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/amavisd/amavislogsumm-%{V_logsumm}
  44. Source2: rc.amavisd
  45. Patch0: amavisd.patch
  46. # build information
  47. Prefix: %{l_prefix}
  48. BuildRoot: %{l_buildroot}
  49. BuildPreReq: OpenPKG, openpkg >= 20060823, sed
  50. PreReq: OpenPKG, openpkg >= 20060823, spamassassin
  51. PreReq: perl, perl-net, perl-util, perl-mail, perl-time
  52. PreReq: perl-sys, perl-comp, perl-conv
  53. %if "%{with_milter}" == "yes"
  54. BuildPreReq: milter
  55. PreReq: milter
  56. %endif
  57. AutoReq: no
  58. AutoReqProv: no
  59. %description
  60. amavisd-new is a high-performance interface between mailer (MTA) and
  61. content checkers: virus scanners, and/or SpamAssassin. It is written
  62. in Perl for maintainability, without paying a significant price
  63. for speed. It talks to MTA via (E)SMTP or LMTP, or by using helper
  64. programs. Best with Postfix, works with Exim, sendmail/milter, or
  65. with any MTA as a SMTP relay.
  66. %track
  67. prog amavisd = {
  68. version = %{version}
  69. url = http://www.ijs.si/software/amavisd/
  70. regex = amavisd-new-(\d+\.\d+\.\d+)\.tar\.gz
  71. }
  72. prog amavislogsumm = {
  73. version = %{V_logsumm}
  74. url = ftp://ftp.openpkg.org/sources/CPY/VERSIONED/amavisd/
  75. regex = amavislogsumm-(__VER__)
  76. }
  77. %prep
  78. %setup -q -n amavisd-new-%{version}
  79. cp %{SOURCE amavislogsumm-%{V_logsumm}} amavislogsumm
  80. %patch -p0
  81. %build
  82. # adjust configuration file
  83. %{l_shtool} subst \
  84. -e "s;'clamscan';'%{l_prefix}/bin/clamscan';g" \
  85. -e "s;'uvscan';'%{l_prefix}/bin/uvscan';g" \
  86. -e "s;'sweep';'%{l_prefix}/bin/sweep';g" \
  87. -e "s;'f-prot';'%{l_prefix}/bin/f-prot';g" \
  88. -e 's;/var/run/clamav/clamd;%{l_prefix}/var/clamav/clamd.sock;g' \
  89. -e 's;/var/amavis;%{l_prefix}/var/amavisd;g' \
  90. -e 's;/var/virusmails;%{l_prefix}/var/amavisd/virusmails;g' \
  91. -e 's;/usr/bin/sendmail;%{l_prefix}/sbin/sendmail;g' \
  92. -e 's; -C/etc/sendmail\.orig\.cf;;g' \
  93. -e 's;/usr/bin/exim;%{l_prefix}/bin/exim;g' \
  94. -e 's;/usr/local/sbin;%{l_prefix}/sbin;g' \
  95. -e 's;/usr/local/bin;%{l_prefix}/bin;g' \
  96. -e 's;\(daemon_user *= \)[^;]*;\1q{%{l_rusr}};' \
  97. -e 's;\(daemon_group *= \)[^;]*;\1q{%{l_rgrp}};' \
  98. -e 's;\(\$DO_SYSLOG *= \)[^;]*;\10;' \
  99. -e '/^\$MYHOME/s!$!\n$LOGFILE = "$MYHOME/amavisd.log";!' \
  100. -e 's;\(\$path *=.*\)/usr/local/sbin\(.*\);\1%{l_prefix}/sbin:%{l_prefix}/bin:/usr/local/sbin\2;' \
  101. amavisd.conf
  102. # adjust program
  103. %{l_shtool} subst \
  104. -e '1s;/usr/bin/perl;%{l_prefix}/bin/perl;' \
  105. -e 's;/var/amavis;%{l_prefix}/var/amavisd;g' \
  106. -e 's;/usr/lib/spamassassin;%{l_prefix}/lib/spamassassin;g' \
  107. amavisd
  108. # optionally build MILTER
  109. %if "%{with_milter}" == "yes"
  110. ( cd helper-progs
  111. CC="%{l_cc}" \
  112. CFLAGS="%{l_cflags -O}" \
  113. LDFLAGS="%{l_ldflags}" \
  114. ./configure \
  115. --prefix="%{l_prefix}" \
  116. --with-sendmail="%{l_prefix}/sbin/sendmail" \
  117. --with-runtime-dir="%{l_prefix}/var/amavisd" \
  118. --with-sockname="%{l_prefix}/var/amavisd/amavisd.sock" \
  119. --with-user="%{l_rusr}" \
  120. --with-milterinc="%{l_prefix}/include/milter" \
  121. --with-milterlib="%{l_prefix}/lib"
  122. %{l_make} %{l_mflags} \
  123. AMAVIS_USER="%{l_rusr}" \
  124. AMAVIS_GROUP="%{l_mgrp}"
  125. ) || exit $?
  126. %endif
  127. %install
  128. # create installation hierarchy
  129. rm -rf $RPM_BUILD_ROOT
  130. %{l_shtool} mkdir -f -p -m 755 \
  131. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  132. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  133. $RPM_BUILD_ROOT%{l_prefix}/etc/amavisd \
  134. $RPM_BUILD_ROOT%{l_prefix}/share/amavisd \
  135. $RPM_BUILD_ROOT%{l_prefix}/var/amavisd \
  136. $RPM_BUILD_ROOT%{l_prefix}/var/amavisd/db \
  137. $RPM_BUILD_ROOT%{l_prefix}/var/amavisd/tmp \
  138. $RPM_BUILD_ROOT%{l_prefix}/var/amavisd/var \
  139. $RPM_BUILD_ROOT%{l_prefix}/var/amavisd/virusmails
  140. # install programs
  141. %{l_shtool} install -c -m 755 \
  142. amavisd $RPM_BUILD_ROOT%{l_prefix}/sbin/
  143. %{l_shtool} install -c -m 755 \
  144. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
  145. amavislogsumm $RPM_BUILD_ROOT%{l_prefix}/sbin/
  146. %if "%{with_milter}" == "yes"
  147. %{l_shtool} install -c -s -m 755 \
  148. helper-progs/amavis-milter $RPM_BUILD_ROOT%{l_prefix}/sbin/
  149. %endif
  150. # install default configuration
  151. %{l_shtool} install -c -m 644 \
  152. amavisd.conf $RPM_BUILD_ROOT%{l_prefix}/etc/amavisd/
  153. # install documentation
  154. %{l_shtool} install -c -m 644 \
  155. README_FILES/amavisd-new-docs.html \
  156. $RPM_BUILD_ROOT%{l_prefix}/share/amavisd/amavisd.html
  157. # install run-command script
  158. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  159. %{SOURCE rc.amavisd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  160. # determine installation files
  161. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
  162. '%config %{l_prefix}/etc/amavisd/amavisd.conf' \
  163. '%doc %{l_prefix}/share/amavisd/*' \
  164. '%attr(0750,%{l_rusr},%{l_mgrp}) %{l_prefix}/var/amavisd' \
  165. '%attr(0750,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/amavisd/*'
  166. %files -f files
  167. %clean
  168. rm -rf $RPM_BUILD_ROOT
  169. %pre
  170. # before upgrade, save status and stop service
  171. [ $1 -eq 2 ] || exit 0
  172. eval `%{l_rc} amavisd status 2>/dev/null | tee %{l_tmpfile}`
  173. %{l_rc} amavisd stop 2>/dev/null
  174. exit 0
  175. %post
  176. [ $1 -eq 2 ] || exit 0
  177. # after upgrade, restore status
  178. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
  179. [ ".$amavisd_active" = .yes ] && %{l_rc} amavisd start
  180. exit 0
  181. %preun
  182. # before erase, stop service and remove log files
  183. [ $1 -eq 0 ] || exit 0
  184. %{l_rc} amavisd stop 2>/dev/null
  185. rm -f $RPM_INSTALL_PREFIX/var/amavisd/.spamassassin >/dev/null 2>&1 || true
  186. rm -f $RPM_INSTALL_PREFIX/var/amavisd/*.log* >/dev/null 2>&1 || true
  187. rm -f $RPM_INSTALL_PREFIX/var/amavisd/*.sum* >/dev/null 2>&1 || true
  188. exit 0