imapd.spec 9.1 KB

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