/[gentoo-x86]/eclass/mysql-v2.eclass
Gentoo

Diff of /eclass/mysql-v2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.11 Revision 1.12
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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-v2.eclass,v 1.11 2011/12/27 07:37:20 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.12 2012/01/06 21:32:48 jmbsvicetto Exp $
4 4
5# @ECLASS: mysql-v2.eclass 5# @ECLASS: mysql-v2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Maintainers: 7# Maintainers:
8# - MySQL Team <mysql-bugs@gentoo.org> 8# - MySQL Team <mysql-bugs@gentoo.org>
51# 51#
52# Supported EAPI versions and export functions 52# Supported EAPI versions and export functions
53# 53#
54 54
55case "${EAPI:-0}" in 55case "${EAPI:-0}" in
56 2|3|4) ;; 56 3|4) ;;
57 *) die "Unsupported EAPI: ${EAPI}" ;; 57 *) die "Unsupported EAPI: ${EAPI}" ;;
58esac 58esac
59 59
60EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm 60EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm
61 61
228&& IUSE="${IUSE} sphinx" 228&& IUSE="${IUSE} sphinx"
229 229
230mysql_version_is_at_least "5.5.7" \ 230mysql_version_is_at_least "5.5.7" \
231&& IUSE="${IUSE} systemtap" 231&& IUSE="${IUSE} systemtap"
232 232
233
234# 233#
235# DEPENDENCIES: 234# DEPENDENCIES:
236# 235#
237 236
238# Be warned, *DEPEND are version-dependant 237# Be warned, *DEPEND are version-dependant
386# warn about deprecated features 385# warn about deprecated features
387mysql-v2_pkg_setup() { 386mysql-v2_pkg_setup() {
388 387
389 if has test ${FEATURES} ; then 388 if has test ${FEATURES} ; then
390 if ! use minimal ; then 389 if ! use minimal ; then
391 if [[ $UID -eq 0 ]]; then 390 if ! has userpriv ${FEATURES} ; then
392 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." 391 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
393 fi 392 fi
394 fi 393 fi
395 fi 394 fi
396 395
500 499
501 # Make sure the vars are correctly initialized 500 # Make sure the vars are correctly initialized
502 mysql_init_vars 501 mysql_init_vars
503 502
504 # Check FEATURES="collision-protect" before removing this 503 # Check FEATURES="collision-protect" before removing this
505 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 504 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
506 505
507 # Secure the logfiles 506 # Secure the logfiles
508 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 507 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
509 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 508 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
510 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 509 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
602 601
603 local pwd1="a" 602 local pwd1="a"
604 local pwd2="b" 603 local pwd2="b"
605 local maxtry=15 604 local maxtry=15
606 605
607 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then 606 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then
608 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" 607 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")"
609 fi 608 fi
610 609
611 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 610 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
612 ewarn "You have already a MySQL database in place." 611 ewarn "You have already a MySQL database in place."
613 ewarn "(${ROOT}/${MY_DATADIR}/*)" 612 ewarn "(${ROOT}/${MY_DATADIR}/*)"
644 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 643 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
645 || touch "${TMPDIR}/fill_help_tables.sql" 644 || touch "${TMPDIR}/fill_help_tables.sql"
646 help_tables="${TMPDIR}/fill_help_tables.sql" 645 help_tables="${TMPDIR}/fill_help_tables.sql"
647 646
648 pushd "${TMPDIR}" &>/dev/null 647 pushd "${TMPDIR}" &>/dev/null
649 "${ROOT}/usr/bin/mysql_install_db" --basedir=/usr >"${TMPDIR}"/mysql_install_db.log 2>&1 648 "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1
650 if [ $? -ne 0 ]; then 649 if [ $? -ne 0 ]; then
651 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 650 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
652 die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" 651 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
653 fi 652 fi
654 popd &>/dev/null 653 popd &>/dev/null
655 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 654 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
656 || die "MySQL databases not installed" 655 || die "MySQL databases not installed"
657 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 656 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
658 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 657 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
659 658
660 # Figure out which options we need to disable to do the setup 659 # Figure out which options we need to disable to do the setup
661 helpfile="${TMPDIR}/mysqld-help" 660 helpfile="${TMPDIR}/mysqld-help"
662 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null 661 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
663 for opt in grant-tables host-cache name-resolve networking slave-start bdb \ 662 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
664 federated innodb ssl log-bin relay-log slow-query-log external-locking \ 663 federated innodb ssl log-bin relay-log slow-query-log external-locking \
665 ndbcluster \ 664 ndbcluster \
666 ; do 665 ; do
667 optexp="--(skip-)?${opt}" optfull="--skip-${opt}" 666 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
671 egrep -sq external-locking "${helpfile}" && \ 670 egrep -sq external-locking "${helpfile}" && \
672 options="${options/skip-locking/skip-external-locking}" 671 options="${options/skip-locking/skip-external-locking}"
673 672
674 # Filling timezones, see 673 # Filling timezones, see
675 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 674 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
676 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null 675 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
677 676
678 if [[ -r "${help_tables}" ]] ; then 677 if [[ -r "${help_tables}" ]] ; then
679 cat "${help_tables}" >> "${sqltmp}" 678 cat "${help_tables}" >> "${sqltmp}"
680 fi 679 fi
681 680
682 einfo "Creating the mysql database and setting proper" 681 einfo "Creating the mysql database and setting proper"
683 einfo "permissions on it ..." 682 einfo "permissions on it ..."
684 683
685 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 684 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
686 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 685 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
687 local mysqld="${ROOT}/usr/sbin/mysqld \ 686 local mysqld="${EROOT}/usr/sbin/mysqld \
688 ${options} \ 687 ${options} \
689 --user=mysql \ 688 --user=mysql \
690 --basedir=${ROOT}/usr \ 689 --basedir=${EROOT}/usr \
691 --datadir=${ROOT}/${MY_DATADIR} \ 690 --datadir=${ROOT}/${MY_DATADIR} \
692 --max_allowed_packet=8M \ 691 --max_allowed_packet=8M \
693 --net_buffer_length=16K \ 692 --net_buffer_length=16K \
694 --default-storage-engine=MyISAM \ 693 --default-storage-engine=MyISAM \
695 --socket=${socket} \ 694 --socket=${socket} \
710 fi 709 fi
711 710
712 ebegin "Setting root password" 711 ebegin "Setting root password"
713 # Do this from memory, as we don't want clear text passwords in temp files 712 # Do this from memory, as we don't want clear text passwords in temp files
714 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" 713 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
715 "${ROOT}/usr/bin/mysql" \ 714 "${EROOT}/usr/bin/mysql" \
716 --socket=${socket} \ 715 --socket=${socket} \
717 -hlocalhost \ 716 -hlocalhost \
718 -e "${sql}" 717 -e "${sql}"
719 eend $? 718 eend $?
720 719
721 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 720 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
722 "${ROOT}/usr/bin/mysql" \ 721 "${EROOT}/usr/bin/mysql" \
723 --socket=${socket} \ 722 --socket=${socket} \
724 -hlocalhost \ 723 -hlocalhost \
725 -uroot \ 724 -uroot \
726 -p"${MYSQL_ROOT_PASSWORD}" \ 725 -p"${MYSQL_ROOT_PASSWORD}" \
727 mysql < "${sqltmp}" 726 mysql < "${sqltmp}"
740# @FUNCTION: mysql-v2_pkg_postrm 739# @FUNCTION: mysql-v2_pkg_postrm
741# @DESCRIPTION: 740# @DESCRIPTION:
742# Remove mysql symlinks. 741# Remove mysql symlinks.
743mysql-v2_pkg_postrm() { 742mysql-v2_pkg_postrm() {
744 743
745 : # mysql_lib_symlinks "${D}" 744 : # mysql_lib_symlinks "${ED}"
746} 745}

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20