mysql.spec 10 KB

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