imapd.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. ##
  2. ## imapd.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 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: imapd
  26. Summary: Cyrus IMAP Server
  27. URL: http://asg.web.cmu.edu/cyrus/imapd/
  28. Vendor: Carnegie Mellon University
  29. Packager: OpenPKG
  30. Distribution: OpenPKG
  31. Class: BASE
  32. Group: Mail
  33. License: BSD
  34. Version: 2.3.1
  35. Release: 20060110
  36. # package options
  37. %option with_fsl yes
  38. %option with_group no
  39. %option with_atvdom no
  40. %option with_drac 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, config
  53. PreReq: OpenPKG, openpkg >= 20040130, perl >= 5.8.3, MTA
  54. BuildPreReq: sasl, db >= 4.2.52, openssl
  55. PreReq: sasl, db >= 4.2.52, 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. # upgrade config scripts for better platform support
  79. %{l_prefix}/bin/config install
  80. %if "%{with_group}" == "yes"
  81. %patch -p0 -P 1
  82. %{l_shtool} subst \
  83. -e 's;/etc/imapd\.group;%{l_prefix}/etc/imapd/imapd.group;' \
  84. lib/auth_unix.c
  85. %endif
  86. %if "%{with_drac}" == "yes"
  87. %{l_shtool} subst -e 's;@DRACLIBS@;-ldrac;g' contrib/drac_auth.patch
  88. %{l_patch} -p0 <contrib/drac_auth.patch
  89. sleep 1
  90. touch configure
  91. %endif
  92. %{l_shtool} subst \
  93. -e 's;-L/usr/local/lib;;g' \
  94. -e 's;-I/usr/local/include;;g' \
  95. -e 's;db-4.1;db;g' \
  96. configure
  97. # ensure local et/com_err can be found
  98. %{l_shtool} subst -s \
  99. -e 's;#include <et/com_err.h>;#include "et/com_err.h";' \
  100. configure
  101. # ensure linking of Berkeley DB
  102. loclibs=""
  103. case "%{l_platform -t}" in
  104. *-sunos* )
  105. %{l_shtool} subst \
  106. -e 's;^\( *.LIBS..*\)\(\"\],.*\)$;\1 -ldb -lrt\2;' \
  107. perl/sieve/managesieve/Makefile.PL \
  108. perl/imap/Makefile.PL
  109. ;;
  110. * )
  111. %{l_shtool} subst \
  112. -e 's;^\( *.LIBS..*\)\(\"\],.*\)$;\1 -ldb\2;' \
  113. perl/sieve/managesieve/Makefile.PL \
  114. perl/imap/Makefile.PL
  115. ;;
  116. esac
  117. # ensure invocation of correct perl
  118. %{l_shtool} subst \
  119. -e 's;^\(.) exec\) \(perl .*\)$;\1 %{l_prefix}/bin/\2;' \
  120. perl/imap/cyradm.sh
  121. %{l_shtool} subst \
  122. -e 's;^\(exec\) \(perl .*\)$;\1 %{l_prefix}/bin/\2;' \
  123. perl/sieve/scripts/*.pl \
  124. snmp/[a-z]* \
  125. tools/[a-z]*
  126. # adjust hard coded location of sieve
  127. %{l_shtool} subst \
  128. -e 's;"/usr/sieve";"%{l_prefix}/var/imapd/sieve";g' \
  129. lib/imapopts.c \
  130. tools/masssievec \
  131. tools/rehash \
  132. tools/translatesieve \
  133. tools/upgradesieve
  134. # adjust default config to install environment for use in mkimap install helper script
  135. %{l_shtool} install -c -m 644 \
  136. -e "s;\(@l_prefix@\);$RPM_BUILD_ROOT\1;g" \
  137. %{l_value -s -a} \
  138. %{SOURCE imapd.conf} \
  139. imapd.conf-mkimap
  140. %{l_shtool} subst \
  141. -e 's;^exec perl ;exec %{l_prefix}/bin/perl ;' \
  142. -e "s;/etc/imapd.conf;%{l_prefix}/etc/imapd/imapd.conf;" \
  143. -e "s;^\(\$sievedir = \).*$;\1 shift || \"%{l_prefix}/var/imapd/sieve\"\;;" \
  144. tools/mkimap
  145. # ajdust syslog ident of deliver program
  146. %{l_shtool} subst \
  147. -e '/alt_config/s;"deliver";"cyrdeliver";' \
  148. imap/deliver.c
  149. %build
  150. cflags="%{l_cppflags}"
  151. %if "%{with_atvdom}" == "yes"
  152. cflags="$cflags -DATVDOM=yes"
  153. %endif
  154. ldflags="%{l_ldflags} %{l_fsl_ldflags}"
  155. case "%{l_platform -t}" in
  156. *-sunos* ) ldflags="$ldflags -lsocket -lnsl" ;;
  157. esac
  158. %if "%{with_drac}" == "yes"
  159. cflags="$cflags -DDRAC_AUTH"
  160. %endif
  161. loclibs=""
  162. case "%{l_platform -t}" in
  163. *-sunos* )
  164. loclibs="-lrt"
  165. ;;
  166. esac
  167. CC="%{l_cc}" \
  168. CPPFLAGS="$cflags" \
  169. CFLAGS="%{l_cflags -O} $cflags" \
  170. LDFLAGS="$ldflags" \
  171. LIBS="%{l_fsl_libs} $loclibs" \
  172. ./configure \
  173. --cache-file=./cache.config \
  174. --prefix=%{l_prefix} \
  175. --sysconfdir=%{l_prefix}/etc/imapd \
  176. --with-openssl=%{l_prefix} \
  177. --with-dbdir=%{l_prefix} \
  178. --with-sasl=%{l_prefix} \
  179. --with-statedir=%{l_prefix}/var/imapd \
  180. --with-auth=unix \
  181. --without-libwrap \
  182. --disable-gssapi \
  183. --without-gss_impl \
  184. --with-perl \
  185. --without-ucdsnmp \
  186. --with-cyrus-prefix=%{l_prefix} \
  187. --with-cyrus-user=%{l_rusr} \
  188. --with-cyrus-group=%{l_rgrp} \
  189. --with-pidfile=%{l_prefix}/var/imapd/cyrus-master.pid
  190. # redirect the hard coded file paths
  191. %{l_shtool} subst \
  192. -e 's;/etc/\(.*\).conf;%{l_prefix}/etc/imapd/\1.conf;' \
  193. imap/*.c imap/*.h master/*.c master/*.h
  194. %{l_make} %{l_mflags}
  195. %install
  196. rm -rf $RPM_BUILD_ROOT
  197. # install package
  198. %{l_make} %{l_mflags} install \
  199. DESTDIR=$RPM_BUILD_ROOT
  200. # create additional directories
  201. %{l_shtool} mkdir -f -p -m 755 \
  202. $RPM_BUILD_ROOT%{l_prefix}/etc/imapd \
  203. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  204. $RPM_BUILD_ROOT%{l_prefix}/var/imapd/log \
  205. $RPM_BUILD_ROOT%{l_prefix}/var/imapd/tmp \
  206. $RPM_BUILD_ROOT%{l_prefix}/var/imapd/spool \
  207. $RPM_BUILD_ROOT%{l_prefix}/bin
  208. # install sieve adminstration script
  209. %{l_shtool} install -c -m 755 \
  210. perl/sieve/scripts/sieveshell.pl \
  211. $RPM_BUILD_ROOT%{l_prefix}/bin/sieveshell
  212. # install sieve command line compiler
  213. %{l_shtool} install -c -m 755 \
  214. sieve/sievec \
  215. $RPM_BUILD_ROOT%{l_prefix}/bin/sievec
  216. # offer a sane configuration
  217. l_hostname=`%{l_shtool} echo -e %h`
  218. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  219. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  220. -e "s;@l_hostname@;$l_hostname;g" \
  221. -e "s;@l_domainname@;$l_domainname;g" \
  222. %{SOURCE cyrus.conf} \
  223. %{SOURCE imapd.conf} \
  224. $RPM_BUILD_ROOT%{l_prefix}/etc/imapd/
  225. # install the run command file
  226. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  227. %{SOURCE rc.imapd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  228. # use mkimap to create many directories for us
  229. tools/mkimap imapd.conf-mkimap $RPM_BUILD_ROOT%{l_prefix}/var/imapd/sieve
  230. # rename files which are likely to cause namespace conflicts
  231. ( cd $RPM_BUILD_ROOT%{l_prefix}
  232. for i in deliver master quota reconstruct; do
  233. mv bin/$i bin/cyr$i
  234. mv man/man8/$i.8 man/man8/cyr$i.8
  235. done
  236. ) || exit $?
  237. # install from tools
  238. %{l_shtool} install -c -m 755 \
  239. tools/mkimap \
  240. $RPM_BUILD_ROOT%{l_prefix}/bin/
  241. # install OSSP fsl configuration
  242. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  243. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  244. %{SOURCE fsl.imapd} \
  245. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  246. # strip binaries
  247. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  248. # determine files
  249. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate
  250. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  251. %{l_files_std} \
  252. '%not %dir %{l_prefix}/etc/fsl' \
  253. '%config %{l_prefix}/etc/fsl/fsl.imapd' \
  254. '%config %{l_prefix}/etc/imapd/imapd.conf' \
  255. '%config %{l_prefix}/etc/imapd/cyrus.conf' \
  256. '%dir %attr(0750,%{l_rusr},%{l_mgrp}) %{l_prefix}/var/imapd' \
  257. '%dir %attr(0750,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/imapd/*' \
  258. '%dir %attr(0770,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/imapd/*/*' \
  259. '%dir %attr(0770,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/imapd/tmp' \
  260. '%dir %attr(0770,%{l_musr},%{l_rgrp}) %{l_prefix}/var/imapd/socket' \
  261. `cat perl-openpkg-files`
  262. %files -f files
  263. %clean
  264. rm -rf $RPM_BUILD_ROOT
  265. %pre
  266. # before upgrade, save status and stop service
  267. [ $1 -eq 2 ] || exit 0
  268. eval `%{l_rc} imapd status 2>/dev/null | tee %{l_tmpfile}`
  269. %{l_rc} imapd stop 2>/dev/null
  270. exit 0
  271. %post
  272. if [ $1 -eq 2 ]; then
  273. # after upgrade, restore status
  274. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
  275. [ ".$imapd_active" = .yes ] && %{l_rc} imapd start
  276. fi
  277. exit 0
  278. %preun
  279. # before erase, stop service and remove log and temp files
  280. [ $1 -eq 0 ] || exit 0
  281. %{l_rc} imapd stop 2>/dev/null
  282. rm -f $RPM_INSTALL_PREFIX/var/imapd/log/*.log >/dev/null 2>&1 || true
  283. rm -rf $RPM_INSTALL_PREFIX/var/imapd/tmp >/dev/null 2>&1 || true
  284. exit 0