imapd.spec 9.3 KB

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