imapd.spec 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. ##
  2. ## imapd.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.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 information
  26. Name: imapd
  27. Summary: Cyrus IMAP Server
  28. URL: http://asg.web.cmu.edu/cyrus/imapd/
  29. Vendor: Carnegie Mellon University
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG
  32. Class: PLUS
  33. Group: Mail
  34. License: BSD
  35. Version: 2.2.3
  36. Release: 20040310
  37. # package options
  38. %option with_fsl yes
  39. %option with_group no
  40. %option with_ignmad no
  41. # list of sources
  42. Source0: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-imapd-%{version}.tar.gz
  43. Source1: rc.imapd
  44. Source2: cyrus.conf
  45. Source3: imapd.conf
  46. Source4: fsl.imapd
  47. Patch0: imapd.patch
  48. Patch1: imapd.patch.group
  49. # build information
  50. Prefix: %{l_prefix}
  51. BuildRoot: %{l_buildroot}
  52. BuildPreReq: OpenPKG, openpkg >= 20040130, perl >= 5.8.3, perl-openpkg >= 5.8.3, make
  53. PreReq: OpenPKG, openpkg >= 20040130, perl >= 5.8.3, MTA
  54. BuildPreReq: sasl, db >= 4.1.24, openssl
  55. PreReq: sasl, db >= 4.1.24, openssl
  56. %if "%{with_fsl}" == "yes"
  57. BuildPreReq: fsl >= 1.2.0
  58. PreReq: fsl >= 1.2.0
  59. %endif
  60. AutoReq: no
  61. AutoReqProv: no
  62. %description
  63. The Cyrus IMAP server is an IMAP4 and POP3 daemon that differs from
  64. other IMAP server implementations in that it is generally intended to
  65. be run on sealed servers, where normal users are not permitted to log
  66. in. The mailbox database is stored in parts of the filesystem that are
  67. private to the Cyrus IMAP system. All user access to mail is through
  68. the IMAP, POP3, or KPOP protocols.
  69. %track
  70. prog imapd = {
  71. version = %{version}
  72. url = ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
  73. regex = cyrus-imapd-(\d+\.\d+\.\d+)\.tar\.gz
  74. }
  75. %prep
  76. %setup -q -n cyrus-imapd-%{version}
  77. %patch -p0
  78. %if "%{with_group}" == "yes"
  79. %patch -p0 -P 1
  80. %{l_shtool} subst \
  81. -e 's;/etc/imapd\.group;%{l_prefix}/etc/imapd/imapd.group;' \
  82. lib/auth_unix.c
  83. %endif
  84. %{l_shtool} subst \
  85. -e 's;-L/usr/local/lib;;g' \
  86. -e 's;-I/usr/local/include;;g' \
  87. -e 's;db-4.1;db;g' \
  88. configure
  89. # ensure local com_err can be used
  90. %{l_shtool} subst -s \
  91. -e 's;#include <com_err.h>;#include "et/com_err.h";' \
  92. `find . -name *.[ch] -print`
  93. # ensure linking of Berkeley DB
  94. %{l_shtool} subst \
  95. -e 's;^\( *.LIBS..*\)\(\"\],.*\)$;\1 -ldb\2;' \
  96. perl/imap/Makefile.PL
  97. # ensure invocation of correct perl in cyradm
  98. %{l_shtool} subst \
  99. -e 's;^\(.) exec\) \(perl .*\)$;\1 %{l_prefix}/bin/\2;' \
  100. perl/imap/cyradm.sh
  101. # adjust hard-coded location of sieve
  102. %{l_shtool} subst \
  103. -e 's;"/usr/sieve";"%{l_prefix}/var/imapd/sieve";g' \
  104. imap/lmtpd.c \
  105. imap/mbdump.c \
  106. imap/user.c \
  107. timsieved/actions.c
  108. # adjust default config to install environment for use in mkimap install helper script
  109. %{l_shtool} install -c -m 644 \
  110. -e "s;\(@l_prefix@\);$RPM_BUILD_ROOT\1;g" \
  111. %{l_value -s -a} \
  112. %{SOURCE imapd.conf} \
  113. imapd.conf-mkimap
  114. %{l_shtool} subst \
  115. -e 's;^exec perl ;exec %{l_prefix}/bin/perl ;' \
  116. -e "s;/etc/imapd.conf;%{l_prefix}/etc/imapd/imapd.conf;" \
  117. -e "s;^\(\$sievedir = \).*$;\1 shift || \"%{l_prefix}/var/imapd/sieve\"\;;" \
  118. tools/mkimap
  119. # ajdust syslog ident of deliver program
  120. %{l_shtool} subst \
  121. -e '/config_init/s;"deliver";"cyrdeliver";' \
  122. imap/deliver.c
  123. %build
  124. cflags="%{l_cppflags}"
  125. %if "%{with_ignmad}" == "yes"
  126. cflags="$cflags -DIGNMAD=yes"
  127. %endif
  128. ldflags="%{l_ldflags} %{l_fsl_ldflags}"
  129. case "%{l_platform -t}" in
  130. *-sunos* ) ldflags="$ldflags -lsocket -lnsl" ;;
  131. esac
  132. CC="%{l_cc}" \
  133. CPPFLAGS="$cflags" \
  134. CFLAGS="%{l_cflags -O} $cflags" \
  135. LDFLAGS="$ldflags" \
  136. LIBS="%{l_fsl_libs}" \
  137. ./configure \
  138. --cache-file=./cache.config \
  139. --prefix=%{l_prefix} \
  140. --sysconfdir=%{l_prefix}/etc/imapd \
  141. --with-openssl=%{l_prefix} \
  142. --with-dbdir=%{l_prefix} \
  143. --with-sasl=%{l_prefix} \
  144. --with-statedir=%{l_prefix}/var/imapd \
  145. --with-auth=unix \
  146. --without-libwrap \
  147. --with-perl \
  148. --without-ucdsnmp \
  149. --with-cyrus-prefix=%{l_prefix} \
  150. --with-cyrus-user=%{l_rusr} \
  151. --with-cyrus-group=%{l_rgrp}
  152. # redirect the hard-coded file paths
  153. %{l_shtool} subst \
  154. -e 's;/etc/\(.*\).conf;%{l_prefix}/etc/imapd/\1.conf;' \
  155. imap/*.c imap/*.h master/*.c master/*.h
  156. %{l_make} %{l_mflags}
  157. %install
  158. rm -rf $RPM_BUILD_ROOT
  159. # install package
  160. %{l_make} %{l_mflags} install \
  161. DESTDIR=$RPM_BUILD_ROOT
  162. # create additional directories
  163. %{l_shtool} mkdir -f -p -m 755 \
  164. $RPM_BUILD_ROOT%{l_prefix}/etc/imapd \
  165. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  166. $RPM_BUILD_ROOT%{l_prefix}/var/imapd/spool \
  167. $RPM_BUILD_ROOT%{l_prefix}/bin
  168. # install sieve adminstration script
  169. %{l_shtool} install -c -m 755 \
  170. perl/sieve/scripts/sieveshell.pl \
  171. $RPM_BUILD_ROOT%{l_prefix}/bin/sieveshell
  172. # offer a sane configuration
  173. l_hostname=`%{l_shtool} echo -e %h`
  174. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  175. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  176. -e "s;@l_hostname@;$l_hostname;g" \
  177. -e "s;@l_domainname@;$l_domainname;g" \
  178. %{SOURCE cyrus.conf} \
  179. %{SOURCE imapd.conf} \
  180. $RPM_BUILD_ROOT%{l_prefix}/etc/imapd/
  181. # install the run command file
  182. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  183. %{SOURCE rc.imapd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  184. # use mkimap to create many directories for us
  185. tools/mkimap imapd.conf-mkimap $RPM_BUILD_ROOT%{l_prefix}/var/imapd/sieve
  186. # rename files which are likely to cause namespace conflicts
  187. ( cd $RPM_BUILD_ROOT%{l_prefix}
  188. for i in deliver master quota reconstruct; do
  189. mv bin/$i bin/cyr$i
  190. mv man/man8/$i.8 man/man8/cyr$i.8
  191. done
  192. ) || exit $?
  193. # install from tools
  194. %{l_shtool} install -c -m 755 \
  195. tools/mkimap \
  196. $RPM_BUILD_ROOT%{l_prefix}/bin/
  197. # install OSSP fsl configuration
  198. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  199. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  200. %{SOURCE fsl.imapd} \
  201. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  202. # strip binaries
  203. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  204. # determine files
  205. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate
  206. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  207. %{l_files_std} \
  208. '%not %dir %{l_prefix}/etc/fsl' \
  209. '%config %{l_prefix}/etc/fsl/fsl.imapd' \
  210. '%config %{l_prefix}/etc/imapd/imapd.conf' \
  211. '%config %{l_prefix}/etc/imapd/cyrus.conf' \
  212. '%dir %attr(0750,%{l_rusr},%{l_mgrp}) %{l_prefix}/var/imapd' \
  213. '%dir %attr(0750,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/imapd/*' \
  214. '%dir %attr(0770,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/imapd/*/*' \
  215. '%dir %attr(0770,%{l_musr},%{l_rgrp}) %{l_prefix}/var/imapd/socket' \
  216. `cat perl-openpkg-files`
  217. %files -f files
  218. %clean
  219. rm -rf $RPM_BUILD_ROOT
  220. %pre
  221. # before upgrade, save status and stop service
  222. [ $1 -eq 2 ] || exit 0
  223. eval `%{l_rc} imapd status 2>/dev/null | tee %{l_tmpfile}`
  224. %{l_rc} imapd stop 2>/dev/null
  225. exit 0
  226. %post
  227. if [ $1 -eq 2 ]; then
  228. # after upgrade, restore status
  229. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
  230. [ ".$imapd_active" = .yes ] && %{l_rc} imapd start
  231. fi
  232. exit 0
  233. %preun
  234. # before erase, stop service and remove log files
  235. [ $1 -eq 0 ] || exit 0
  236. %{l_rc} imapd stop 2>/dev/null
  237. exit 0