mysql4.spec 10 KB

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