dbmail.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. ##
  2. ## dbmail.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 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 component versions
  25. %define V_major 2.2
  26. %define V_minor 3
  27. # package information
  28. Name: dbmail
  29. Summary: Fast Scalable RDBMS Mail Server
  30. URL: http://www.dbmail.org/
  31. Vendor: IC&S
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: EVAL
  35. Group: Mail
  36. License: GPL
  37. Version: %{V_major}.%{V_minor}
  38. Release: 20070228
  39. # package options
  40. %option with_fsl yes
  41. %option with_sieve yes
  42. %option with_sqlite yes
  43. %option with_mysql no
  44. %option with_pgsql no
  45. %option with_ldap no
  46. # checking for option conflicts
  47. %if "%{with_sqlite}" == "no" && "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
  48. %{error:one of the build-time options 'with_sqlite', 'with_mysql' or 'with_pgsql' have to be enabled}
  49. %endif
  50. # list of sources
  51. Source0: http://www.dbmail.org/download/%{V_major}/dbmail-%{V_major}.%{V_minor}.tar.gz
  52. Source1: fsl.dbmail
  53. Source2: rc.dbmail
  54. Source3: dbmail-setup.sh
  55. Patch0: dbmail.patch
  56. # build information
  57. Prefix: %{l_prefix}
  58. BuildRoot: %{l_buildroot}
  59. BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, pkgconfig
  60. PreReq: OpenPKG, openpkg >= 20060823, MTA
  61. BuildPreReq: libiconv, gettext, gc, glib2, gmime
  62. PreReq: libiconv, gettext, gc, glib2, gmime
  63. %if "%{with_fsl}" == "yes"
  64. BuildPreReq: fsl >= 1.6.0
  65. PreReq: fsl >= 1.6.0
  66. %endif
  67. %if "%{with_sieve}" == "yes"
  68. BuildPreReq: libsieve >= 2.2
  69. PreReq: libsieve >= 2.2
  70. %endif
  71. %if "%{with_sqlite}" == "yes"
  72. BuildPreReq: sqlite
  73. PreReq: sqlite
  74. %endif
  75. %if "%{with_mysql}" == "yes"
  76. BuildPreReq: mysql, mysql::with_innobase = yes, zlib
  77. PreReq: mysql, mysql::with_innobase = yes, zlib
  78. %endif
  79. %if "%{with_pgsql}" == "yes"
  80. BuildPreReq: postgresql, openssl
  81. PreReq: postgresql, openssl
  82. %endif
  83. %if "%{with_ldap}" == "yes"
  84. BuildPreReq: openldap, openssl
  85. PreReq: openldap, openssl
  86. %endif
  87. AutoReq: no
  88. AutoReqProv: no
  89. %description
  90. DBMail is a collection of programs that enables Email to be
  91. stored in and retrieved from a RDBMS. Currently SQLite, MySQL
  92. and PostgreSQL can be used as RDBMS. Advantages of DBMail are
  93. in the areas of scalability, manageability, speed, security and
  94. flexibility.
  95. %track
  96. prog dbmail = {
  97. version = %{version}
  98. url = http://www.dbmail.org/index.php?page=download
  99. regex = dbmail-(\d+\.[02468](?:\.\d+)+)\.tar\.gz
  100. }
  101. %prep
  102. %setup -q
  103. %patch -p0
  104. %build
  105. export CC="%{l_cc}"
  106. export CFLAGS="%{l_cflags -O}"
  107. export CPPFLAGS="%{l_cppflags}"
  108. export LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}"
  109. export LIBS="%{l_fsl_libs}"
  110. %if "%{with_pgsql}" == "yes"
  111. LIBS="$LIBS -lssl -lcrypto"
  112. %endif
  113. %if "%{with_ldap}" == "yes"
  114. LIBS="$LIBS -llber -lssl -lcrypto"
  115. %endif
  116. ./configure \
  117. --prefix=%{l_prefix} \
  118. --sysconfdir=%{l_prefix}/etc/dbmail \
  119. --localstatedir=%{l_prefix}/var/dbmail/run \
  120. --with-logdir=%{l_prefix}/var/dbmail/log \
  121. --with-gc=%{l_prefix} \
  122. %if "%{with_sieve}" == "yes"
  123. --with-sieve=%{l_prefix}/include \
  124. %endif
  125. %if "%{with_sqlite}" == "yes"
  126. --with-sqlite \
  127. %else
  128. --without-sqlite \
  129. %endif
  130. %if "%{with_mysql}" == "yes"
  131. --with-mysql \
  132. %else
  133. --without-mysql \
  134. %endif
  135. %if "%{with_pgsql}" == "yes"
  136. --with-pgsql \
  137. %else
  138. --without-pgsql \
  139. %endif
  140. %if "%{with_ldap}" == "yes"
  141. --with-auth-ldap=%{l_prefix}/include \
  142. %else
  143. --without-auth-ldap \
  144. %endif
  145. --disable-shared \
  146. --enable-static
  147. %{l_make} %{l_mflags -O}
  148. %install
  149. rm -rf $RPM_BUILD_ROOT
  150. # install DBMail
  151. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  152. # create additional directories
  153. %{l_shtool} mkdir -f -p -m 755 \
  154. $RPM_BUILD_ROOT%{l_prefix}/etc/dbmail \
  155. $RPM_BUILD_ROOT%{l_prefix}/var/dbmail/db \
  156. $RPM_BUILD_ROOT%{l_prefix}/var/dbmail/log \
  157. $RPM_BUILD_ROOT%{l_prefix}/var/dbmail/run
  158. # strip down installation
  159. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  160. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/dbmail >/dev/null 2>&1 || true
  161. # install run-command script
  162. %{l_shtool} mkdir -f -p -m 755 \
  163. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  164. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  165. %{SOURCE rc.dbmail} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  166. # install OSSP fsl configuration
  167. %{l_shtool} mkdir -f -p -m 755 \
  168. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  169. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  170. %{SOURCE fsl.dbmail} \
  171. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  172. # install database setup stuff
  173. %if "%{with_sqlite}" == "yes"
  174. db_type='sqlite'
  175. db_script='sql/sqlite/create_tables.sqlite'
  176. %endif
  177. %if "%{with_mysql}" == "yes"
  178. db_type='mysql'
  179. db_script='sql/mysql/create_tables.mysql'
  180. %endif
  181. %if "%{with_pgsql}" == "yes"
  182. db_type='pgsql'
  183. db_script='sql/postgresql/create_tables.pgsql'
  184. %endif
  185. %{l_shtool} mkdir -f -p -m 755 \
  186. $RPM_BUILD_ROOT%{l_prefix}/share/dbmail
  187. %{l_shtool} install -c -m 644 \
  188. $db_script $RPM_BUILD_ROOT%{l_prefix}/share/dbmail/dbmail-setup.sql
  189. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  190. -e "s;@db_type@;$db_type;g" \
  191. %{SOURCE dbmail-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/dbmail-setup
  192. # install default configuration file
  193. %{l_shtool} install%{l_nil} -c -m 600 %{l_value -s -a} \
  194. -e 's;[ ]*$;;' \
  195. -e "s;^\\(driver[^=]*=\\).*$;\\1 $db_type;" \
  196. %if "%{with_ldap}" == "yes"
  197. -e 's;^\(authdriver[^=]*=\).*$;\1 ldap;' \
  198. %else
  199. -e 's;^\(authdriver[^=]*=\).*$;\1 sql;' \
  200. %endif
  201. %if "%{with_sqlite}" == "yes"
  202. -e 's;^\(user[^=]*=\).*$;\1 %{l_rusr};' \
  203. -e 's;^\(pass[^=]*=\).*$;\1 %{l_rgrp};' \
  204. -e 's;^\(db[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/db/dbmail.db;' \
  205. %else
  206. -e 's;^\(user[^=]*=\).*$;\1 dbmail;' \
  207. -e 's;^\(pass[^=]*=\).*$;\1 dbmail;' \
  208. -e 's;^\(db[^=]*=\).*$;\1;' \
  209. %endif
  210. -e 's;^\(sendmail[^=]*=\).*$;\1 %{l_prefix}/sbin/sendmail;' \
  211. -e 's;^\(EFFECTIVE_USER[^=]*=\).*$;\1 %{l_rusr};' \
  212. -e 's;^\(EFFECTIVE_GROUP[^=]*=\).*$;\1 %{l_rgrp};' \
  213. -e 's;^\(BINDIP[^=]*=\).*$;\1 127.0.0.1;' \
  214. -e 's;^\(RESOLVE_IP[^=]*=\).*$;\1 no;' \
  215. -e 's;^\(logfile[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/log/dbmail-output.log;' \
  216. -e 's;^\(errorlog[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/log/dbmail-output.log;' \
  217. -e 's;^\(pid_directory[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/run;' \
  218. -e 's;^\(state_directory[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/run;' \
  219. -e 's;dc=mydomain;dc=example;g' \
  220. dbmail.conf $RPM_BUILD_ROOT%{l_prefix}/etc/dbmail/
  221. # install additional setup documentation
  222. %{l_shtool} install%{l_nil} -c -m 644 \
  223. %if "%{with_sieve}" == "yes"
  224. README.sieve \
  225. %endif
  226. README.{aliases,exim,postfix,sieve,smtp,usermap} \
  227. $RPM_BUILD_ROOT%{l_prefix}/share/dbmail/
  228. # determine installation files
  229. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
  230. '%config %attr(0640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/dbmail/*' \
  231. '%not %dir %{l_prefix}/etc/fsl' \
  232. '%config %{l_prefix}/etc/fsl/fsl.dbmail' \
  233. '%doc %{l_prefix}/share/dbmail/README.*' \
  234. '%dir %attr(0770,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/dbmail/*'
  235. %files -f files
  236. %clean
  237. rm -rf $RPM_BUILD_ROOT
  238. %post
  239. if [ $1 -eq 1 ]; then
  240. %if "%{with_sqlite}" == "yes"
  241. ( echo "Establishing initial DBMail SQLite database"
  242. ) | %{l_rpmtool} msg -b -t notice
  243. $RPM_INSTALL_PREFIX/sbin/dbmail-setup install
  244. %endif
  245. # display final hints on initial installation
  246. ( echo "First, please adjust the configuration file"
  247. echo " $RPM_INSTALL_PREFIX/etc/dbmail/dbmail.conf"
  248. echo "especially in terms of database configuration because"
  249. echo "those settings are relevant to the dbmail-setup utility."
  250. echo "To complete this installation of DBMail,"
  251. %if "%{with_sqlite}" != "yes"
  252. %if "%{with_mysql}" == "yes"
  253. echo "after starting your MySQL RDBMS with"
  254. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  255. %endif
  256. %if "%{with_pgsql}" == "yes"
  257. echo "after starting your PostgreSQL RDBMS with"
  258. echo " \$ $RPM_INSTALL_PREFIX/etc/rc postgresql start"
  259. %endif
  260. echo "please establish the initial DBMail database with:"
  261. echo " \$ $RPM_INSTALL_PREFIX/sbin/dbmail-setup install"
  262. %endif
  263. echo "Then hook DBMail into your particular MTA manually"
  264. echo "and add each of your users to DBMail with the commands:"
  265. echo " \$ $RPM_INSTALL_PREFIX/sbin/dbmail-users \\%{l_nil}"
  266. echo " -a <username> -w <password> -s <user>@<domain>"
  267. ) | %{l_rpmtool} msg -b -t notice
  268. elif [ $1 -eq 2 ]; then
  269. # after upgrade, restart service
  270. [ $1 -eq 2 ] || exit 0
  271. eval `%{l_rc} dbmail status 2>/dev/null`
  272. [ ".$dbmail_active" = .yes ] && %{l_rc} dbmail restart
  273. fi
  274. exit 0
  275. %preun
  276. if [ $1 -eq 0 ]; then
  277. # before erase, stop service and remove log files
  278. [ $1 -eq 0 ] || exit 0
  279. %{l_rc} dbmail stop 2>/dev/null
  280. $RPM_INSTALL_PREFIX/sbin/dbmail-setup uninstall >/dev/null 2>&1 || true
  281. rm -f $RPM_INSTALL_PREFIX/var/dbmail/db/* >/dev/null 2>&1 || true
  282. rm -f $RPM_INSTALL_PREFIX/var/dbmail/run/* >/dev/null 2>&1 || true
  283. rm -f $RPM_INSTALL_PREFIX/var/dbmail/log/* >/dev/null 2>&1 || true
  284. fi
  285. exit 0