mysql.spec 8.4 KB

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