mysql.spec 11 KB

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