mysql51.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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-heap \
  125. --with-plugin-myisam \
  126. --with-plugin-myisammrg \
  127. %if "%{with_archive}" == "yes"
  128. --with-plugin-archive \
  129. %else
  130. --without-plugin-archive \
  131. %endif
  132. %if "%{with_blackhole}" == "yes"
  133. --with-plugin-blackhole \
  134. %else
  135. --without-plugin-blackhole \
  136. %endif
  137. %if "%{with_federated}" == "yes"
  138. --with-plugin-federated \
  139. %else
  140. --without-plugin-federated \
  141. %endif
  142. %if "%{with_innobase}" == "yes"
  143. --with-plugin-innobase \
  144. %else
  145. --without-plugin-innobase \
  146. %endif
  147. %if "%{with_ndbcluster}" == "yes"
  148. --with-plugin-ndbcluster \
  149. %else
  150. --without-plugin-ndbcluster \
  151. %endif
  152. %if "%{with_partition}" == "yes"
  153. --with-plugin-partition \
  154. %else
  155. --without-plugin-partition \
  156. %endif
  157. %if "%{with_csv}" == "yes"
  158. --with-plugin-csv \
  159. %else
  160. --without-plugin-csv \
  161. %endif
  162. %endif
  163. --with-zlib-dir=%{l_prefix} \
  164. %if "%{with_ssl}" == "yes"
  165. --with-ssl=%{l_prefix} \
  166. %endif
  167. %if "%{with_embedded}" == "yes"
  168. --with-embedded-server \
  169. %endif
  170. --without-readline \
  171. --without-libedit \
  172. --with-big-tables \
  173. --with-low-memory \
  174. --disable-shared \
  175. $opt
  176. # build source tree
  177. %{l_make} %{l_mflags}
  178. %install
  179. rm -rf $RPM_BUILD_ROOT
  180. # patch init script
  181. %{l_shtool} subst %{l_value -s -a} \
  182. scripts/mysql_install_db.sh
  183. # perform standard installation procedure
  184. %{l_make} %{l_mflags} install \
  185. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  186. DESTDIR=$RPM_BUILD_ROOT
  187. # move utility 'replace', msql2mysql is patched for new path
  188. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  189. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  190. # strip installation area
  191. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  192. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  193. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  194. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  195. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  196. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  197. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  198. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  199. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  200. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  201. # install global configuration
  202. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  203. %{l_shtool} install%{l_nil} -c -m 644 %{l_value -s -a} \
  204. %if "%{with_innobase}" == "yes"
  205. -e '/<\/\{0,1\}with_innobase>/d' \
  206. %else
  207. -e '/<with_innobase>/,/<\/with_innobase>/d' \
  208. %endif
  209. %{SOURCE my.cnf} \
  210. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  211. %{l_shtool} install -c -m 600 \
  212. %{SOURCE my.pwd} \
  213. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  214. # install run-command script
  215. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  216. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  217. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  218. # make sure the database directory exists
  219. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  220. # directory for temporary tables
  221. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  222. # optional client-only installation
  223. %if "%{with_server}" != "yes"
  224. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  225. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  226. for bin in *; do
  227. case "$bin" in
  228. mysql | mysql_config ) ;;
  229. * ) rm -f $bin ;;
  230. esac
  231. done
  232. ) || exit $?
  233. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  234. for man in *; do
  235. case "$man" in
  236. mysql.1 | mysql_config.1 ) ;;
  237. * ) rm -f $man ;;
  238. esac
  239. done
  240. ) || exit $?
  241. %endif
  242. # determine the package files
  243. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  244. %if "%{with_server}" == "yes"
  245. %{l_files_std} \
  246. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  247. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  248. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  249. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  250. %else
  251. %{l_files_std}
  252. %endif
  253. %files -f files
  254. %clean
  255. rm -rf $RPM_BUILD_ROOT
  256. %pre
  257. %if "%{with_server}" == "yes"
  258. # before upgrade, save status and stop service
  259. [ $1 -eq 2 ] || exit 0
  260. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  261. %{l_rc} mysql stop 2>/dev/null
  262. %endif
  263. exit 0
  264. %post
  265. %if "%{with_server}" == "yes"
  266. if [ $1 -eq 1 ]; then
  267. # after install, create initial database
  268. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  269. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  270. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  271. ( echo "An initial MySQL DB was created. The owner of the database"
  272. echo "is the DB user 'root'. Its initial password is empty."
  273. echo "After starting MySQL with..."
  274. echo ""
  275. echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
  276. echo ""
  277. echo "...you should change the password as soon as possible with:"
  278. echo ""
  279. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  280. echo " -u root password '<new-password>'"
  281. echo ""
  282. echo "Additionally, because the MySQL package includes automated"
  283. echo "maintenance procedures that require administrator access to"
  284. echo "the database, you must maintain a (plain text) copy of the"
  285. echo "administrator account name and password:"
  286. echo ""
  287. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  288. ) | %{l_rpmtool} msg -b -t notice
  289. fi
  290. if [ $1 -eq 2 ]; then
  291. # after upgrade, restore status
  292. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  293. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  294. fi
  295. %endif
  296. exit 0
  297. %preun
  298. %if "%{with_server}" == "yes"
  299. # before erase, stop service and remove log files
  300. [ $1 -eq 0 ] || exit 0
  301. %{l_rc} mysql stop 2>/dev/null
  302. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  303. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  304. %endif
  305. exit 0