mysql.spec 12 KB

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