mysql.spec 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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 22
  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: 20041209
  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, readline, ncurses
  59. PreReq: zlib, readline, 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. LDFLAGS="-L`pwd`/bdb/build_unix -L`pwd`/libmysql %{l_ldflags}" \
  95. ./configure \
  96. --prefix=%{l_prefix} \
  97. --sysconfdir=%{l_prefix}/etc/mysql \
  98. --localstatedir=%{l_prefix}/var/mysql \
  99. --libexecdir=%{l_prefix}/libexec/mysql \
  100. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  101. --with-mysqld-user=%{l_musr} \
  102. --enable-thread-safe-client \
  103. --with-comment="%{l_openpkg_release}" \
  104. %if "%{with_server}" != "yes"
  105. --without-server \
  106. %endif
  107. %if "%{with_bdb}" == "yes"
  108. --with-berkeley-db \
  109. %endif
  110. %if "%{with_innodb}" == "no"
  111. --without-innodb \
  112. %endif
  113. %if "%{with_ssl}" == "yes"
  114. --with-openssl \
  115. --with-openssl-includes=%{l_prefix}/include \
  116. --with-openssl-libs=%{l_prefix}/lib \
  117. %endif
  118. --without-readline \
  119. --without-libedit \
  120. --with-vio \
  121. --with-named-z-libs=no \
  122. --with-low-memory \
  123. --disable-shared \
  124. $opt
  125. # build source tree
  126. %{l_make} %{l_mflags}
  127. %install
  128. rm -rf $RPM_BUILD_ROOT
  129. # patch init script
  130. %{l_shtool} subst %{l_value -s -a} \
  131. scripts/mysql_install_db.sh
  132. # perform standard installation procedure
  133. %{l_make} %{l_mflags} install \
  134. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  135. DESTDIR=$RPM_BUILD_ROOT
  136. # move utility 'replace', msql2mysql is patched for new path
  137. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  138. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  139. # strip installation area
  140. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  141. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  142. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  143. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  144. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  145. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  146. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  147. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  148. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  149. # determine default parameters
  150. %if "%{with_bdb}" == "yes"
  151. l_mysql_bdb_cache_size=8M
  152. l_mysql_bdb_log_buffer_size=32k
  153. l_mysql_bdb_max_lock=10000
  154. %else
  155. l_mysql_bdb_cache_size=0
  156. l_mysql_bdb_log_buffer_size=0
  157. l_mysql_bdb_max_lock=0
  158. %endif
  159. %if "%{with_bdb}" == "yes" || "%{with_innodb}" == "yes"
  160. l_mysqld=mysqld
  161. %else
  162. l_mysqld=mysqld-max
  163. %endif
  164. # install global configuration
  165. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  166. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  167. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  168. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  169. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  170. %{SOURCE my.cnf} \
  171. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  172. %{l_shtool} install -c -m 600 \
  173. %{SOURCE my.pwd} \
  174. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  175. # install run-command script
  176. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  177. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  178. -e "s;@l_mysqld@;${l_mysqld};g" \
  179. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  180. # make sure the database directory exists
  181. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  182. # directory for temporary tables
  183. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  184. # optional client-only installation
  185. %if "%{with_server}" != "yes"
  186. rm -rf $RPM_BUILD_ROOT%{l_prefix}/bin/*
  187. %endif
  188. # determine the package files
  189. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  190. %if "%{with_server}" == "yes"
  191. %{l_files_std} \
  192. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  193. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  194. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  195. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  196. %else
  197. %{l_files_std}
  198. %endif
  199. %files -f files
  200. %clean
  201. rm -rf $RPM_BUILD_ROOT
  202. %pre
  203. %if "%{with_server}" == "yes"
  204. # before upgrade, save status and stop service
  205. [ $1 -eq 2 ] || exit 0
  206. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  207. %{l_rc} mysql stop 2>/dev/null
  208. %endif
  209. exit 0
  210. %post
  211. %if "%{with_server}" == "yes"
  212. if [ $1 -eq 1 ]; then
  213. # after install, create initial database
  214. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  215. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  216. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  217. ( echo "An initial MySQL DB was created. The owner of the database"
  218. echo "is the DB user 'root'. Its initial password is empty."
  219. echo "After starting MySQL with..."
  220. echo ""
  221. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  222. echo ""
  223. echo "...you should change the password as soon as possible with:"
  224. echo ""
  225. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  226. echo " -u root password '<new-password>'"
  227. echo ""
  228. echo "Additionally, because the MySQL package includes automated"
  229. echo "maintenance procedures that require administrator access to"
  230. echo "the database, you must maintain a (plain text) copy of the"
  231. echo "administrator account name and password:"
  232. echo ""
  233. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  234. ) | %{l_rpmtool} msg -b -t notice
  235. fi
  236. if [ $1 -eq 2 ]; then
  237. # after upgrade, restore status
  238. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  239. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  240. fi
  241. %endif
  242. exit 0
  243. %preun
  244. %if "%{with_server}" == "yes"
  245. # before erase, stop service and remove log files
  246. [ $1 -eq 0 ] || exit 0
  247. %{l_rc} mysql stop 2>/dev/null
  248. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  249. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  250. %endif
  251. exit 0