mysql.spec 10 KB

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