dbmail.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. ##
  2. ## dbmail.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 component versions
  24. %define V_major 2.2
  25. %define V_minor 10
  26. # package information
  27. Name: dbmail
  28. Summary: Fast Scalable RDBMS Mail Server
  29. URL: http://www.dbmail.org/
  30. Vendor: IC&S
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Mail
  35. License: GPL
  36. Version: %{V_major}.%{V_minor}
  37. Release: 20080325
  38. # package options
  39. %option with_fsl yes
  40. %option with_sieve yes
  41. %option with_sqlite yes
  42. %option with_mysql no
  43. %option with_pgsql no
  44. %option with_ldap no
  45. # checking for option conflicts
  46. %if "%{with_sqlite}" == "no" && "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
  47. %{error:one of the build-time options 'with_sqlite', 'with_mysql' or 'with_pgsql' have to be enabled}
  48. %endif
  49. # list of sources
  50. Source0: http://www.dbmail.org/download/%{V_major}/dbmail-%{V_major}.%{V_minor}.tar.gz
  51. Source1: fsl.dbmail
  52. Source2: rc.dbmail
  53. Source3: dbmail-setup.sh
  54. Patch0: dbmail.patch
  55. # build information
  56. Prefix: %{l_prefix}
  57. BuildRoot: %{l_buildroot}
  58. BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, pkgconfig
  59. PreReq: OpenPKG, openpkg >= 20060823, MTA
  60. BuildPreReq: libiconv, gettext, gc, glib2, gmime
  61. PreReq: libiconv, gettext, gc, glib2, gmime
  62. %if "%{with_fsl}" == "yes"
  63. BuildPreReq: fsl
  64. PreReq: fsl
  65. %endif
  66. %if "%{with_sieve}" == "yes"
  67. BuildPreReq: libsieve >= 2.2
  68. PreReq: libsieve >= 2.2
  69. %endif
  70. %if "%{with_sqlite}" == "yes"
  71. BuildPreReq: sqlite >= 3.4.1
  72. PreReq: sqlite >= 3.4.1
  73. %endif
  74. %if "%{with_mysql}" == "yes"
  75. BuildPreReq: mysql, mysql::with_innobase = yes, zlib
  76. PreReq: mysql, mysql::with_innobase = yes, zlib
  77. %endif
  78. %if "%{with_pgsql}" == "yes"
  79. BuildPreReq: postgresql >= 8.2.4-20070906, openssl
  80. PreReq: postgresql >= 8.2.4-20070906, openssl
  81. %endif
  82. %if "%{with_ldap}" == "yes"
  83. BuildPreReq: openldap, openssl
  84. PreReq: openldap, openssl
  85. %endif
  86. AutoReq: no
  87. AutoReqProv: no
  88. %description
  89. DBMail is a collection of programs that enables Email to be
  90. stored in and retrieved from a RDBMS. Currently SQLite, MySQL
  91. and PostgreSQL can be used as RDBMS. Advantages of DBMail are
  92. in the areas of scalability, manageability, speed, security and
  93. flexibility.
  94. %track
  95. prog dbmail = {
  96. version = %{V_major}.%{V_minor}
  97. url = http://www.dbmail.org/index.php?page=download
  98. regex = dbmail-(\d+\.\d*[02468](\.\d+)+)\.tar\.gz
  99. }
  100. %prep
  101. %setup -q -n dbmail-%{V_major}.%{V_minor}
  102. %patch -p0
  103. %build
  104. export CC="%{l_cc}"
  105. export CFLAGS="%{l_cflags -O}"
  106. export CPPFLAGS="%{l_cppflags}"
  107. export LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}"
  108. export LIBS="%{l_fsl_libs}"
  109. %if "%{with_pgsql}" == "yes"
  110. LIBS="$LIBS -lssl -lcrypto"
  111. %endif
  112. %if "%{with_ldap}" == "yes"
  113. LIBS="$LIBS -llber -lssl -lcrypto"
  114. %endif
  115. ./configure \
  116. --prefix=%{l_prefix} \
  117. --mandir=%{l_prefix}/man \
  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;@l_bash@;%{l_bash};g" \
  191. -e "s;@db_type@;$db_type;g" \
  192. %{SOURCE dbmail-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/dbmail-setup
  193. # install default configuration file
  194. %{l_shtool} install%{l_nil} -c -m 600 %{l_value -s -a} \
  195. -e 's;[ ]*$;;' \
  196. -e "s;^\\(driver[^=]*=\\).*$;\\1 $db_type;" \
  197. %if "%{with_ldap}" == "yes"
  198. -e 's;^\(authdriver[^=]*=\).*$;\1 ldap;' \
  199. %else
  200. -e 's;^\(authdriver[^=]*=\).*$;\1 sql;' \
  201. %endif
  202. %if "%{with_sqlite}" == "yes"
  203. -e 's;^\(user[^=]*=\).*$;\1 %{l_rusr};' \
  204. -e 's;^\(pass[^=]*=\).*$;\1 %{l_rgrp};' \
  205. -e 's;^\(db[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/db/dbmail.db;' \
  206. %else
  207. -e 's;^\(user[^=]*=\).*$;\1 dbmail;' \
  208. -e 's;^\(pass[^=]*=\).*$;\1 dbmail;' \
  209. -e 's;^\(db[^=]*=\).*$;\1 dbmail;' \
  210. %endif
  211. -e 's;^\(sendmail[^=]*=\).*$;\1 %{l_prefix}/sbin/sendmail;' \
  212. -e 's;^\(EFFECTIVE_USER[^=]*=\).*$;\1 %{l_rusr};' \
  213. -e 's;^\(EFFECTIVE_GROUP[^=]*=\).*$;\1 %{l_rgrp};' \
  214. -e 's;^\(BINDIP[^=]*=\).*$;\1 127.0.0.1;' \
  215. -e 's;^\(RESOLVE_IP[^=]*=\).*$;\1 no;' \
  216. -e 's;^\(logfile[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/log/dbmail-output.log;' \
  217. -e 's;^\(errorlog[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/log/dbmail-output.log;' \
  218. -e 's;^\(pid_directory[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/run;' \
  219. -e 's;^\(state_directory[^=]*=\).*$;\1 %{l_prefix}/var/dbmail/run;' \
  220. -e 's;dc=mydomain;dc=example;g' \
  221. dbmail.conf $RPM_BUILD_ROOT%{l_prefix}/etc/dbmail/
  222. # install additional setup documentation
  223. %{l_shtool} install%{l_nil} -c -m 644 \
  224. %if "%{with_sieve}" == "yes"
  225. README.sieve \
  226. %endif
  227. README.{aliases,exim,postfix,sieve,smtp,usermap} \
  228. $RPM_BUILD_ROOT%{l_prefix}/share/dbmail/
  229. # determine installation files
  230. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
  231. '%config %attr(0640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/dbmail/*' \
  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/bin/openpkg rc mysql start"
  255. %endif
  256. %if "%{with_pgsql}" == "yes"
  257. echo "after starting your PostgreSQL RDBMS with"
  258. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg 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 "For instance for the Postfix MTA this is achieved via:"
  265. echo " # transport:"
  266. echo " <domain> lmtp:127.0.0.1:24"
  267. echo "Finally, add each of your users to DBMail with:"
  268. echo " \$ $RPM_INSTALL_PREFIX/sbin/dbmail-users \\%{l_nil}"
  269. echo " -a <username> -w <password> -s <user>@<domain>"
  270. ) | %{l_rpmtool} msg -b -t notice
  271. elif [ $1 -eq 2 ]; then
  272. # after upgrade, restart service
  273. [ $1 -eq 2 ] || exit 0
  274. eval `%{l_rc} dbmail status 2>/dev/null`
  275. [ ".$dbmail_active" = .yes ] && %{l_rc} dbmail restart
  276. fi
  277. exit 0
  278. %preun
  279. if [ $1 -eq 0 ]; then
  280. # before erase, stop service and remove log files
  281. [ $1 -eq 0 ] || exit 0
  282. %{l_rc} dbmail stop 2>/dev/null
  283. $RPM_INSTALL_PREFIX/sbin/dbmail-setup uninstall >/dev/null 2>&1 || true
  284. rm -f $RPM_INSTALL_PREFIX/var/dbmail/db/* >/dev/null 2>&1 || true
  285. rm -f $RPM_INSTALL_PREFIX/var/dbmail/run/* >/dev/null 2>&1 || true
  286. rm -f $RPM_INSTALL_PREFIX/var/dbmail/log/* >/dev/null 2>&1 || true
  287. fi
  288. exit 0