mysql.spec 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. ##
  2. ## mysql.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 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 17
  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
  37. Class: BASE
  38. Group: Database
  39. License: GPL
  40. Version: %{V_opkg}
  41. Release: 20040203
  42. # package options
  43. %option with_bdb yes
  44. %option with_innodb no
  45. # list of sources
  46. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  47. Source1: my.cnf
  48. Source2: my.pwd
  49. Source3: rc.mysql
  50. Patch0: mysql.patch
  51. # build information
  52. Prefix: %{l_prefix}
  53. BuildRoot: %{l_buildroot}
  54. BuildPreReq: OpenPKG, openpkg >= 20040130, perl, gcc
  55. PreReq: OpenPKG, openpkg >= 20040130, perl
  56. BuildPreReq: zlib
  57. PreReq: zlib
  58. AutoReq: no
  59. AutoReqProv: no
  60. %description
  61. MySQL is a multi-user Relational Database Management System (RDBMS),
  62. which is controlled through Structured Query Language (SQL) operating in
  63. full multi-threading mode. The main goals of MySQL are speed, robustness
  64. and ease of use. MySQL was originally developed because of the need for
  65. a SQL server that could handle very big databases with magnitude higher
  66. speed than what any database vendor could offer.
  67. %track
  68. prog mysql = {
  69. version = 4.0.17
  70. url = http://www.mysql.com/downloads/mysql-4.0.html
  71. regex = mysql-(__VER__)\.tar\.gz
  72. }
  73. %prep
  74. %setup -q
  75. %patch -p0
  76. %build
  77. # patch file search path
  78. %{l_shtool} subst %{l_value -s -a} \
  79. mysys/default.c
  80. # determine additional configure options
  81. case "%{l_platform -t}" in
  82. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  83. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  84. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  85. esac
  86. # configure source tree
  87. CC="%{l_cc}" \
  88. CXX="%{l_cxx}" \
  89. CFLAGS="%{l_cflags -O}" \
  90. CXXFLAGS="%{l_cxxflags -O}" \
  91. ./configure \
  92. --prefix=%{l_prefix} \
  93. --sysconfdir=%{l_prefix}/etc/mysql \
  94. --localstatedir=%{l_prefix}/var/mysql \
  95. --libexecdir=%{l_prefix}/libexec/mysql \
  96. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  97. --with-mysqld-user=%{l_musr} \
  98. --enable-thread-safe-client \
  99. %if "%{with_bdb}" == "yes"
  100. --with-berkeley-db \
  101. %endif
  102. %if "%{with_innodb}" == "no"
  103. --without-innodb \
  104. %endif
  105. --with-named-z-libs=no \
  106. --with-low-memory \
  107. --disable-shared \
  108. $opt
  109. # build source tree
  110. %{l_make} %{l_mflags}
  111. %install
  112. rm -rf $RPM_BUILD_ROOT
  113. # patch init script
  114. %{l_shtool} subst %{l_value -s -a} \
  115. scripts/mysql_install_db.sh
  116. # perform standard installation procedure
  117. %{l_make} %{l_mflags} install \
  118. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  119. DESTDIR=$RPM_BUILD_ROOT
  120. # move utility 'replace', msql2mysql is patched for new path
  121. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  122. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  123. # strip installation area
  124. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  125. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  126. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  127. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  128. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  129. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  130. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  131. # determine default parameters
  132. %if "%{with_bdb}" == "yes"
  133. l_mysql_bdb_cache_size=8M
  134. l_mysql_bdb_log_buffer_size=32k
  135. l_mysql_bdb_max_lock=10000
  136. %else
  137. l_mysql_bdb_cache_size=0
  138. l_mysql_bdb_log_buffer_size=0
  139. l_mysql_bdb_max_lock=0
  140. %endif
  141. %if "%{with_bdb}" == "yes" || "%{with_innodb}" == "yes"
  142. l_mysqld=mysqld
  143. %else
  144. l_mysqld=mysqld-max
  145. %endif
  146. # install global configuration
  147. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  148. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  149. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  150. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  151. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  152. %{SOURCE my.cnf} \
  153. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  154. %{l_shtool} install -c -m 600 \
  155. %{SOURCE my.pwd} \
  156. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  157. # install run-command script
  158. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  159. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  160. -e "s;@l_mysqld@;${l_mysqld};g" \
  161. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  162. # make sure the database directory exists
  163. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  164. # determine the package files
  165. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  166. %{l_files_std} \
  167. '%config %{l_prefix}/etc/mysql/my.cnf' \
  168. '%config %{l_prefix}/etc/mysql/my.pwd' \
  169. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql'
  170. %files -f files
  171. %clean
  172. rm -rf $RPM_BUILD_ROOT
  173. %pre
  174. # before upgrade, save status and stop service
  175. [ $1 -eq 2 ] || exit 0
  176. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  177. %{l_rc} mysql stop 2>/dev/null
  178. exit 0
  179. %post
  180. if [ $1 -eq 1 ]; then
  181. # after install, create initial database
  182. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  183. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf
  184. chown %{l_rusr}:%{l_rgrp} \
  185. $RPM_INSTALL_PREFIX/etc/mysql/my.cnf \
  186. $RPM_INSTALL_PREFIX/etc/mysql/my.pwd
  187. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  188. ( echo "The MySQL package includes automated maintenance procedures"
  189. echo "that require administrator access to the database. For this"
  190. echo "to work you must keep a copy (plain text) of the administrator"
  191. echo "account in '$RPM_INSTALL_PREFIX/etc/mysql/my.pwd'."
  192. ) | %{l_rpmtool} msg -b -t notice
  193. fi
  194. if [ $1 -eq 2 ]; then
  195. # after upgrade, restore status
  196. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  197. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  198. fi
  199. exit 0
  200. %preun
  201. # before erase, stop service and remove log files
  202. [ $1 -eq 0 ] || exit 0
  203. %{l_rc} mysql stop 2>/dev/null
  204. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  205. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  206. exit 0