mysql4.spec 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. ##
  2. ## mysql4.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 21
  27. %define V_mysql %{V_major}.%{V_minor}
  28. %define V_opkg %{V_major}.%{V_minor}
  29. # package information
  30. Name: mysql4
  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: EVAL
  37. Group: Database
  38. License: GPL
  39. Version: %{V_opkg}
  40. Release: 20061112
  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. %option with_charset utf8
  49. %option with_collation utf8_unicode_ci
  50. # list of sources
  51. Source0: http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
  52. Source1: my.cnf
  53. Source2: my.pwd
  54. Source3: rc.mysql
  55. Patch0: mysql4.patch
  56. # build information
  57. Prefix: %{l_prefix}
  58. BuildRoot: %{l_buildroot}
  59. BuildPreReq: OpenPKG, openpkg >= 20060823, perl, make, gcc, gcc::with_cxx = yes
  60. PreReq: OpenPKG, openpkg >= 20060823, perl
  61. BuildPreReq: zlib, readline, ncurses
  62. PreReq: zlib, readline, ncurses
  63. %if "%{with_ssl}" == "yes"
  64. BuildPreReq: openssl
  65. PreReq: openssl
  66. %endif
  67. AutoReq: no
  68. AutoReqProv: no
  69. Provides: mysql = %{version}-%{release}
  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 mysql4 = {
  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 -n mysql-%{V_mysql}
  85. %patch -p0
  86. %build
  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. --with-charset=%{with_charset} \
  131. --with-collation=%{with_collation} \
  132. --without-readline \
  133. --without-libedit \
  134. --with-vio \
  135. --with-named-z-libs=no \
  136. --with-low-memory \
  137. --disable-shared \
  138. $opt
  139. # build source tree
  140. %{l_make} %{l_mflags}
  141. %install
  142. rm -rf $RPM_BUILD_ROOT
  143. # patch init script
  144. %{l_shtool} subst %{l_value -s -a} \
  145. scripts/mysql_install_db.sh
  146. # perform standard installation procedure
  147. %{l_make} %{l_mflags} install \
  148. AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
  149. DESTDIR=$RPM_BUILD_ROOT
  150. # move utility 'replace', msql2mysql is patched for new path
  151. mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
  152. $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
  153. # strip installation area
  154. rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
  155. rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
  156. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  157. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
  158. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
  159. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
  160. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
  161. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
  162. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  163. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
  164. # determine default parameters
  165. %if "%{with_bdb}" == "yes"
  166. l_mysql_bdb_cache_size=8M
  167. l_mysql_bdb_log_buffer_size=32k
  168. l_mysql_bdb_max_lock=10000
  169. %else
  170. l_mysql_bdb_cache_size=0
  171. l_mysql_bdb_log_buffer_size=0
  172. l_mysql_bdb_max_lock=0
  173. %endif
  174. %if "%{with_bdb}" == "yes" || "%{with_innodb}" == "yes"
  175. l_mysqld=mysqld
  176. %else
  177. l_mysqld=mysqld-max
  178. %endif
  179. # install global configuration
  180. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
  181. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  182. -e "s;@l_mysql_bdb_cache_size@;${l_mysql_bdb_cache_size};g" \
  183. -e "s;@l_mysql_bdb_log_buffer_size@;${l_mysql_bdb_log_buffer_size};g" \
  184. -e "s;@l_mysql_bdb_max_lock@;${l_mysql_bdb_max_lock};g" \
  185. %{SOURCE my.cnf} \
  186. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  187. %{l_shtool} install -c -m 600 \
  188. %{SOURCE my.pwd} \
  189. $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
  190. # install run-command script
  191. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  192. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  193. -e "s;@l_mysqld@;${l_mysqld};g" \
  194. %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  195. # make sure the database directory exists
  196. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
  197. # directory for temporary tables
  198. %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
  199. # optional client-only installation
  200. %if "%{with_server}" != "yes"
  201. rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
  202. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  203. for bin in *; do
  204. case "$bin" in
  205. mysql | mysql_config ) ;;
  206. * ) rm -f $bin ;;
  207. esac
  208. done
  209. ) || exit $?
  210. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  211. for man in *; do
  212. case "$man" in
  213. mysql.1 | mysql_config.1 ) ;;
  214. * ) rm -f $man ;;
  215. esac
  216. done
  217. ) || exit $?
  218. %endif
  219. # determine the package files
  220. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  221. %if "%{with_server}" == "yes"
  222. %{l_files_std} \
  223. '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
  224. '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
  225. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
  226. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
  227. %else
  228. %{l_files_std}
  229. %endif
  230. %files -f files
  231. %clean
  232. rm -rf $RPM_BUILD_ROOT
  233. %pre
  234. %if "%{with_server}" == "yes"
  235. # before upgrade, save status and stop service
  236. [ $1 -eq 2 ] || exit 0
  237. eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
  238. %{l_rc} mysql stop 2>/dev/null
  239. %endif
  240. exit 0
  241. %post
  242. %if "%{with_server}" == "yes"
  243. if [ $1 -eq 1 ]; then
  244. # after install, create initial database
  245. $RPM_INSTALL_PREFIX/bin/mysql_install_db \
  246. --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
  247. chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
  248. ( echo "An initial MySQL DB was created. The owner of the database"
  249. echo "is the DB user 'root'. Its initial password is empty."
  250. echo "After starting MySQL with..."
  251. echo ""
  252. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  253. echo ""
  254. echo "...you should change the password as soon as possible with:"
  255. echo ""
  256. echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
  257. echo " -u root password '<new-password>'"
  258. echo ""
  259. echo "Additionally, because the MySQL package includes automated"
  260. echo "maintenance procedures that require administrator access to"
  261. echo "the database, you must maintain a (plain text) copy of the"
  262. echo "administrator account name and password:"
  263. echo ""
  264. echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
  265. ) | %{l_rpmtool} msg -b -t notice
  266. fi
  267. if [ $1 -eq 2 ]; then
  268. # after upgrade, restore status
  269. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  270. [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
  271. fi
  272. %endif
  273. exit 0
  274. %preun
  275. %if "%{with_server}" == "yes"
  276. # before erase, stop service and remove log files
  277. [ $1 -eq 0 ] || exit 0
  278. %{l_rc} mysql stop 2>/dev/null
  279. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
  280. rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
  281. %endif
  282. exit 0