mysql.spec 11 KB

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