mysql6.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. ##
  2. ## mysql6.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 6.0
  26. %define V_minor 2
  27. %define V_mysql %{V_major}.%{V_minor}-alpha
  28. %define V_opkg %{V_major}.%{V_minor}
  29. # package information
  30. Name: mysql6
  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: 20071005
  41. # package options
  42. %option with_server yes
  43. %option with_falcon yes
  44. %option with_innobase yes
  45. %option with_archive no
  46. %option with_blackhole no
  47. %option with_federated no
  48. %option with_ndbcluster no
  49. %option with_partition no
  50. %option with_ssl no
  51. %option with_embedded no
  52. %option with_charset utf8
  53. %option with_collation utf8_unicode_ci
  54. # fixing implicit inter-plugin dependencies and correlations
  55. %if "%{with_ndbcluster}" == "yes"
  56. %undefine with_partition
  57. %define with_partition yes
  58. %endif
  59. # list of sources
  60. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  61. Source1: my.cnf
  62. Source2: my.pwd
  63. Source3: rc.mysql
  64. Patch0: mysql6.patch
  65. # build information
  66. Prefix: %{l_prefix}
  67. BuildRoot: %{l_buildroot}
  68. BuildPreReq: OpenPKG, openpkg >= 20060823, perl, make, gcc, gcc::with_cxx = yes
  69. PreReq: OpenPKG, openpkg >= 20060823, perl
  70. BuildPreReq: zlib, readline, ncurses
  71. PreReq: zlib, readline, ncurses
  72. %if "%{with_ssl}" == "yes"
  73. BuildPreReq: openssl
  74. PreReq: openssl
  75. %endif
  76. AutoReq: no
  77. AutoReqProv: no
  78. Provides: mysql = %{version}-%{release}
  79. %description
  80. MySQL is a multi-user Relational Database Management System (RDBMS),
  81. which is controlled through Structured Query Language (SQL)
  82. operating in full multi-threading mode. The main goals of MySQL are
  83. speed, robustness and ease of use. MySQL was originally developed
  84. because of the need for a SQL server that could handle very big
  85. databases with magnitude higher speed than what any database vendor
  86. could offer.
  87. %track
  88. prog mysql6 = {
  89. version = %{V_mysql}
  90. url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
  91. regex = mysql-(__VER__)\.tar\.gz
  92. }
  93. %prep
  94. %setup -q -n mysql-%{V_mysql}
  95. %patch -p0
  96. %build
  97. # patch file search path
  98. %{l_shtool} subst %{l_value -s -a} \
  99. mysys/default.c
  100. # determine additional configure options
  101. case "%{l_platform -t}" in
  102. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  103. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  104. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  105. esac
  106. # configure source tree
  107. CC="%{l_cc}" \
  108. CXX="%{l_cxx}" \
  109. CFLAGS="%{l_cflags -O}" \
  110. CXXFLAGS="%{l_cxxflags -O}" \
  111. CPPFLAGS="%{l_cppflags ncurses}" \
  112. LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \
  113. LIBS="-lz" \
  114. ./configure \
  115. --prefix=%{l_prefix} \
  116. --sysconfdir=%{l_prefix}/etc/mysql \
  117. --localstatedir=%{l_prefix}/var/mysql \
  118. --libexecdir=%{l_prefix}/libexec/mysql \
  119. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  120. --with-mysqld-user=%{l_musr} \
  121. --enable-thread-safe-client \
  122. --with-comment="%{l_openpkg_release}" \
  123. %if "%{with_server}" != "yes"
  124. --without-server \
  125. %else
  126. --with-server \
  127. --with-plugin-csv \
  128. --with-plugin-heap \
  129. --with-plugin-myisam \
  130. --with-plugin-myisammrg \
  131. %if "%{with_falcon}" == "yes"
  132. --with-plugin-falcon \
  133. %else
  134. --without-plugin-falcon \
  135. %endif
  136. %if "%{with_innobase}" == "yes"
  137. --with-plugin-innobase \
  138. %else
  139. --without-plugin-innobase \
  140. %endif
  141. %if "%{with_archive}" == "yes"
  142. --with-plugin-archive \
  143. %else
  144. --without-plugin-archive \
  145. %endif
  146. %if "%{with_blackhole}" == "yes"
  147. --with-plugin-blackhole \
  148. %else
  149. --without-plugin-blackhole \
  150. %endif
  151. %if "%{with_federated}" == "yes"
  152. --with-plugin-federated \
  153. %else
  154. --without-plugin-federated \
  155. %endif
  156. %if "%{with_ndbcluster}" == "yes"
  157. --with-plugin-ndbcluster \
  158. %else
  159. --without-plugin-ndbcluster \
  160. %endif
  161. %if "%{with_partition}" == "yes"
  162. --with-plugin-partition \
  163. %else
  164. --without-plugin-partition \
  165. %endif
  166. %endif
  167. --with-zlib-dir=%{l_prefix} \
  168. %if "%{with_ssl}" == "yes"
  169. --with-ssl=%{l_prefix} \
  170. %endif
  171. %if "%{with_embedded}" == "yes"
  172. --with-embedded-server \
  173. %endif
  174. --with-charset=%{with_charset} \
  175. --with-collation=%{with_collation} \
  176. --without-readline \
  177. --without-libedit \
  178. --with-big-tables \
  179. --with-low-memory \
  180. --disable-shared \
  181. $opt
  182. # build source tree
  183. %{l_make} %{l_mflags}
  184. %install
  185. rm -rf $RPM_BUILD_ROOT
  186. # patch init script
  187. %{l_shtool} subst %{l_value -s -a} \
  188. scripts/mysql_install_db.sh
  189. # perform standard installation procedure
  190. %{l_make} %{l_mflags} install \
  191. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  192. DESTDIR=$RPM_BUILD_ROOT
  193. # move utility 'replace', msql2mysql is patched for new path
  194. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  195. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  196. # strip installation area
  197. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  198. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  199. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  200. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  201. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  202. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  203. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  204. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  205. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  206. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  207. # install global configuration
  208. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  209. sed <%{SOURCE my.cnf} >my.cnf \
  210. %if "%{with_innobase}" == "yes"
  211. -e '/<\/\{0,1\}with_innobase>/d'
  212. %else
  213. -e '/<with_innobase>/,/<\/with_innobase>/d'
  214. %endif
  215. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  216. my.cnf \
  217. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  218. %{l_shtool} install -c -m 600 \
  219. %{SOURCE my.pwd} \
  220. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  221. # install run-command script
  222. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  223. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  224. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  225. # make sure the database directory exists
  226. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  227. # directory for temporary tables
  228. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  229. # optional client-only installation
  230. %if "%{with_server}" != "yes"
  231. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  232. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  233. for bin in *; do
  234. case "$bin" in
  235. mysql | mysql_config ) ;;
  236. * ) rm -f $bin ;;
  237. esac
  238. done
  239. ) || exit $?
  240. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  241. for man in *; do
  242. case "$man" in
  243. mysql.1 | mysql_config.1 ) ;;
  244. * ) rm -f $man ;;
  245. esac
  246. done
  247. ) || exit $?
  248. %endif
  249. # determine the package files
  250. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  251. %if "%{with_server}" == "yes"
  252. %{l_files_std} \
  253. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  254. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  255. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  256. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  257. %else
  258. %{l_files_std}
  259. %endif
  260. %files -f files
  261. %clean
  262. rm -rf $RPM_BUILD_ROOT
  263. %pre
  264. %if "%{with_server}" == "yes"
  265. # before upgrade, save status and stop service
  266. [ $1 -eq 2 ] || exit 0
  267. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  268. %{l_rc} mysql stop 2>/dev/null
  269. %endif
  270. exit 0
  271. %post
  272. %if "%{with_server}" == "yes"
  273. if [ $1 -eq 1 ]; then
  274. # after install, create initial database
  275. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  276. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  277. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  278. ( echo "An initial MySQL DB was created. The owner of the database"
  279. echo "is the DB user 'root'. Its initial password is empty."
  280. echo "After starting MySQL with..."
  281. echo ""
  282. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  283. echo ""
  284. echo "...you should change the password as soon as possible with:"
  285. echo ""
  286. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  287. echo " -u root password '<new-password>'"
  288. echo ""
  289. echo "Additionally, because the MySQL package includes automated"
  290. echo "maintenance procedures that require administrator access to"
  291. echo "the database, you must maintain a (plain text) copy of the"
  292. echo "administrator account name and password:"
  293. echo ""
  294. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  295. ) | %{l_rpmtool} msg -b -t notice
  296. fi
  297. if [ $1 -eq 2 ]; then
  298. # after upgrade, restore status
  299. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  300. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  301. fi
  302. %endif
  303. exit 0
  304. %preun
  305. %if "%{with_server}" == "yes"
  306. # before erase, stop service and remove log files
  307. [ $1 -eq 0 ] || exit 0
  308. %{l_rc} mysql stop 2>/dev/null
  309. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  310. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  311. %endif
  312. exit 0