mysql51.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. ##
  2. ## mysql51.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_major 5.1
  26. %define V_minor 22
  27. %define V_mysql %{V_major}.%{V_minor}-rc
  28. %define V_opkg %{V_major}.%{V_minor}
  29. # package information
  30. Name: mysql51
  31. Summary: Fast Relational Database Management System
  32. URL: http://www.mysql.com/products/mysql/
  33. Vendor: MySQL AB
  34. Packager: OpenPKG Foundation e.V.
  35. Distribution: OpenPKG Community
  36. Class: EVAL
  37. Group: Database
  38. License: GPL
  39. Version: %{V_opkg}
  40. Release: 20071001
  41. # package options
  42. %option with_server yes
  43. %option with_innobase yes
  44. %option with_archive no
  45. %option with_blackhole no
  46. %option with_federated no
  47. %option with_ndbcluster no
  48. %option with_partition no
  49. %option with_ssl no
  50. %option with_embedded no
  51. %option with_charset utf8
  52. %option with_collation utf8_unicode_ci
  53. # fixing implicit inter-plugin dependencies and correlations
  54. %if "%{with_ndbcluster}" == "yes"
  55. %undefine with_partition
  56. %define with_partition yes
  57. %endif
  58. # list of sources
  59. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  60. Source1: my.cnf
  61. Source2: my.pwd
  62. Source3: rc.mysql
  63. Patch0: mysql51.patch
  64. # build information
  65. Prefix: %{l_prefix}
  66. BuildRoot: %{l_buildroot}
  67. BuildPreReq: OpenPKG, openpkg >= 20060823, perl, make, gcc, gcc::with_cxx = yes
  68. PreReq: OpenPKG, openpkg >= 20060823, perl
  69. BuildPreReq: zlib, readline, ncurses
  70. PreReq: zlib, readline, ncurses
  71. %if "%{with_ssl}" == "yes"
  72. BuildPreReq: openssl
  73. PreReq: openssl
  74. %endif
  75. AutoReq: no
  76. AutoReqProv: no
  77. Provides: mysql = %{version}-%{release}
  78. %description
  79. MySQL is a multi-user Relational Database Management System (RDBMS),
  80. which is controlled through Structured Query Language (SQL)
  81. operating in full multi-threading mode. The main goals of MySQL are
  82. speed, robustness and ease of use. MySQL was originally developed
  83. because of the need for a SQL server that could handle very big
  84. databases with magnitude higher speed than what any database vendor
  85. could offer.
  86. %track
  87. prog mysql51 = {
  88. version = %{V_mysql}
  89. url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
  90. regex = mysql-(__VER__)\.tar\.gz
  91. }
  92. %prep
  93. %setup -q -n mysql-%{V_mysql}
  94. %patch -p0
  95. %build
  96. # patch file search path
  97. %{l_shtool} subst %{l_value -s -a} \
  98. mysys/default.c
  99. # determine additional configure options
  100. case "%{l_platform -t}" in
  101. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  102. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  103. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  104. esac
  105. # configure source tree
  106. CC="%{l_cc}" \
  107. CXX="%{l_cxx}" \
  108. CFLAGS="%{l_cflags -O}" \
  109. CXXFLAGS="%{l_cxxflags -O}" \
  110. CPPFLAGS="%{l_cppflags ncurses}" \
  111. LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \
  112. LIBS="-lz" \
  113. ./configure \
  114. --prefix=%{l_prefix} \
  115. --sysconfdir=%{l_prefix}/etc/mysql \
  116. --localstatedir=%{l_prefix}/var/mysql \
  117. --libexecdir=%{l_prefix}/libexec/mysql \
  118. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  119. --with-mysqld-user=%{l_musr} \
  120. --enable-thread-safe-client \
  121. --with-comment="%{l_openpkg_release}" \
  122. %if "%{with_server}" != "yes"
  123. --without-server \
  124. %else
  125. --with-server \
  126. --with-plugin-csv \
  127. --with-plugin-heap \
  128. --with-plugin-myisam \
  129. --with-plugin-myisammrg \
  130. %if "%{with_innobase}" == "yes"
  131. --with-plugin-innobase \
  132. %else
  133. --without-plugin-innobase \
  134. %endif
  135. %if "%{with_archive}" == "yes"
  136. --with-plugin-archive \
  137. %else
  138. --without-plugin-archive \
  139. %endif
  140. %if "%{with_blackhole}" == "yes"
  141. --with-plugin-blackhole \
  142. %else
  143. --without-plugin-blackhole \
  144. %endif
  145. %if "%{with_federated}" == "yes"
  146. --with-plugin-federated \
  147. %else
  148. --without-plugin-federated \
  149. %endif
  150. %if "%{with_ndbcluster}" == "yes"
  151. --with-plugin-ndbcluster \
  152. %else
  153. --without-plugin-ndbcluster \
  154. %endif
  155. %if "%{with_partition}" == "yes"
  156. --with-plugin-partition \
  157. %else
  158. --without-plugin-partition \
  159. %endif
  160. %endif
  161. --with-zlib-dir=%{l_prefix} \
  162. %if "%{with_ssl}" == "yes"
  163. --with-ssl=%{l_prefix} \
  164. %endif
  165. %if "%{with_embedded}" == "yes"
  166. --with-embedded-server \
  167. %endif
  168. --with-charset=%{with_charset} \
  169. --with-collation=%{with_collation} \
  170. --without-readline \
  171. --without-libedit \
  172. --with-big-tables \
  173. --with-low-memory \
  174. --disable-shared \
  175. $opt
  176. # build source tree
  177. %{l_make} %{l_mflags}
  178. %install
  179. rm -rf $RPM_BUILD_ROOT
  180. # patch init script
  181. %{l_shtool} subst %{l_value -s -a} \
  182. scripts/mysql_install_db.sh
  183. # perform standard installation procedure
  184. %{l_make} %{l_mflags} install \
  185. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  186. DESTDIR=$RPM_BUILD_ROOT
  187. # move utility 'replace', msql2mysql is patched for new path
  188. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  189. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  190. # strip installation area
  191. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  192. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  193. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  194. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  195. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  196. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  197. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  198. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  199. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  200. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  201. # install global configuration
  202. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  203. %{l_shtool} install%{l_nil} -c -m 644 %{l_value -s -a} \
  204. %if "%{with_innobase}" == "yes"
  205. -e '/<\/\{0,1\}with_innobase>/d' \
  206. %else
  207. -e '/<with_innobase>/,/<\/with_innobase>/d' \
  208. %endif
  209. %{SOURCE my.cnf} \
  210. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  211. %{l_shtool} install -c -m 600 \
  212. %{SOURCE my.pwd} \
  213. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  214. # install run-command script
  215. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  216. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  217. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  218. # make sure the database directory exists
  219. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  220. # directory for temporary tables
  221. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  222. # optional client-only installation
  223. %if "%{with_server}" != "yes"
  224. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  225. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  226. for bin in *; do
  227. case "$bin" in
  228. mysql | mysql_config ) ;;
  229. * ) rm -f $bin ;;
  230. esac
  231. done
  232. ) || exit $?
  233. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  234. for man in *; do
  235. case "$man" in
  236. mysql.1 | mysql_config.1 ) ;;
  237. * ) rm -f $man ;;
  238. esac
  239. done
  240. ) || exit $?
  241. %endif
  242. # determine the package files
  243. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  244. %if "%{with_server}" == "yes"
  245. %{l_files_std} \
  246. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  247. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  248. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  249. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  250. %else
  251. %{l_files_std}
  252. %endif
  253. %files -f files
  254. %clean
  255. rm -rf $RPM_BUILD_ROOT
  256. %pre
  257. %if "%{with_server}" == "yes"
  258. # before upgrade, save status and stop service
  259. [ $1 -eq 2 ] || exit 0
  260. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  261. %{l_rc} mysql stop 2>/dev/null
  262. %endif
  263. exit 0
  264. %post
  265. %if "%{with_server}" == "yes"
  266. if [ $1 -eq 1 ]; then
  267. # after install, create initial database
  268. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  269. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  270. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  271. ( echo "An initial MySQL DB was created. The owner of the database"
  272. echo "is the DB user 'root'. Its initial password is empty."
  273. echo "After starting MySQL with..."
  274. echo ""
  275. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  276. echo ""
  277. echo "...you should change the password as soon as possible with:"
  278. echo ""
  279. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  280. echo " -u root password '<new-password>'"
  281. echo ""
  282. echo "Additionally, because the MySQL package includes automated"
  283. echo "maintenance procedures that require administrator access to"
  284. echo "the database, you must maintain a (plain text) copy of the"
  285. echo "administrator account name and password:"
  286. echo ""
  287. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  288. ) | %{l_rpmtool} msg -b -t notice
  289. fi
  290. if [ $1 -eq 2 ]; then
  291. # after upgrade, restore status
  292. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  293. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  294. fi
  295. %endif
  296. exit 0
  297. %preun
  298. %if "%{with_server}" == "yes"
  299. # before erase, stop service and remove log files
  300. [ $1 -eq 0 ] || exit 0
  301. %{l_rc} mysql stop 2>/dev/null
  302. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  303. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  304. %endif
  305. exit 0