mysql51.spec 11 KB

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