mysql.spec 9.0 KB

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