mysql.spec 11 KB

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