mysql.spec 11 KB

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