imapd.spec 10 KB

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