imapd.spec 9.3 KB

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