mysql.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. ##
  2. ## mysql.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 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.0
  25. %define V_minor 51a
  26. %define V_mysql %{V_major}.%{V_minor}
  27. %define V_opkg %{V_major}.%{V_minor}
  28. %define V_jdbc 5.0.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: 20080129
  41. # package options
  42. %option with_server yes
  43. %option with_bdb 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_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. # list of sources
  55. Source0: http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  56. Source1: http://ftp.gwdg.de/pub/misc/mysql/Downloads/Connector-J/mysql-connector-java-%{V_jdbc}.tar.gz
  57. Source2: my.cnf
  58. Source3: my.pwd
  59. Source4: rc.mysql
  60. Patch0: mysql.patch
  61. # build information
  62. Prefix: %{l_prefix}
  63. BuildRoot: %{l_buildroot}
  64. BuildPreReq: OpenPKG, openpkg >= 20060823, perl, make, gcc, gcc::with_cxx = yes
  65. PreReq: OpenPKG, openpkg >= 20060823, perl
  66. BuildPreReq: zlib, readline, ncurses
  67. PreReq: zlib, readline, ncurses
  68. %if "%{with_ssl}" == "yes"
  69. BuildPreReq: openssl
  70. PreReq: openssl
  71. %endif
  72. %if "%{with_jdbc}" == "yes"
  73. BuildPreReq: java, JAVA-JDK, ant
  74. PreReq: java, JAVA-JDK, ant
  75. %endif
  76. AutoReq: no
  77. AutoReqProv: no
  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 mysql = {
  88. version = %{V_mysql}
  89. url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
  90. regex = mysql-(__VER__)\.tar\.gz
  91. }
  92. prog mysql:connector-jdbc = {
  93. version = %{V_jdbc}
  94. url = http://dev.mysql.com/downloads/connector/j/%{V_major}.html
  95. regex = mysql-connector-java-(__VER__)\.tar\.gz
  96. }
  97. %prep
  98. %setup -q
  99. %if "%{with_jdbc}" == "yes"
  100. %setup -q -T -D -a 1
  101. %endif
  102. %patch -p0
  103. %build
  104. # patch file search path
  105. %{l_shtool} subst %{l_value -s -a} \
  106. mysys/default.c
  107. # determine additional configure options
  108. case "%{l_platform -t}" in
  109. *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  110. *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  111. *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
  112. esac
  113. # configure source tree
  114. CC="%{l_cc}" \
  115. CXX="%{l_cxx}" \
  116. CFLAGS="%{l_cflags -O}" \
  117. CXXFLAGS="%{l_cxxflags -O}" \
  118. CPPFLAGS="%{l_cppflags ncurses}" \
  119. LDFLAGS="-L`pwd`/bdb/build_unix -L`pwd`/libmysql %{l_ldflags}" \
  120. ./configure \
  121. --prefix=%{l_prefix} \
  122. --sysconfdir=%{l_prefix}/etc/mysql \
  123. --localstatedir=%{l_prefix}/var/mysql \
  124. --libexecdir=%{l_prefix}/libexec/mysql \
  125. --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
  126. --with-mysqld-user=%{l_musr} \
  127. --enable-thread-safe-client \
  128. --with-comment="%{l_openpkg_release}" \
  129. %if "%{with_server}" != "yes"
  130. --without-server \
  131. %else
  132. --with-server \
  133. --with-csv-storage-engine \
  134. %if "%{with_bdb}" == "yes"
  135. --with-berkeley-db \
  136. %else
  137. --without-berkeley-db \
  138. %endif
  139. %if "%{with_innobase}" == "yes"
  140. --with-innodb \
  141. %else
  142. --without-innodb \
  143. %endif
  144. %if "%{with_archive}" == "yes"
  145. --with-archive-storage-engine \
  146. %else
  147. --without-archive-storage-engine \
  148. %endif
  149. %if "%{with_blackhole}" == "yes"
  150. --with-blackhole-storage-engine \
  151. %else
  152. --without-blackhole-storage-engine \
  153. %endif
  154. %if "%{with_federated}" == "yes"
  155. --with-federated-storage-engine \
  156. %else
  157. --without-federated-storage-engine \
  158. %endif
  159. %if "%{with_ndbcluster}" == "yes"
  160. --with-ndbcluster \
  161. --with-ndb-shm \
  162. %else
  163. --without-ndbcluster \
  164. %endif
  165. %endif
  166. %if "%{with_ssl}" == "yes"
  167. --with-openssl \
  168. --with-openssl-includes=%{l_prefix}/include \
  169. --with-openssl-libs=%{l_prefix}/lib \
  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. # build JDBC driver
  185. %if "%{with_jdbc}" == "yes"
  186. ( cd mysql-connector-java-%{V_jdbc}
  187. export JAVA_PLATFORM="sun-jdk"
  188. eval `%{l_prefix}/bin/java-toolkit -e`
  189. %{l_prefix}/bin/ant
  190. ) || exit $?
  191. %endif
  192. %install
  193. rm -rf $RPM_BUILD_ROOT
  194. # patch init script
  195. %{l_shtool} subst %{l_value -s -a} \
  196. scripts/mysql_install_db.sh
  197. # perform standard installation procedure
  198. %{l_make} %{l_mflags} install \
  199. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  200. DESTDIR=$RPM_BUILD_ROOT
  201. # cleanup mysql_config script
  202. %{l_shtool} subst \
  203. -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \
  204. $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config
  205. # move utility 'replace', msql2mysql is patched for new path
  206. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  207. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  208. # strip installation area
  209. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  210. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  211. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  212. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  213. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  214. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  215. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  216. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  217. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  218. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  219. # install global configuration
  220. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  221. sed <%{SOURCE my.cnf} >my.cnf \
  222. %if "%{with_bdb}" == "yes"
  223. -e '/<\/\{0,1\}with_bdb>/d' \
  224. %else
  225. -e '/<with_bdb>/,/<\/with_bdb>/d' \
  226. %endif
  227. %if "%{with_innobase}" == "yes"
  228. -e '/<\/\{0,1\}with_innobase>/d'
  229. %else
  230. -e '/<with_innobase>/,/<\/with_innobase>/d'
  231. %endif
  232. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  233. my.cnf \
  234. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  235. %{l_shtool} install -c -m 600 \
  236. %{SOURCE my.pwd} \
  237. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  238. # install run-command script
  239. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  240. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  241. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  242. # make sure the database directory exists
  243. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  244. # directory for temporary tables
  245. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  246. # optional client-only installation
  247. %if "%{with_server}" != "yes"
  248. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  249. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  250. for bin in *; do
  251. case "$bin" in
  252. mysql | mysql_config ) ;;
  253. * ) rm -f $bin ;;
  254. esac
  255. done
  256. ) || exit $?
  257. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  258. for man in *; do
  259. case "$man" in
  260. mysql.1 | mysql_config.1 ) ;;
  261. * ) rm -f $man ;;
  262. esac
  263. done
  264. ) || exit $?
  265. %endif
  266. # install JDBC driver
  267. %if "%{with_jdbc}" == "yes"
  268. ( cd mysql-connector-java-%{V_jdbc}
  269. %{l_shtool} install -c -m 644 \
  270. build/mysql-connector-java-%{V_jdbc}/mysql-connector-java-%{V_jdbc}-bin.jar \
  271. $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar
  272. ) || exit $?
  273. %endif
  274. # determine the package files
  275. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  276. %if "%{with_server}" == "yes"
  277. %{l_files_std} \
  278. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  279. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  280. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  281. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  282. %else
  283. %{l_files_std}
  284. %endif
  285. %files -f files
  286. %clean
  287. rm -rf $RPM_BUILD_ROOT
  288. %pre
  289. %if "%{with_server}" == "yes"
  290. # before upgrade, save status and stop service
  291. [ $1 -eq 2 ] || exit 0
  292. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  293. %{l_rc} mysql stop 2>/dev/null
  294. %endif
  295. exit 0
  296. %post
  297. %if "%{with_server}" == "yes"
  298. if [ $1 -eq 1 ]; then
  299. # after install, create initial database
  300. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  301. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  302. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  303. ( echo "An initial MySQL DB was created. The owner of the database"
  304. echo "is the DB user 'root'. Its initial password is empty."
  305. echo "After starting MySQL with..."
  306. echo ""
  307. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  308. echo ""
  309. echo "...you should change the password as soon as possible with:"
  310. echo ""
  311. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  312. echo " -u root password '<new-password>'"
  313. echo ""
  314. echo "Additionally, because the MySQL package includes automated"
  315. echo "maintenance procedures that require administrator access to"
  316. echo "the database, you must maintain a (plain text) copy of the"
  317. echo "administrator account name and password:"
  318. echo ""
  319. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  320. ) | %{l_rpmtool} msg -b -t notice
  321. fi
  322. if [ $1 -eq 2 ]; then
  323. # after upgrade, restore status
  324. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  325. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  326. fi
  327. %endif
  328. exit 0
  329. %preun
  330. %if "%{with_server}" == "yes"
  331. # before erase, stop service and remove log files
  332. [ $1 -eq 0 ] || exit 0
  333. %{l_rc} mysql stop 2>/dev/null
  334. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  335. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  336. %endif
  337. exit 0