mysql5.spec 10 KB

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