mysql40.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. ##
  2. ## mysql40.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2005 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2005 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2005 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 23a
  28. %define V_mysql %{V_major}.%{V_minor}
  29. %define V_opkg %{V_major}.%{V_minor}
  30. # package information
  31. Name: mysql40
  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: PLUS
  38. Group: Database
  39. License: GPL
  40. Version: %{V_opkg}
  41. Release: 20050115
  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: mysql40.patch
  53. # build information
  54. Prefix: %{l_prefix}
  55. BuildRoot: %{l_buildroot}
  56. BuildPreReq: OpenPKG, openpkg >= 20040130, perl, gcc, make
  57. PreReq: OpenPKG, openpkg >= 20040130, perl
  58. BuildPreReq: zlib, readline, ncurses
  59. PreReq: zlib, readline, ncurses
  60. AutoReq: no
  61. AutoReqProv: no
  62. Provides: mysql = %{version}-%{release}
  63. %description
  64. MySQL is a multi-user Relational Database Management System (RDBMS),
  65. which is controlled through Structured Query Language (SQL) operating in
  66. full multi-threading mode. The main goals of MySQL are speed, robustness
  67. and ease of use. MySQL was originally developed because of the need for
  68. a SQL server that could handle very big databases with magnitude higher
  69. speed than what any database vendor could offer.
  70. NOTICE: This package contains the old and previous MySQL 4.0
  71. version. Please use the "mysql" package, containing the current
  72. stable MySQL 4.1 version.
  73. %track
  74. prog mysql40 = {
  75. version = %{V_mysql}
  76. url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
  77. regex = mysql-(4\.0\.\d+)\.tar\.gz
  78. }
  79. %prep
  80. %setup -q -n mysql-%{V_mysql}
  81. %patch -p0
  82. %build
  83. # patch file search path
  84. %{l_shtool} subst %{l_value -s -a} \
  85. mysys/default.c
  86. # determine additional configure options
  87. case "%{l_platform -t}" in
  88. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  89. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  90. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  91. esac
  92. # configure source tree
  93. CC="%{l_cc}" \
  94. CXX="%{l_cxx}" \
  95. CFLAGS="%{l_cflags -O}" \
  96. CXXFLAGS="%{l_cxxflags -O}" \
  97. CPPFLAGS="%{l_cppflags ncurses}" \
  98. LDFLAGS="-L`pwd`/bdb/build_unix -L`pwd`/libmysql %{l_ldflags}" \
  99. ./configure \
  100. --prefix=%{l_prefix} \
  101. --sysconfdir=%{l_prefix}/etc/mysql \
  102. --localstatedir=%{l_prefix}/var/mysql \
  103. --libexecdir=%{l_prefix}/libexec/mysql \
  104. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  105. --with-mysqld-user=%{l_musr} \
  106. --enable-thread-safe-client \
  107. --with-comment="%{l_openpkg_release}" \
  108. %if "%{with_server}" != "yes"
  109. --without-server \
  110. %endif
  111. %if "%{with_bdb}" == "yes"
  112. --with-berkeley-db \
  113. %endif
  114. %if "%{with_innodb}" == "no"
  115. --without-innodb \
  116. %endif
  117. %if "%{with_ssl}" == "yes"
  118. --with-openssl \
  119. --with-openssl-includes=%{l_prefix}/include \
  120. --with-openssl-libs=%{l_prefix}/lib \
  121. %endif
  122. --without-readline \
  123. --without-libedit \
  124. --with-vio \
  125. --with-named-z-libs=no \
  126. --with-low-memory \
  127. --disable-shared \
  128. $opt
  129. # build source tree
  130. %{l_make} %{l_mflags}
  131. %install
  132. rm -rf $RPM_BUILD_ROOT
  133. # patch init script
  134. %{l_shtool} subst %{l_value -s -a} \
  135. scripts/mysql_install_db.sh
  136. # perform standard installation procedure
  137. %{l_make} %{l_mflags} install \
  138. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  139. DESTDIR=$RPM_BUILD_ROOT
  140. # move utility 'replace', msql2mysql is patched for new path
  141. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  142. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  143. # strip installation area
  144. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  145. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  146. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  147. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  148. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  149. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  150. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  151. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  152. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  153. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  154. # determine default parameters
  155. %if "%{with_bdb}" == "yes"
  156. l_mysql_bdb_cache_size=8M
  157. l_mysql_bdb_log_buffer_size=32k
  158. l_mysql_bdb_max_lock=10000
  159. %else
  160. l_mysql_bdb_cache_size=0
  161. l_mysql_bdb_log_buffer_size=0
  162. l_mysql_bdb_max_lock=0
  163. %endif
  164. %if "%{with_bdb}" == "yes" || "%{with_innodb}" == "yes"
  165. l_mysqld=mysqld
  166. %else
  167. l_mysqld=mysqld-max
  168. %endif
  169. # install global configuration
  170. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  171. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  172. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  173. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  174. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  175. %{SOURCE my.cnf} \
  176. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  177. %{l_shtool} install -c -m 600 \
  178. %{SOURCE my.pwd} \
  179. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  180. # install run-command script
  181. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  182. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  183. -e "s;@l_mysqld@;${l_mysqld};g" \
  184. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  185. # make sure the database directory exists
  186. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  187. # directory for temporary tables
  188. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  189. # optional client-only installation
  190. %if "%{with_server}" != "yes"
  191. rm -rf $RPM_BUILD_ROOT%{l_prefix}/bin/*
  192. %endif
  193. # determine the package files
  194. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  195. %if "%{with_server}" == "yes"
  196. %{l_files_std} \
  197. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  198. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  199. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  200. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  201. %else
  202. %{l_files_std}
  203. %endif
  204. %files -f files
  205. %clean
  206. rm -rf $RPM_BUILD_ROOT
  207. %pre
  208. %if "%{with_server}" == "yes"
  209. # before upgrade, save status and stop service
  210. [ $1 -eq 2 ] || exit 0
  211. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  212. %{l_rc} mysql stop 2>/dev/null
  213. %endif
  214. exit 0
  215. %post
  216. %if "%{with_server}" == "yes"
  217. if [ $1 -eq 1 ]; then
  218. # after install, create initial database
  219. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  220. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  221. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  222. ( echo "An initial MySQL DB was created. The owner of the database"
  223. echo "is the DB user 'root'. Its initial password is empty."
  224. echo "After starting MySQL with..."
  225. echo ""
  226. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  227. echo ""
  228. echo "...you should change the password as soon as possible with:"
  229. echo ""
  230. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  231. echo " -u root password '<new-password>'"
  232. echo ""
  233. echo "Additionally, because the MySQL package includes automated"
  234. echo "maintenance procedures that require administrator access to"
  235. echo "the database, you must maintain a (plain text) copy of the"
  236. echo "administrator account name and password:"
  237. echo ""
  238. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  239. ) | %{l_rpmtool} msg -b -t notice
  240. fi
  241. if [ $1 -eq 2 ]; then
  242. # after upgrade, restore status
  243. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  244. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  245. fi
  246. %endif
  247. exit 0
  248. %preun
  249. %if "%{with_server}" == "yes"
  250. # before erase, stop service and remove log files
  251. [ $1 -eq 0 ] || exit 0
  252. %{l_rc} mysql stop 2>/dev/null
  253. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  254. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  255. %endif
  256. exit 0