dovecot.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. ##
  2. ## dovecot.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package version
  24. %define V_major 1.1
  25. %define V_minor 2
  26. %define V_minor_sieve 5
  27. %define V_minor_managesieve 1
  28. %define V_managesieve 0.10.3
  29. # package information
  30. Name: dovecot
  31. Summary: IMAP4 & POP3 Server
  32. URL: http://www.dovecot.org/
  33. Vendor: Timo Sirainen et al.
  34. Packager: OpenPKG Foundation e.V.
  35. Distribution: OpenPKG Community
  36. Class: EVAL
  37. Group: Mail
  38. License: MIT+LGPL
  39. Version: %{V_major}.%{V_minor}
  40. Release: 20080724
  41. # package options
  42. %option with_fsl yes
  43. %option with_pam yes
  44. %option with_ldap no
  45. %option with_mysql no
  46. %option with_pgsql no
  47. %option with_sqlite no
  48. %option with_pop3d no
  49. %option with_managesieve no
  50. %option with_sieve yes
  51. # list of sources
  52. Source0: http://www.dovecot.org/releases/%{V_major}/dovecot-%{V_major}.%{V_minor}.tar.gz
  53. Source1: http://www.dovecot.org/releases/sieve/dovecot-sieve-%{V_major}.%{V_minor_sieve}.tar.gz
  54. Source2: fsl.dovecot
  55. Source3: rc.dovecot
  56. Patch0: dovecot.patch
  57. Patch1: http://www.rename-it.nl/dovecot/%{V_major}/dovecot-%{V_major}.%{V_minor_managesieve}-managesieve-%{V_managesieve}.diff.gz
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20060823
  62. PreReq: OpenPKG, openpkg >= 20060823, MTA
  63. BuildPreReq: libiconv, openssl
  64. PreReq: libiconv, openssl
  65. %if "%{with_fsl}" == "yes"
  66. BuildPreReq: fsl
  67. PreReq: fsl
  68. %endif
  69. %if "%{with_ldap}" == "yes"
  70. BuildPreReq: openldap
  71. PreReq: openldap
  72. %endif
  73. %if "%{with_managesieve}" == "yes"
  74. BuildPreReq: autoconf, automake, pkgconfig, libtool
  75. BuildPreReq: gettext
  76. PreReq: gettext
  77. %endif
  78. %if "%{with_pam}" == "yes"
  79. BuildPreReq: PAM
  80. PreReq: PAM
  81. %endif
  82. %if "%{with_mysql}" == "yes"
  83. BuildPreReq: mysql, zlib
  84. PreReq: mysql, zlib
  85. %endif
  86. %if "%{with_pgsql}" == "yes"
  87. BuildPreReq: postgresql
  88. PreReq: postgresql
  89. %endif
  90. %if "%{with_sqlite}" == "yes"
  91. BuildPreReq: sqlite
  92. PreReq: sqlite
  93. %endif
  94. AutoReq: no
  95. AutoReqProv: no
  96. %description
  97. Dovecot is an Open Source IMAP and POP3 server, written with
  98. security primarily in mind. Dovecot is an excellent choice for both
  99. small and large installations. It's fast, simple to set up, requires
  100. no special administration and it uses very little memory.
  101. %track
  102. prog dovecot = {
  103. version = %{V_major}.%{V_minor}
  104. url = http://www.dovecot.org/download.html
  105. regex = dovecot-(1\.1(\.\d+)+)\.tar\.gz
  106. }
  107. prog dovecot:sieve = {
  108. version = %{V_major}.%{V_minor_sieve}
  109. url = http://www.dovecot.org/download.html
  110. regex = dovecot-sieve-(%{V_major}(\.\d+)+)\.tar\.gz
  111. }
  112. prog dovecot:managesieve = {
  113. version = %{V_managesieve}
  114. url = http://www.rename-it.nl/dovecot/%{V_major}/
  115. regex = dovecot-%{V_major}\.%{V_minor_managesieve}-managesieve-(__VER__)\.diff\.gz
  116. }
  117. %prep
  118. %setup -q
  119. %if "%{with_sieve}" == "yes"
  120. %setup -q -T -D -a 1
  121. %endif
  122. %{l_sed} <%{PATCH0} %{l_value -s -a} | %{l_patch} -p0 -b
  123. %if "%{with_managesieve}" == "yes"
  124. sleep 1
  125. %{l_gzip} -dc <%{PATCH1} | %{l_patch} -p1 -b
  126. sleep 1
  127. autoreconf -i --force || true
  128. %endif
  129. %build
  130. cppflags="%{l_cppflags}"
  131. ldflags="%{l_ldflags} %{l_fsl_ldflags}"
  132. libs="%{l_fsl_libs}"
  133. sql_drivers=""
  134. %if "%{with_ldap}" == "yes"
  135. libs="$libs -llber -lssl -lcrypto"
  136. %endif
  137. %if "%{with_mysql}" == "yes"
  138. cppflags="$cppflags %{l_cppflags mysql}"
  139. ldflags="$ldflags %{l_ldflags mysql}"
  140. sql_drivers="$sql_drivers,mysql"
  141. %endif
  142. %if "%{with_pgsql}" == "yes"
  143. libs="$libs -lssl -lcrypto -lcrypt"
  144. sql_drivers="$sql_drivers,pgsql"
  145. %endif
  146. %if "%{with_sqlite}" == "yes"
  147. sql_drivers="$sql_drivers,sqlite"
  148. %endif
  149. sql_drivers=`echo "$sql_drivers" | sed 's;^,;;'`
  150. CC="%{l_cc}" \
  151. CFLAGS="%{l_cflags -O}" \
  152. CPPFLAGS="$cppflags" \
  153. LDFLAGS="$ldflags" \
  154. LIBS="$libs" \
  155. ./configure \
  156. --prefix=%{l_prefix} \
  157. --sysconfdir=%{l_prefix}/etc/dovecot \
  158. --with-ssldir=%{l_prefix}/etc/dovecot/ssl \
  159. --datadir=%{l_prefix}/share/dovecot \
  160. --docdir=%{l_prefix}/share/dovecot/doc \
  161. --with-rundir=%{l_prefix}/var/dovecot/run \
  162. --with-libiconv-prefix=%{l_prefix} \
  163. --with-ssl=openssl \
  164. --with-deliver \
  165. --with-docs \
  166. %if "%{with_ldap}" == "yes"
  167. --with-ldap \
  168. %else
  169. --without-ldap \
  170. %endif
  171. %if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_sqlite}" == "yes"
  172. --with-sql \
  173. --with-sql-drivers="$sql_drivers" \
  174. %if "%{with_mysql}" == "yes"
  175. --with-mysql \
  176. %else
  177. --without-mysql \
  178. %endif
  179. %if "%{with_pgsql}" == "yes"
  180. --with-pgsql \
  181. %else
  182. --without-pgsql \
  183. %endif
  184. %if "%{with_sqlite}" == "yes"
  185. --with-sqlite \
  186. %else
  187. --without-sqlite \
  188. %endif
  189. %else
  190. --without-sql \
  191. --without-sql-drivers \
  192. --without-mysql \
  193. --without-pgsql \
  194. --without-sqlite \
  195. %endif
  196. %if "%{with_pam}" == "yes"
  197. --with-pam \
  198. %else
  199. --without-pam \
  200. %endif
  201. %if "%{with_pop3d}" == "yes"
  202. --with-pop3d \
  203. %else
  204. --without-pop3d \
  205. %endif
  206. --without-gc \
  207. --without-gssapi \
  208. --without-lucene \
  209. --without-vpopmail \
  210. --enable-shared \
  211. --disable-static
  212. %{l_make} %{l_mflags -O}
  213. %if "%{with_sieve}" == "yes"
  214. # build optional Dovecot LDA sieve plugin
  215. ( cd dovecot-sieve-%{V_major}.%{V_minor_sieve}
  216. CC="%{l_cc}" \
  217. CFLAGS="%{l_cflags -O}" \
  218. CPPFLAGS="%{l_cppflags}" \
  219. LDFLAGS="%{l_ldflags}" \
  220. ./configure \
  221. --prefix=%{l_prefix} \
  222. --with-dovecot=..
  223. %{l_make} %{l_mflags -O}
  224. ) || exit $?
  225. %endif
  226. %install
  227. rm -rf $RPM_BUILD_ROOT
  228. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  229. %if "%{with_sieve}" == "yes"
  230. # install optional Dovecot LDA sieve plugin
  231. ( cd dovecot-sieve-%{V_major}.%{V_minor_sieve}
  232. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  233. ) || exit $?
  234. %endif
  235. # adjust file names of configuration files
  236. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot
  237. for i in dovecot dovecot-ldap dovecot-sql; do
  238. mv ${i}{-example,}.conf
  239. done
  240. ) || exit $?
  241. # create additional dirctories
  242. %{l_shtool} mkdir -f -p -m 755 \
  243. $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot/ssl \
  244. $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/log \
  245. $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/run/login
  246. # install run-command script
  247. %{l_shtool} mkdir -f -p -m 755 \
  248. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  249. %if "%{with_pop3d}" == "yes"
  250. cmd='/<\/\{0,1\}with_pop3d>/d'
  251. %else
  252. cmd='/<with_pop3d>/,/<\/with_pop3d>/d'
  253. %endif
  254. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  255. -e "$cmd" \
  256. %{SOURCE rc.dovecot} \
  257. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  258. # install OSSP fsl configuration
  259. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  260. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  261. %{SOURCE fsl.dovecot} \
  262. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  263. # strip installation
  264. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/dovecot/{,*}/*.la \
  265. >/dev/null 2>&1 || true
  266. strip \
  267. $RPM_BUILD_ROOT%{l_prefix}/sbin/* \
  268. $RPM_BUILD_ROOT%{l_prefix}/libexec/dovecot/* \
  269. >/dev/null 2>&1 || true
  270. # generate file list
  271. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
  272. '%not %dir %{l_prefix}/etc/fsl' \
  273. '%config %{l_prefix}/etc/fsl/fsl.dovecot' \
  274. '%config %attr(0600,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/dovecot/*' \
  275. '%config %attr(0640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/dovecot/dovecot.conf' \
  276. '%dir %attr(0700,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/dovecot/ssl' \
  277. '%dir %attr(0755,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot' \
  278. '%dir %attr(0770,%{l_susr},%{l_rgrp}) %{l_prefix}/var/dovecot/log' \
  279. '%dir %attr(0755,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot/run' \
  280. '%dir %attr(0750,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot/run/login' \
  281. '%doc %{l_prefix}/share/dovecot/doc' \
  282. '%doc %{l_prefix}/share/dovecot/doc/wiki'
  283. %files -f files
  284. %clean
  285. rm -rf $RPM_BUILD_ROOT
  286. %post
  287. # after upgrade, restart service
  288. [ $1 -eq 2 ] || exit 0
  289. eval `%{l_rc} dovecot status 2>/dev/null`
  290. [ ".$dovecot_active" = .yes ] && %{l_rc} dovecot restart
  291. exit 0
  292. %preun
  293. # before erase, stop service and remove log files
  294. [ $1 -eq 0 ] || exit 0
  295. %{l_rc} dovecot stop 2>/dev/null
  296. rm -f $RPM_INSTALL_PREFIX/var/dovecot/* >/dev/null 2>&1 || true
  297. rm -f $RPM_INSTALL_PREFIX/var/dovecot/log/* >/dev/null 2>&1 || true
  298. rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/* >/dev/null 2>&1 || true
  299. rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/login/* >/dev/null 2>&1 || true
  300. exit 0