mysql.spec 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. ##
  2. ## mysql.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.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 16
  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: 20031022
  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.mysql
  49. Patch0: mysql.patch
  50. # build information
  51. Prefix: %{l_prefix}
  52. BuildRoot: %{l_buildroot}
  53. BuildPreReq: OpenPKG, openpkg >= 20030909, perl, gcc
  54. PreReq: OpenPKG, openpkg >= 20030909, perl
  55. BuildPreReq: zlib
  56. PreReq: zlib
  57. AutoReq: no
  58. AutoReqProv: no
  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 %{l_value -s -a} \
  72. mysys/default.c
  73. # determine additional configure options
  74. case "%{l_platform -t}" in
  75. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  76. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  77. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  78. esac
  79. # configure source tree
  80. CC="%{l_cc}" \
  81. CXX="%{l_cxx}" \
  82. CFLAGS="%{l_cflags -O}" \
  83. CXXFLAGS="%{l_cxxflags -O}" \
  84. ./configure \
  85. --prefix=%{l_prefix} \
  86. --sysconfdir=%{l_prefix}/etc/mysql \
  87. --localstatedir=%{l_prefix}/var/mysql \
  88. --libexecdir=%{l_prefix}/libexec/mysql \
  89. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  90. --with-mysqld-user=%{l_musr} \
  91. --enable-thread-safe-client \
  92. %if "%{with_berkeleydb}" == "yes"
  93. --with-berkeley-db \
  94. %endif
  95. %if "%{with_innobase}" == "no"
  96. --without-innodb \
  97. %endif
  98. --with-low-memory \
  99. --disable-shared \
  100. $opt
  101. # build source tree
  102. %{l_make} %{l_mflags}
  103. %install
  104. rm -rf $RPM_BUILD_ROOT
  105. # patch init script
  106. %{l_shtool} subst %{l_value -s -a} \
  107. scripts/mysql_install_db.sh
  108. # perform standard installation procedure
  109. %{l_make} %{l_mflags} install \
  110. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  111. DESTDIR=$RPM_BUILD_ROOT
  112. # move utility 'replace', msql2mysql is patched for new path
  113. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  114. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  115. # strip installation area
  116. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  117. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  118. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  119. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  120. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  121. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  122. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  123. # determine default parameters
  124. %if "%{with_berkeleydb}" == "yes"
  125. l_mysql_bdb_cache_size=8M
  126. l_mysql_bdb_log_buffer_size=32k
  127. l_mysql_bdb_max_lock=10000
  128. %else
  129. l_mysql_bdb_cache_size=0
  130. l_mysql_bdb_log_buffer_size=0
  131. l_mysql_bdb_max_lock=0
  132. %endif
  133. %if "%{with_berkeleydb}" == "yes" || "%{with_innobase}" == "yes"
  134. l_mysqld=mysqld
  135. %else
  136. l_mysqld=mysqld-max
  137. %endif
  138. # install global configuration
  139. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  140. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  141. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  142. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  143. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  144. %{SOURCE my.cnf} \
  145. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  146. %{l_shtool} install -c -m 600 \
  147. %{SOURCE my.pwd} \
  148. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  149. # install run-command script
  150. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  151. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  152. -e "s;@l_mysqld@;${l_mysqld};g" \
  153. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  154. # make sure the database directory exists
  155. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  156. # determine the package files
  157. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  158. %{l_files_std} \
  159. '%config %{l_prefix}/etc/mysql/my.cnf' \
  160. '%config %{l_prefix}/etc/mysql/my.pwd' \
  161. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql'
  162. %files -f files
  163. %clean
  164. rm -rf $RPM_BUILD_ROOT
  165. %pre
  166. # before upgrade, save status and stop service
  167. [ $1 -eq 2 ] || exit 0
  168. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  169. %{l_rc} mysql stop 2>/dev/null
  170. exit 0
  171. %post
  172. if [ $1 -eq 1 ]; then
  173. # after install, create initial database
  174. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  175. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf
  176. chown %{l_rusr}:%{l_rgrp} \
  177. $RPM_INSTALL_PREFIX/etc/mysql/my.cnf \
  178. $RPM_INSTALL_PREFIX/etc/mysql/my.pwd
  179. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  180. ( echo "The MySQL package includes automated maintenance procedures"
  181. echo "that require administrator access to the database. For this"
  182. echo "to work you must keep a copy (plain text) of the administrator"
  183. echo "account in '$RPM_INSTALL_PREFIX/etc/mysql/my.pwd'."
  184. ) | %{l_rpmtool} msg -b -t notice
  185. fi
  186. if [ $1 -eq 2 ]; then
  187. # after upgrade, restore status
  188. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  189. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  190. fi
  191. exit 0
  192. %preun
  193. # before erase, stop service and remove log files
  194. [ $1 -eq 0 ] || exit 0
  195. %{l_rc} mysql stop 2>/dev/null
  196. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  197. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  198. exit 0