| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.6 2006/01/14 19:00:32 vivo Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.9 2006/01/24 23:09:00 vivo Exp $ |
| 4 | |
4 | |
| 5 | # Author: Francesco Riosa <vivo at gentoo.org> |
5 | # Author: Francesco Riosa <vivo at gentoo.org> |
| 6 | # Maintainer: Francesco Riosa <vivo at gentoo.org> |
6 | # Maintainer: Francesco Riosa <vivo at gentoo.org> |
| 7 | |
7 | |
| 8 | inherit eutils flag-o-matic gnuconfig mysql_fx |
8 | inherit eutils flag-o-matic gnuconfig |
| 9 | |
9 | |
| 10 | #major, minor only in the slot |
10 | #major, minor only in the slot |
| 11 | SLOT=$(( ${MYSQL_VERSION_ID} / 10000 )) |
11 | SLOT=$(( ${MYSQL_VERSION_ID} / 10000 )) |
| 12 | |
12 | |
| 13 | # shorten the path because the socket path length must be shorter than 107 chars |
13 | # shorten the path because the socket path length must be shorter than 107 chars |
| 14 | # and we will run a mysql server during test phase |
14 | # and we will run a mysql server during test phase |
| 15 | S="${WORKDIR}/${PN}" |
15 | S="${WORKDIR}/${PN}" |
| 16 | |
16 | |
| 17 | DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
17 | DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
| 18 | HOMEPAGE="http://www.mysql.com/" |
18 | HOMEPAGE="http://www.mysql.com/" |
| 19 | NEWP="${PN}-${PV/_/-}" |
19 | NEWP="${P/_/-}" |
| 20 | SRC_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/${NEWP}.tar.gz |
20 | SRC_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/${NEWP}.tar.gz |
| 21 | mirror://gentoo/mysql-extras-20060114.tar.bz2" |
21 | mirror://gentoo/mysql-extras-20060115.tar.bz2" |
| 22 | LICENSE="GPL-2" |
22 | LICENSE="GPL-2" |
| 23 | IUSE="big-tables berkdb debug minimal perl selinux ssl static" |
23 | IUSE="big-tables berkdb debug minimal perl selinux srvdir ssl static" |
| 24 | RESTRICT="primaryuri" |
24 | RESTRICT="primaryuri confcache" |
| 25 | DEPEND="app-admin/eselect-mysql" |
25 | DEPEND="app-admin/eselect-mysql" |
| 26 | |
26 | |
| 27 | mysql_version_is_at_least "4.01.03.00" \ |
27 | mysql_version_is_at_least "4.01.03.00" \ |
| 28 | && IUSE="${IUSE} cluster utf8 extraengine" |
28 | && IUSE="${IUSE} cluster extraengine" |
| 29 | |
29 | |
| 30 | mysql_version_is_at_least "5.00.18.00" \ |
30 | mysql_version_is_at_least "5.00.18.00" \ |
| 31 | && IUSE="${IUSE} max-idx-128" |
31 | && IUSE="${IUSE} max-idx-128" |
| 32 | |
32 | |
| 33 | mysql_version_is_at_least "5.01.00.00" \ |
33 | mysql_version_is_at_least "5.01.00.00" \ |
| 34 | && IUSE="${IUSE} innodb" |
34 | && IUSE="${IUSE} innodb" |
| 35 | |
35 | |
| 36 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
36 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
|
|
37 | |
|
|
38 | # void mysql_init_vars() |
|
|
39 | # |
|
|
40 | # initialize global variables |
|
|
41 | # 2005-11-19 <vivo at gentoo.org> |
|
|
42 | mysql_init_vars() { |
|
|
43 | |
|
|
44 | if [[ ${SLOT} -eq 0 ]] ; then |
|
|
45 | MY_SUFFIX="" |
|
|
46 | else |
|
|
47 | MY_SUFFIX=${MY_SUFFIX:-"-${SLOT}"} |
|
|
48 | fi |
|
|
49 | MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR:-"/usr/share/mysql${MY_SUFFIX}"} |
|
|
50 | MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql${MY_SUFFIX}"} |
|
|
51 | MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql${MY_SUFFIX}"} |
|
|
52 | MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql${MY_SUFFIX}"} |
|
|
53 | MY_LOGDIR=${MY_LOGDIR="/var/log/mysql${MY_SUFFIX}"} |
|
|
54 | MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql${MY_SUFFIX}"} |
|
|
55 | |
|
|
56 | if [ -z "${DATADIR}" ]; then |
|
|
57 | DATADIR="" |
|
|
58 | if [ -f "${SYSCONFDIR}/my.cnf" ] ; then |
|
|
59 | DATADIR=`"my_print_defaults${MY_SUFFIX}" mysqld 2>/dev/null | sed -ne '/datadir/s|^--datadir=||p' | tail -n1` |
|
|
60 | if [ -z "${DATADIR}" ]; then |
|
|
61 | if useq "srvdir" ; then |
|
|
62 | DATADIR="/srv/localhost/mysql/datadir" |
|
|
63 | else |
|
|
64 | DATADIR=`grep ^datadir "${SYSCONFDIR}/my.cnf" | sed -e 's/.*=\s*//'` |
|
|
65 | fi |
|
|
66 | fi |
|
|
67 | fi |
|
|
68 | if [ -z "${DATADIR}" ]; then |
|
|
69 | DATADIR="${MY_LOCALSTATEDIR}" |
|
|
70 | einfo "Using default DATADIR" |
|
|
71 | fi |
|
|
72 | einfo "MySQL DATADIR is ${DATADIR}" |
|
|
73 | |
|
|
74 | if [ -z "${PREVIOUS_DATADIR}" ] ; then |
|
|
75 | if [ -a "${DATADIR}" ] ; then |
|
|
76 | ewarn "Previous datadir found, it's YOUR job to change" |
|
|
77 | ewarn "ownership and have care of it" |
|
|
78 | PREVIOUS_DATADIR="yes" |
|
|
79 | export PREVIOUS_DATADIR |
|
|
80 | else |
|
|
81 | PREVIOUS_DATADIR="no" |
|
|
82 | export PREVIOUS_DATADIR |
|
|
83 | fi |
|
|
84 | fi |
|
|
85 | fi |
|
|
86 | |
|
|
87 | export MY_SUFFIX MY_SHAREDSTATEDIR MY_SYSCONFDIR |
|
|
88 | export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR |
|
|
89 | export MY_INCLUDEDIR |
|
|
90 | export DATADIR |
|
|
91 | } |
| 37 | |
92 | |
| 38 | mysql_pkg_setup() { |
93 | mysql_pkg_setup() { |
| 39 | |
94 | |
| 40 | enewgroup mysql 60 || die "problem adding group mysql" |
95 | enewgroup mysql 60 || die "problem adding group mysql" |
| 41 | enewuser mysql 60 -1 /dev/null mysql \ |
96 | enewuser mysql 60 -1 /dev/null mysql \ |
| … | |
… | |
| 118 | ${buildstep} || die "failed ${buildstep/ */} dir \"${d}\"" |
173 | ${buildstep} || die "failed ${buildstep/ */} dir \"${d}\"" |
| 119 | done |
174 | done |
| 120 | popd &>/dev/null |
175 | popd &>/dev/null |
| 121 | done |
176 | done |
| 122 | |
177 | |
| 123 | if ! useq bdbdir && ! mysql_check_version_range "5.01.00.00 to 5.01.06.99" |
178 | if useq berkdb && ! mysql_check_version_range "5.01.00.00 to 5.01.06.99" |
| 124 | then |
179 | then |
| 125 | [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh" |
180 | [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh" |
| 126 | pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null |
181 | pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null |
| 127 | popd &>/dev/null |
182 | popd &>/dev/null |
| 128 | fi |
183 | fi |
| … | |
… | |
| 190 | else |
245 | else |
| 191 | myconf="${myconf} --with-raid" |
246 | myconf="${myconf} --with-raid" |
| 192 | fi |
247 | fi |
| 193 | |
248 | |
| 194 | if ! mysql_version_is_at_least "5.00.00.00" ; then |
249 | if ! mysql_version_is_at_least "5.00.00.00" ; then |
| 195 | if mysql_version_is_at_least "4.01.00.00" && useq utf8; then |
250 | if mysql_version_is_at_least "4.01.00.00" ; then |
| 196 | myconf="${myconf} --with-charset=utf8" |
251 | myconf="${myconf} --with-charset=utf8" |
| 197 | myconf="${myconf} --with-collation=utf8_general_ci" |
252 | myconf="${myconf} --with-collation=utf8_general_ci" |
| 198 | else |
253 | else |
| 199 | myconf="${myconf} --with-charset=latin1" |
254 | myconf="${myconf} --with-charset=latin1" |
| 200 | myconf="${myconf} --with-collation=latin1_swedish_ci" |
255 | myconf="${myconf} --with-collation=latin1_swedish_ci" |
| … | |
… | |
| 262 | if mysql_version_is_at_least "5.01.00.00" ; then |
317 | if mysql_version_is_at_least "5.01.00.00" ; then |
| 263 | myconf="${myconf} --with-partition" |
318 | myconf="${myconf} --with-partition" |
| 264 | fi |
319 | fi |
| 265 | fi |
320 | fi |
| 266 | |
321 | |
|
|
322 | fi |
|
|
323 | |
| 267 | mysql_version_is_at_least "5.00.18.00" \ |
324 | mysql_version_is_at_least "5.00.18.00" \ |
| 268 | && useq "max-idx-128" \ |
325 | && useq "max-idx-128" \ |
| 269 | && myconf="${myconf} --with-max-indexes=128" |
326 | && myconf="${myconf} --with-max-indexes=128" |
|
|
327 | |
|
|
328 | if mysql_version_is_at_least "5.01.05.00" ; then |
|
|
329 | myconf="${myconf} --with-row-based-replication" |
| 270 | fi |
330 | fi |
| 271 | |
331 | |
| 272 | #Bug #114895,Bug #110149 |
332 | #Bug #114895,Bug #110149 |
| 273 | filter-flags "-O" "-O[01]" |
333 | filter-flags "-O" "-O[01]" |
| 274 | #glibc-2.3.2_pre fix; bug #16496 |
334 | #glibc-2.3.2_pre fix; bug #16496 |
| … | |
… | |
| 360 | fi |
420 | fi |
| 361 | |
421 | |
| 362 | # config stuff |
422 | # config stuff |
| 363 | insinto "${MY_SYSCONFDIR}" |
423 | insinto "${MY_SYSCONFDIR}" |
| 364 | doins scripts/mysqlaccess.conf |
424 | doins scripts/mysqlaccess.conf |
|
|
425 | sed -e "s!@MY_SUFFIX@!${MY_SUFFIX}!g" \ |
|
|
426 | -e "s!@DATADIR@!${DATADIR}!g" \ |
|
|
427 | "${FILESDIR}/my.cnf-4.1-r1" \ |
|
|
428 | > "${TMPDIR}/my.cnf.ok" |
|
|
429 | ls -l ${TMPDIR} ${FILESDIR}/my.cnf-4.1-r1 |
| 365 | newins "${FILESDIR}/my.cnf-4.1" my.cnf |
430 | newins "${TMPDIR}/my.cnf.ok" my.cnf |
|
|
431 | |
| 366 | insinto "/etc/conf.d" |
432 | insinto "/etc/conf.d" |
| 367 | newins "${FILESDIR}/mysql-slot.conf.d-r2" "mysql" |
433 | newins "${FILESDIR}/mysql-slot.conf.d-r2" "mysql" |
| 368 | mysql_version_is_at_least "5.00.11.00" \ |
434 | mysql_version_is_at_least "5.00.11.00" \ |
| 369 | && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager" |
435 | && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager" |
| 370 | |
|
|
| 371 | local charset='utf8' |
|
|
| 372 | ! useq utf8 && local charset='latin1' |
|
|
| 373 | sed --in-place \ |
|
|
| 374 | -e "s/@MY_SUFFIX@/${MY_SUFFIX}/" \ |
|
|
| 375 | -e "s/@CHARSET@/${charset}/" \ |
|
|
| 376 | "${D}/etc/mysql${MY_SUFFIX}/my.cnf" |
|
|
| 377 | |
436 | |
| 378 | # minimal builds don't have the server |
437 | # minimal builds don't have the server |
| 379 | if ! useq minimal; then |
438 | if ! useq minimal; then |
| 380 | exeinto /etc/init.d |
439 | exeinto /etc/init.d |
| 381 | newexe "${FILESDIR}/mysql-slot.rc6-r2" "mysql" |
440 | newexe "${FILESDIR}/mysql-slot.rc6-r2" "mysql" |
| 382 | [[ ${SLOT} -gt 0 ]] && dosym "/etc/init.d/mysql" "/etc/init.d/mysql${MY_SUFFIX}" |
441 | [[ ${SLOT} -gt 0 ]] && dosym "/etc/init.d/mysql" "/etc/init.d/mysql${MY_SUFFIX}" |
| 383 | |
442 | |
| 384 | mysql_version_is_at_least "5.00.11.00" \ |
443 | mysql_version_is_at_least "5.00.11.00" \ |
| 385 | && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager" |
444 | && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager" |
| 386 | insinto /etc/logrotate.d |
445 | insinto /etc/logrotate.d |
| 387 | # TODO |
446 | sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \ |
|
|
447 | "${FILESDIR}/logrotate-slot.mysql" \ |
|
|
448 | > "${TMPDIR}/logrotate.mysql" |
| 388 | newins "${FILESDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" |
449 | newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" |
| 389 | |
450 | |
| 390 | #empty dirs... |
451 | #empty dirs... |
| 391 | diropts "-m0750" |
452 | diropts "-m0750" |
| 392 | if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then |
453 | if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then |
| 393 | dodir "${DATADIR}" |
454 | dodir "${DATADIR}" |
| … | |
… | |
| 530 | fi |
591 | fi |
| 531 | |
592 | |
| 532 | local options="" |
593 | local options="" |
| 533 | local sqltmp="$(emktemp)" |
594 | local sqltmp="$(emktemp)" |
| 534 | |
595 | |
| 535 | local help_tables="${ROOT}/usr/share/doc/mysql-${PVR}/scripts/fill_help_tables.sql.gz" |
596 | local help_tables="${MY_SHAREDSTATEDIR}/fill_help_tables.sql" |
| 536 | [[ -r "${help_tables}" ]] \ |
597 | [[ -r "${help_tables}" ]] \ |
| 537 | && zcat "${help_tables}" > "${TMPDIR}/fill_help_tables.sql" \ |
598 | && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
| 538 | || touch "${TMPDIR}/fill_help_tables.sql" |
599 | || touch "${TMPDIR}/fill_help_tables.sql" |
| 539 | help_tables="${TMPDIR}/fill_help_tables.sql" |
600 | help_tables="${TMPDIR}/fill_help_tables.sql" |
| 540 | |
601 | |
| 541 | pushd "${TMPDIR}" &>/dev/null |
602 | pushd "${TMPDIR}" &>/dev/null |
| 542 | ${ROOT}/usr/bin/mysql_install_db${MY_SUFFIX} | grep -B5 -A999 -i "ERROR" |
603 | ${ROOT}/usr/bin/mysql_install_db${MY_SUFFIX} | grep -B5 -A999 -i "ERROR" |