milter-regex.spec 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. ##
  2. ## milter-regex.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 information
  25. Name: milter-regex
  26. Summary: Mail Filter for Regular Expressions based ACL
  27. URL: http://www.benzedrine.cx/milter-regex.html
  28. Vendor: Daniel Hartmeier
  29. Packager: OpenPKG Foundation e.V.
  30. Distribution: OpenPKG Community
  31. Class: EVAL
  32. Group: Mail
  33. License: BSD
  34. Version: 1.7
  35. Release: 20070907
  36. # package options
  37. %option with_fsl yes
  38. # list of sources
  39. Source0: http://www.benzedrine.cx/milter-regex-%{version}.tar.gz
  40. Source1: rc.milter-regex
  41. Source2: fsl.milter-regex
  42. Patch0: milter-regex.patch
  43. # build information
  44. Prefix: %{l_prefix}
  45. BuildRoot: %{l_buildroot}
  46. BuildPreReq: OpenPKG, openpkg >= 20040130, byacc, gcc, pkgconfig
  47. PreReq: OpenPKG, openpkg >= 20040130
  48. BuildPreReq: milter, pcre
  49. PreReq: milter, pcre
  50. %if "%{with_fsl}" == "yes"
  51. BuildPreReq: fsl >= 1.2.0
  52. PreReq: fsl >= 1.2.0
  53. %endif
  54. AutoReq: no
  55. AutoReqProv: no
  56. %description
  57. milter-regex is a Sendmail "milter" API based plugin that rejects or
  58. discards mail messages matching regular expressions.
  59. %track
  60. prog milter-regex = {
  61. version = %{version}
  62. url = http://www.benzedrine.cx/milter-regex.html
  63. regex = milter-regex-(__VER__)\.tar\.gz
  64. }
  65. %prep
  66. %setup -q
  67. %patch -p0
  68. %build
  69. # build program
  70. %{l_shtool} subst \
  71. -e 's;/etc/milter-regex\.conf;%{l_prefix}/etc/milter-regex/milter-regex.conf;g' \
  72. milter-regex.c milter-regex.8
  73. CC="%{l_cc}"
  74. CFLAGS="%{l_cflags -O} `pkg-config milter libpcre --cflags-only-other`"
  75. CPPFLAGS="%{l_cppflags} `pkg-config milter libpcre --cflags-only-I`"
  76. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} `pkg-config milter libpcre --libs-only-other`"
  77. LIBS="%{l_fsl_libs} `pkg-config milter --libs-only-l` -lpcreposix -lpcre"
  78. case "%{l_platform -t}" in
  79. *-freebsd* ) CFLAGS="$CFLAGS -pthread" ;;
  80. *-linux* ) CFLAGS="$CFLAGS -pthread" ;;
  81. *-sunos* ) LIBS="$LIBS -lpthread -lsocket -lnsl -lresolv" ;;
  82. *-hpux* ) CFLAGS="$CFLAGS -pthread" ;;
  83. *-aix* ) CFLAGS="$CFLAGS -pthread" ;;
  84. esac
  85. byacc -d parse.y
  86. $CC $CFLAGS $CPPFLAGS $LDFLAGS -o milter-regex eval.c strlcpy.c y.tab.c milter-regex.c $LIBS
  87. touch milter-regex.conf
  88. %install
  89. # create installation hierarchy
  90. rm -rf $RPM_BUILD_ROOT
  91. %{l_shtool} mkdir -f -p -m 755 \
  92. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  93. $RPM_BUILD_ROOT%{l_prefix}/etc/milter-regex \
  94. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  95. $RPM_BUILD_ROOT%{l_prefix}/bin \
  96. $RPM_BUILD_ROOT%{l_prefix}/var/milter-regex \
  97. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  98. # install program, manual page and default configuration
  99. %{l_shtool} install -c -m 755 \
  100. milter-regex $RPM_BUILD_ROOT%{l_prefix}/bin/
  101. %{l_shtool} install -c -m 644 \
  102. milter-regex.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
  103. %{l_shtool} install -c -m 644 \
  104. milter-regex.conf $RPM_BUILD_ROOT%{l_prefix}/etc/milter-regex/
  105. # install OSSP fsl configuration
  106. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  107. %{SOURCE fsl.milter-regex} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  108. # install run-command script
  109. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  110. %{SOURCE rc.milter-regex} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  111. # determine installation files
  112. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  113. %{l_files_std} \
  114. '%config %{l_prefix}/etc/fsl/*' \
  115. '%config %{l_prefix}/etc/milter-regex/*' \
  116. '%attr(755,%{l_rusr},%{l_mgrp}) %{l_prefix}/var/milter-regex'
  117. %files -f files
  118. %clean
  119. rm -rf $RPM_BUILD_ROOT
  120. %post
  121. # after upgrade, restart service
  122. [ $1 -eq 2 ] || exit 0
  123. eval `%{l_rc} milter-regex status 2>/dev/null`
  124. [ ".$milter_regex_active" = .yes ] && %{l_rc} milter-regex restart
  125. exit 0
  126. %preun
  127. # before erase, stop service and remove log files
  128. [ $1 -eq 0 ] || exit 0
  129. %{l_rc} milter-regex stop 2>/dev/null
  130. rm -f $RPM_INSTALL_PREFIX/var/milter-regex/* >/dev/null 2>&1 || true
  131. exit 0