mysql.spec 12 KB

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