mysql.spec 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 4.0
  27. %define V_minor 13
  28. %define V_mysql %{V_major}.%{V_minor}
  29. %define V_opkg %{V_major}.%{V_minor}
  30. # package information
  31. Name: mysql
  32. Summary: Fast Relational Database Management System
  33. URL: http://www.mysql.com/
  34. Vendor: MySQL AB
  35. Packager: The OpenPKG Project
  36. Distribution: OpenPKG [BASE]
  37. Group: Database
  38. License: GPL
  39. Version: %{V_opkg}
  40. Release: 20030609
  41. # package options
  42. %option with_berkeleydb yes
  43. %option with_innobase no
  44. # list of sources
  45. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  46. Source1: my.cnf
  47. Source2: my.pwd
  48. Source3: rc.%{name}
  49. Patch0: %{name}.patch
  50. # build information
  51. Prefix: %{l_prefix}
  52. BuildRoot: %{l_buildroot}
  53. BuildPreReq: OpenPKG, openpkg >= 20030103, gcc, zlib
  54. PreReq: OpenPKG, openpkg >= 20030103, zlib
  55. AutoReq: no
  56. AutoReqProv: no
  57. Provides: MYSQL
  58. Conflicts: mysql3
  59. %description
  60. MySQL is a multi-user Relational Database Management System (RDBMS),
  61. which is controlled through Structured Query Language (SQL) operating in
  62. full multi-threading mode. The main goals of MySQL are speed, robustness
  63. and ease of use. MySQL was originally developed because of the need for
  64. a SQL server that could handle very big databases with magnitude higher
  65. speed than what any database vendor could offer.
  66. %prep
  67. %setup -q
  68. %patch -p0
  69. %build
  70. # patch file search path
  71. %{l_shtool} subst \
  72. -e 's;@l_prefix@;%{l_prefix};g' \
  73. mysys/default.c
  74. # determine additional configure options
  75. case "%{l_target}" in
  76. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  77. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  78. *-solaris* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  79. esac
  80. # configure source tree
  81. CC="%{l_cc}" \
  82. CXX="%{l_cxx}" \
  83. CFLAGS="%{l_cflags -O}" \
  84. CXXFLAGS="%{l_cxxflags -O}" \
  85. ./configure \
  86. --prefix=%{l_prefix} \
  87. --sysconfdir=%{l_prefix}/etc/%{name} \
  88. --localstatedir=%{l_prefix}/var/%{name} \
  89. --libexecdir=%{l_prefix}/libexec/%{name} \
  90. --with-unix-socket-path=%{l_prefix}/var/%{name}/mysql.sock \
  91. --with-mysqld-user=%{l_musr} \
  92. --enable-thread-safe-client \
  93. %if "%{with_berkeleydb}" == "yes"
  94. --with-berkeley-db \
  95. %endif
  96. %if "%{with_innobase}" == "no"
  97. --without-innodb \
  98. %endif
  99. --with-low-memory \
  100. --disable-shared \
  101. $opt
  102. # build source tree
  103. %{l_make} %{l_mflags}
  104. %install
  105. rm -rf $RPM_BUILD_ROOT
  106. # patch init script
  107. %{l_shtool} subst \
  108. -e 's;@l_prefix@;%{l_prefix};g' \
  109. scripts/mysql_install_db.sh
  110. # perform standard installation procedure
  111. %{l_make} %{l_mflags} install \
  112. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  113. DESTDIR=$RPM_BUILD_ROOT
  114. # move utility 'replace', msql2mysql is patched for new path
  115. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  116. $RPM_BUILD_ROOT%{l_prefix}/libexec/%{name}
  117. # strip installation area
  118. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  119. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  120. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  121. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/%{name}/mysql-%{V_mysql}.spec
  122. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/%{name}/binary-configure
  123. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  124. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/%{name}/* 2>/dev/null || true
  125. # determine default parameters
  126. %if "%{with_berkeleydb}" == "yes"
  127. l_mysql_bdb_cache_size=8M
  128. l_mysql_bdb_log_buffer_size=32k
  129. l_mysql_bdb_max_lock=10000
  130. %else
  131. l_mysql_bdb_cache_size=0
  132. l_mysql_bdb_log_buffer_size=0
  133. l_mysql_bdb_max_lock=0
  134. %endif
  135. %if "%{with_berkeleydb}" == "yes" || "%{with_innobase}" == "yes" || "%{with_gemini}" == "yes"
  136. l_mysqld=mysqld
  137. %else
  138. l_mysqld=mysqld-max
  139. %endif
  140. # install global configuration
  141. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/%{name}
  142. %{l_shtool} install -c -m 644 \
  143. -e 's;@l_prefix@;%{l_prefix};g' \
  144. -e 's;@l_rusr@;%{l_rusr};g' \
  145. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  146. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  147. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  148. %{SOURCE my.cnf} \
  149. $RPM_BUILD_ROOT%{l_prefix}/etc/%{name}/
  150. %{l_shtool} install -c -m 600 \
  151. %{SOURCE my.pwd} \
  152. $RPM_BUILD_ROOT%{l_prefix}/etc/%{name}/
  153. # install run-command script
  154. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  155. %{l_shtool} install -c -m 755 \
  156. -e 's;@l_prefix@;%{l_prefix};g' \
  157. -e 's;@l_rusr@;%{l_rusr};g' \
  158. -e 's;@l_rgrp@;%{l_rgrp};g' \
  159. -e "s;@l_mysqld@;${l_mysqld};g" \
  160. %{SOURCE rc.%{name}} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  161. # make sure the database directory exists
  162. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/%{name}
  163. # determine the package files
  164. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  165. %{l_files_std} \
  166. '%config %{l_prefix}/etc/%{name}/my.cnf' \
  167. '%config %{l_prefix}/etc/%{name}/my.pwd'
  168. %files -f files
  169. %clean
  170. rm -rf $RPM_BUILD_ROOT
  171. %post
  172. # create initial database
  173. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  174. --defaults-file=$RPM_INSTALL_PREFIX/etc/%{name}/my.cnf
  175. chown %{l_rusr}:%{l_rgrp} \
  176. $RPM_INSTALL_PREFIX/etc/%{name}/my.cnf \
  177. $RPM_INSTALL_PREFIX/etc/%{name}/my.pwd
  178. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/%{name}/
  179. ( echo "The MySQL package includes automated maintenance procedures"
  180. echo "that require administrator access to the database. For this"
  181. echo "to work you must keep a copy (plain text) of the administrator"
  182. echo "account in '$RPM_INSTALL_PREFIX/etc/%{name}/my.pwd'."
  183. ) | %{l_rpmtool} msg -b -t notice