mysql.spec 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ##
  2. ## mysql.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package version
  26. %define V_major 3.23
  27. %define V_minor 56
  28. # package information
  29. Name: mysql
  30. Summary: Fast Relational Database Management System
  31. URL: http://www.mysql.com/
  32. Vendor: MySQL AB
  33. Packager: The OpenPKG Project
  34. Distribution: OpenPKG [BASE]
  35. Group: Database
  36. License: GPL
  37. Version: %{V_major}.%{V_minor}
  38. Release: 20030504
  39. # package options
  40. %option with_berkeleydb yes
  41. %option with_innobase no
  42. %option with_gemini no
  43. # list of sources
  44. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{version}.tar.gz
  45. Source1: my.cnf
  46. Source2: my.pwd
  47. Source3: rc.mysql
  48. Patch0: mysql.patch
  49. # build information
  50. Prefix: %{l_prefix}
  51. BuildRoot: %{l_buildroot}
  52. BuildPreReq: OpenPKG, openpkg >= 20030103, gcc, zlib
  53. PreReq: OpenPKG, openpkg >= 20030103, zlib
  54. AutoReq: no
  55. AutoReqProv: no
  56. Provides: MYSQL
  57. Conflicts: mysql4
  58. %description
  59. MySQL is a multi-user Relational Database Management System (RDBMS),
  60. which is controlled through Structured Query Language (SQL) operating in
  61. full multi-threading mode. The main goals of MySQL are speed, robustness
  62. and ease of use. MySQL was originally developed because of the need for
  63. a SQL server that could handle very big databases with magnitude higher
  64. speed than what any database vendor could offer.
  65. %prep
  66. %setup -q
  67. %patch -p0
  68. %build
  69. # patch file search path
  70. %{l_shtool} subst \
  71. -e 's;@l_prefix@;%{l_prefix};g' \
  72. mysys/default.c
  73. # patch socklen_t for Sol6
  74. case "%{l_target}" in
  75. *-solaris2.6* )
  76. %{l_shtool} subst \
  77. -e 's;socklen_t;size_t;g' \
  78. acinclude.m4 \
  79. aclocal.m4 \
  80. configure \
  81. include/global.h \
  82. include/my_global.h \
  83. libmysql/acinclude.m4
  84. %{l_shtool} subst \
  85. -e 's;socklen_t;size_socket;g' \
  86. sql/mini_client.cc \
  87. sql/mysqld.cc
  88. ;;
  89. esac
  90. # determine additional configure options
  91. case "%{l_target}" in
  92. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  93. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  94. *-solaris* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  95. esac
  96. # only use system default path
  97. unset LD_LIBRARY_PATH || true
  98. # configure source tree
  99. CC="%{l_cc}" \
  100. CXX="%{l_cxx}" \
  101. CFLAGS="%{l_cflags -O}" \
  102. CXXFLAGS="%{l_cxxflags -O}" \
  103. ./configure \
  104. --prefix=%{l_prefix} \
  105. --sysconfdir=%{l_prefix}/etc/mysql \
  106. --localstatedir=%{l_prefix}/var/mysql \
  107. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  108. --with-mysqld-user=%{l_musr} \
  109. --enable-thread-safe-client \
  110. %if "%{with_berkeleydb}" == "yes"
  111. --with-berkeley-db \
  112. %endif
  113. %if "%{with_innobase}" == "yes"
  114. --with-innodb \
  115. %endif
  116. %if "%{with_gemini}" == "yes"
  117. --with-gemini \
  118. %endif
  119. --with-low-memory \
  120. --disable-shared \
  121. $opt
  122. # build source tree
  123. %{l_make} %{l_mflags -O}
  124. %install
  125. rm -rf $RPM_BUILD_ROOT
  126. # patch init script
  127. %{l_shtool} subst \
  128. -e 's;@l_prefix@;%{l_prefix};g' \
  129. scripts/mysql_install_db.sh
  130. # perform standard installation procedure
  131. %{l_make} %{l_mflags} install \
  132. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  133. DESTDIR=$RPM_BUILD_ROOT
  134. # KLUDGE: my_dir.h is not installed!
  135. %{l_shtool} install -c -m 644 \
  136. include/my_dir.h $RPM_BUILD_ROOT%{l_prefix}/include/mysql/
  137. # strip installation area
  138. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  139. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  140. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  141. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{version}.spec
  142. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  143. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  144. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/* 2>/dev/null || true
  145. # determine default parameters
  146. %if "%{with_berkeleydb}" == "yes"
  147. l_mysql_bdb_cache_size=8M
  148. l_mysql_bdb_log_buffer_size=32k
  149. l_mysql_bdb_max_lock=10000
  150. %else
  151. l_mysql_bdb_cache_size=0
  152. l_mysql_bdb_log_buffer_size=0
  153. l_mysql_bdb_max_lock=0
  154. %endif
  155. %if "%{with_berkeleydb}" == "yes" || "%{with_innobase}" == "yes" || "%{with_gemini}" == "yes"
  156. l_mysqld=mysqld
  157. %else
  158. l_mysqld=mysqld-max
  159. %endif
  160. # install global configuration
  161. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  162. %{l_shtool} install -c -m 644 \
  163. -e 's;@l_prefix@;%{l_prefix};g' \
  164. -e 's;@l_rusr@;%{l_rusr};g' \
  165. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  166. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  167. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  168. %{SOURCE my.cnf} \
  169. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  170. %{l_shtool} install -c -m 600 \
  171. %{SOURCE my.pwd} \
  172. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  173. # install run-command script
  174. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  175. %{l_shtool} install -c -m 755 \
  176. -e 's;@l_prefix@;%{l_prefix};g' \
  177. -e 's;@l_rusr@;%{l_rusr};g' \
  178. -e 's;@l_rgrp@;%{l_rgrp};g' \
  179. -e "s;@l_mysqld@;${l_mysqld};g" \
  180. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  181. # make sure the database directory exists
  182. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  183. # determine the package files
  184. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  185. %{l_files_std} \
  186. '%config %{l_prefix}/etc/mysql/my.cnf' \
  187. '%config %{l_prefix}/etc/mysql/my.pwd'
  188. %files -f files
  189. %clean
  190. rm -rf $RPM_BUILD_ROOT
  191. %post
  192. # create initial database
  193. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  194. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf
  195. chown %{l_rusr}:%{l_rgrp} \
  196. $RPM_INSTALL_PREFIX/etc/mysql/my.cnf \
  197. $RPM_INSTALL_PREFIX/etc/mysql/my.pwd
  198. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/
  199. ( echo "The MySQL package includes automated maintenance procedures"
  200. echo "that require administrator access to the database. For this"
  201. echo "to work you must keep a copy (plain text) of the administrator"
  202. echo "account in '$RPM_INSTALL_PREFIX/etc/mysql/my.pwd'."
  203. ) | %{l_rpmtool} msg -b -t notice