mysql.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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.8
  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: 20090903
  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. # determine additional configure options
  113. case "%{l_platform -t}" in
  114. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  115. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  116. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  117. esac
  118. # configure source tree
  119. CC="%{l_cc}" \
  120. CXX="%{l_cxx}" \
  121. CFLAGS="%{l_cflags -O}" \
  122. CXXFLAGS="%{l_cxxflags -O}" \
  123. CPPFLAGS="%{l_cppflags ncurses}" \
  124. LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \
  125. LIBS="-lz" \
  126. ./configure \
  127. --prefix=%{l_prefix} \
  128. --mandir=%{l_prefix}/man \
  129. --infodir=%{l_prefix}/info \
  130. --sysconfdir=%{l_prefix}/etc/mysql \
  131. --localstatedir=%{l_prefix}/var/mysql \
  132. --libexecdir=%{l_prefix}/libexec/mysql \
  133. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  134. --with-mysqld-user=%{l_musr} \
  135. --enable-thread-safe-client \
  136. --with-comment="%{l_openpkg_release}" \
  137. %if "%{with_server}" != "yes"
  138. --without-server \
  139. %else
  140. --with-server \
  141. --with-plugin-csv \
  142. --with-plugin-heap \
  143. --with-plugin-myisam \
  144. --with-plugin-myisammrg \
  145. %if "%{with_innobase}" == "yes"
  146. --with-plugin-innobase \
  147. %else
  148. --without-plugin-innobase \
  149. %endif
  150. %if "%{with_archive}" == "yes"
  151. --with-plugin-archive \
  152. %else
  153. --without-plugin-archive \
  154. %endif
  155. %if "%{with_blackhole}" == "yes"
  156. --with-plugin-blackhole \
  157. %else
  158. --without-plugin-blackhole \
  159. %endif
  160. %if "%{with_federated}" == "yes"
  161. --with-plugin-federated \
  162. %else
  163. --without-plugin-federated \
  164. %endif
  165. %if "%{with_ndbcluster}" == "yes"
  166. --with-plugin-ndbcluster \
  167. %else
  168. --without-plugin-ndbcluster \
  169. %endif
  170. %if "%{with_partition}" == "yes"
  171. --with-plugin-partition \
  172. %else
  173. --without-plugin-partition \
  174. %endif
  175. %endif
  176. --with-zlib-dir=%{l_prefix} \
  177. %if "%{with_ssl}" == "yes"
  178. --with-ssl=%{l_prefix} \
  179. %endif
  180. %if "%{with_embedded}" == "yes"
  181. --with-embedded-server \
  182. %endif
  183. --with-charset=%{with_charset} \
  184. --with-collation=%{with_collation} \
  185. --without-readline \
  186. --without-libedit \
  187. --with-big-tables \
  188. --with-low-memory \
  189. --disable-shared \
  190. $opt
  191. # build source tree
  192. %{l_make} %{l_mflags}
  193. # build JDBC driver
  194. %if "%{with_jdbc}" == "yes"
  195. ( cd mysql-connector-java-%{V_jdbc}
  196. export JAVA_PLATFORM="sun-jdk"
  197. eval `%{l_prefix}/bin/java-toolkit -e`
  198. %{l_prefix}/bin/ant
  199. ) || exit $?
  200. %endif
  201. %install
  202. rm -rf $RPM_BUILD_ROOT
  203. # patch init script
  204. %{l_shtool} subst %{l_value -s -a} \
  205. scripts/mysql_install_db.sh
  206. # perform standard installation procedure
  207. %{l_make} %{l_mflags} install \
  208. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  209. DESTDIR=$RPM_BUILD_ROOT
  210. # cleanup mysql_config script
  211. %{l_shtool} subst \
  212. -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \
  213. $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config
  214. # move utility 'replace', msql2mysql is patched for new path
  215. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  216. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  217. # strip installation area
  218. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  219. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  220. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  221. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  222. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  223. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  224. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  225. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  226. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  227. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  228. # install global configuration
  229. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  230. sed <%{SOURCE my.cnf} >my.cnf \
  231. %if "%{with_innobase}" == "yes"
  232. -e '/<\/\{0,1\}with_innobase>/d'
  233. %else
  234. -e '/<with_innobase>/,/<\/with_innobase>/d'
  235. %endif
  236. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  237. my.cnf \
  238. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  239. %{l_shtool} install -c -m 600 \
  240. %{SOURCE my.pwd} \
  241. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  242. # install run-command script
  243. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  244. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  245. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  246. # make sure the database directory exists
  247. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  248. # directory for temporary tables
  249. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  250. # optional client-only installation
  251. %if "%{with_server}" != "yes"
  252. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  253. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  254. for bin in *; do
  255. case "$bin" in
  256. mysql | mysql_config ) ;;
  257. * ) rm -f $bin ;;
  258. esac
  259. done
  260. ) || exit $?
  261. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  262. for man in *; do
  263. case "$man" in
  264. mysql.1 | mysql_config.1 ) ;;
  265. * ) rm -f $man ;;
  266. esac
  267. done
  268. ) || exit $?
  269. %endif
  270. # install JDBC driver
  271. %if "%{with_jdbc}" == "yes"
  272. ( cd mysql-connector-java-%{V_jdbc}
  273. %{l_shtool} install -c -m 644 \
  274. build/mysql-connector-java-%{V_jdbc}/mysql-connector-java-%{V_jdbc}-bin.jar \
  275. $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar
  276. ) || exit $?
  277. %endif
  278. # determine the package files
  279. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  280. %if "%{with_server}" == "yes"
  281. %{l_files_std} \
  282. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  283. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  284. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  285. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  286. %else
  287. %{l_files_std}
  288. %endif
  289. %files -f files
  290. %clean
  291. rm -rf $RPM_BUILD_ROOT
  292. %pre
  293. %if "%{with_server}" == "yes"
  294. # before upgrade, save status and stop service
  295. [ $1 -eq 2 ] || exit 0
  296. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  297. %{l_rc} mysql stop 2>/dev/null
  298. %endif
  299. exit 0
  300. %post
  301. %if "%{with_server}" == "yes"
  302. if [ $1 -eq 1 ]; then
  303. # after install, create initial database
  304. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  305. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  306. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  307. ( echo "An initial MySQL DB was created. The owner of the database"
  308. echo "is the DB user 'root'. Its initial password is empty."
  309. echo "After starting MySQL with..."
  310. echo ""
  311. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  312. echo ""
  313. echo "...you should change the password as soon as possible with:"
  314. echo ""
  315. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  316. echo " -u root password '<new-password>'"
  317. echo ""
  318. echo "Additionally, because the MySQL package includes automated"
  319. echo "maintenance procedures that require administrator access to"
  320. echo "the database, you must maintain a (plain text) copy of the"
  321. echo "administrator account name and password:"
  322. echo ""
  323. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  324. ) | %{l_rpmtool} msg -b -t notice
  325. fi
  326. if [ $1 -eq 2 ]; then
  327. # after upgrade, restore status
  328. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  329. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  330. fi
  331. %endif
  332. exit 0
  333. %preun
  334. %if "%{with_server}" == "yes"
  335. # before erase, stop service and remove log files
  336. [ $1 -eq 0 ] || exit 0
  337. %{l_rc} mysql stop 2>/dev/null
  338. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  339. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  340. %endif
  341. exit 0