dbmail.spec 11 KB

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