dovecot11.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. ##
  2. ## dovecot11.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 rc10
  26. %define V_minor_sieve 5
  27. %define V_minor_managesieve rc10
  28. %define V_managesieve 0.10.2
  29. # package information
  30. Name: dovecot11
  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: 20080617
  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}/rc/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: dovecot11.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. Provides: dovecot = %{version}-%{release}
  97. %description
  98. Dovecot is an Open Source IMAP and POP3 server, written with
  99. security primarily in mind. Dovecot is an excellent choice for both
  100. small and large installations. It's fast, simple to set up, requires
  101. no special administration and it uses very little memory.
  102. %track
  103. prog dovecot11 = {
  104. version = %{V_major}.%{V_minor}
  105. url = http://www.dovecot.org/download.html
  106. regex = dovecot-(1\.1(\.(?:rc)\d+)+)\.tar\.gz
  107. }
  108. prog dovecot11:sieve = {
  109. version = %{V_major}.%{V_minor_sieve}
  110. url = http://www.dovecot.org/download.html
  111. regex = dovecot-sieve-(%{V_major}(\.\d+)+)\.tar\.gz
  112. }
  113. prog dovecot11:managesieve = {
  114. version = %{V_managesieve}
  115. url = http://www.rename-it.nl/dovecot/%{V_major}/
  116. regex = dovecot-%{V_major}\.%{V_minor_managesieve}-managesieve-(__VER__)\.diff\.gz
  117. }
  118. %prep
  119. %setup -q -n dovecot-%{V_major}.%{V_minor}
  120. %if "%{with_sieve}" == "yes"
  121. %setup -q -n dovecot-%{V_major}.%{V_minor} -T -D -a 1
  122. %endif
  123. %{l_sed} <%{PATCH0} %{l_value -s -a} | %{l_patch} -p0 -b
  124. %if "%{with_managesieve}" == "yes"
  125. sleep 1
  126. %{l_gzip} -dc <%{PATCH1} | %{l_patch} -p1 -b
  127. sleep 1
  128. autoreconf -i --force || true
  129. %endif
  130. %build
  131. cppflags="%{l_cppflags}"
  132. ldflags="%{l_ldflags} %{l_fsl_ldflags}"
  133. libs="%{l_fsl_libs}"
  134. sql_drivers=""
  135. %if "%{with_ldap}" == "yes"
  136. libs="$libs -llber -lssl -lcrypto"
  137. %endif
  138. %if "%{with_mysql}" == "yes"
  139. cppflags="$cppflags %{l_cppflags mysql}"
  140. ldflags="$ldflags %{l_ldflags mysql}"
  141. sql_drivers="$sql_drivers,mysql"
  142. %endif
  143. %if "%{with_pgsql}" == "yes"
  144. libs="$libs -lssl -lcrypto -lcrypt"
  145. sql_drivers="$sql_drivers,pgsql"
  146. %endif
  147. %if "%{with_sqlite}" == "yes"
  148. sql_drivers="$sql_drivers,sqlite"
  149. %endif
  150. sql_drivers=`echo "$sql_drivers" | sed 's;^,;;'`
  151. CC="%{l_cc}" \
  152. CFLAGS="%{l_cflags -O}" \
  153. CPPFLAGS="$cppflags" \
  154. LDFLAGS="$ldflags" \
  155. LIBS="$libs" \
  156. ./configure \
  157. --prefix=%{l_prefix} \
  158. --sysconfdir=%{l_prefix}/etc/dovecot \
  159. --with-ssldir=%{l_prefix}/etc/dovecot/ssl \
  160. --datadir=%{l_prefix}/share/dovecot \
  161. --docdir=%{l_prefix}/share/dovecot/doc \
  162. --with-rundir=%{l_prefix}/var/dovecot/run \
  163. --with-libiconv-prefix=%{l_prefix} \
  164. --with-ssl=openssl \
  165. --with-deliver \
  166. --with-docs \
  167. %if "%{with_ldap}" == "yes"
  168. --with-ldap \
  169. %else
  170. --without-ldap \
  171. %endif
  172. %if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_sqlite}" == "yes"
  173. --with-sql \
  174. --with-sql-drivers="$sql_drivers" \
  175. %if "%{with_mysql}" == "yes"
  176. --with-mysql \
  177. %else
  178. --without-mysql \
  179. %endif
  180. %if "%{with_pgsql}" == "yes"
  181. --with-pgsql \
  182. %else
  183. --without-pgsql \
  184. %endif
  185. %if "%{with_sqlite}" == "yes"
  186. --with-sqlite \
  187. %else
  188. --without-sqlite \
  189. %endif
  190. %else
  191. --without-sql \
  192. --without-sql-drivers \
  193. --without-mysql \
  194. --without-pgsql \
  195. --without-sqlite \
  196. %endif
  197. %if "%{with_pam}" == "yes"
  198. --with-pam \
  199. %else
  200. --without-pam \
  201. %endif
  202. %if "%{with_pop3d}" == "yes"
  203. --with-pop3d \
  204. %else
  205. --without-pop3d \
  206. %endif
  207. --without-gc \
  208. --without-gssapi \
  209. --without-lucene \
  210. --without-vpopmail \
  211. --enable-shared \
  212. --disable-static
  213. %{l_make} %{l_mflags -O}
  214. %if "%{with_sieve}" == "yes"
  215. # build optional Dovecot LDA sieve plugin
  216. ( cd dovecot-sieve-%{V_major}.%{V_minor_sieve}
  217. CC="%{l_cc}" \
  218. CFLAGS="%{l_cflags -O}" \
  219. CPPFLAGS="%{l_cppflags}" \
  220. LDFLAGS="%{l_ldflags}" \
  221. ./configure \
  222. --prefix=%{l_prefix} \
  223. --with-dovecot=..
  224. %{l_make} %{l_mflags -O}
  225. ) || exit $?
  226. %endif
  227. %install
  228. rm -rf $RPM_BUILD_ROOT
  229. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  230. %if "%{with_sieve}" == "yes"
  231. # install optional Dovecot LDA sieve plugin
  232. ( cd dovecot-sieve-%{V_major}.%{V_minor_sieve}
  233. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  234. ) || exit $?
  235. %endif
  236. # adjust file names of configuration files
  237. ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot
  238. for i in dovecot dovecot-ldap dovecot-sql; do
  239. mv ${i}{-example,}.conf
  240. done
  241. ) || exit $?
  242. # create additional dirctories
  243. %{l_shtool} mkdir -f -p -m 755 \
  244. $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot/ssl \
  245. $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/log \
  246. $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/run/login
  247. # install run-command script
  248. %{l_shtool} mkdir -f -p -m 755 \
  249. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  250. %if "%{with_pop3d}" == "yes"
  251. cmd='/<\/\{0,1\}with_pop3d>/d'
  252. %else
  253. cmd='/<with_pop3d>/,/<\/with_pop3d>/d'
  254. %endif
  255. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  256. -e "$cmd" \
  257. %{SOURCE rc.dovecot} \
  258. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  259. # install OSSP fsl configuration
  260. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  261. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  262. %{SOURCE fsl.dovecot} \
  263. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  264. # strip installation
  265. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/dovecot/{,*}/*.la \
  266. >/dev/null 2>&1 || true
  267. strip \
  268. $RPM_BUILD_ROOT%{l_prefix}/sbin/* \
  269. $RPM_BUILD_ROOT%{l_prefix}/libexec/dovecot/* \
  270. >/dev/null 2>&1 || true
  271. # generate file list
  272. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
  273. '%not %dir %{l_prefix}/etc/fsl' \
  274. '%config %{l_prefix}/etc/fsl/fsl.dovecot' \
  275. '%config %attr(0600,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/dovecot/*' \
  276. '%config %attr(0640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/dovecot/dovecot.conf' \
  277. '%dir %attr(0700,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/dovecot/ssl' \
  278. '%dir %attr(0755,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot' \
  279. '%dir %attr(0770,%{l_susr},%{l_rgrp}) %{l_prefix}/var/dovecot/log' \
  280. '%dir %attr(0755,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot/run' \
  281. '%dir %attr(0750,%{l_susr},%{l_mgrp}) %{l_prefix}/var/dovecot/run/login' \
  282. '%doc %{l_prefix}/share/dovecot/doc' \
  283. '%doc %{l_prefix}/share/dovecot/doc/wiki'
  284. %files -f files
  285. %clean
  286. rm -rf $RPM_BUILD_ROOT
  287. %post
  288. # after upgrade, restart service
  289. [ $1 -eq 2 ] || exit 0
  290. eval `%{l_rc} dovecot status 2>/dev/null`
  291. [ ".$dovecot_active" = .yes ] && %{l_rc} dovecot restart
  292. exit 0
  293. %preun
  294. # before erase, stop service and remove log files
  295. [ $1 -eq 0 ] || exit 0
  296. %{l_rc} dovecot stop 2>/dev/null
  297. rm -f $RPM_INSTALL_PREFIX/var/dovecot/* >/dev/null 2>&1 || true
  298. rm -f $RPM_INSTALL_PREFIX/var/dovecot/log/* >/dev/null 2>&1 || true
  299. rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/* >/dev/null 2>&1 || true
  300. rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/login/* >/dev/null 2>&1 || true
  301. exit 0