/[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.10 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.10 2011/11/17 16:04:02 dev-zero 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
225 225
226[[ ${PN} == "mariadb" ]] \ 226[[ ${PN} == "mariadb" ]] \
227&& mysql_version_is_at_least "5.2.5" \ 227&& mysql_version_is_at_least "5.2.5" \
228&& IUSE="${IUSE} sphinx" 228&& IUSE="${IUSE} sphinx"
229 229
230mysql_version_is_at_least "5.5.7" \
231&& IUSE="${IUSE} systemtap"
230 232
231# 233#
232# DEPENDENCIES: 234# DEPENDENCIES:
233# 235#
234 236
277 279
278[[ "${PN}" == "mariadb" ]] \ 280[[ "${PN}" == "mariadb" ]] \
279&& mysql_version_is_at_least "5.2.5" \ 281&& mysql_version_is_at_least "5.2.5" \
280&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" 282&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
281 283
284mysql_version_is_at_least "5.5.7" \
285&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )"
286
282# dev-perl/DBD-mysql is needed by some scripts installed by MySQL 287# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
283PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 288PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
284 289
285# For other stuff to bring us in 290# For other stuff to bring us in
286PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" 291PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
380# warn about deprecated features 385# warn about deprecated features
381mysql-v2_pkg_setup() { 386mysql-v2_pkg_setup() {
382 387
383 if has test ${FEATURES} ; then 388 if has test ${FEATURES} ; then
384 if ! use minimal ; then 389 if ! use minimal ; then
385 if [[ $UID -eq 0 ]]; then 390 if ! has userpriv ${FEATURES} ; then
386 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."
387 fi 392 fi
388 fi 393 fi
389 fi 394 fi
390 395
494 499
495 # Make sure the vars are correctly initialized 500 # Make sure the vars are correctly initialized
496 mysql_init_vars 501 mysql_init_vars
497 502
498 # Check FEATURES="collision-protect" before removing this 503 # Check FEATURES="collision-protect" before removing this
499 [[ -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}"
500 505
501 # Secure the logfiles 506 # Secure the logfiles
502 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 507 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
503 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 508 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
504 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 509 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
596 601
597 local pwd1="a" 602 local pwd1="a"
598 local pwd2="b" 603 local pwd2="b"
599 local maxtry=15 604 local maxtry=15
600 605
601 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
602 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")"
603 fi 608 fi
604 609
605 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 610 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
606 ewarn "You have already a MySQL database in place." 611 ewarn "You have already a MySQL database in place."
607 ewarn "(${ROOT}/${MY_DATADIR}/*)" 612 ewarn "(${ROOT}/${MY_DATADIR}/*)"
638 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 643 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
639 || touch "${TMPDIR}/fill_help_tables.sql" 644 || touch "${TMPDIR}/fill_help_tables.sql"
640 help_tables="${TMPDIR}/fill_help_tables.sql" 645 help_tables="${TMPDIR}/fill_help_tables.sql"
641 646
642 pushd "${TMPDIR}" &>/dev/null 647 pushd "${TMPDIR}" &>/dev/null
643 "${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
644 if [ $? -ne 0 ]; then 649 if [ $? -ne 0 ]; then
645 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
646 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"
647 fi 652 fi
648 popd &>/dev/null 653 popd &>/dev/null
649 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 654 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
650 || die "MySQL databases not installed" 655 || die "MySQL databases not installed"
651 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 656 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
652 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 657 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
653 658
654 # 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
655 helpfile="${TMPDIR}/mysqld-help" 660 helpfile="${TMPDIR}/mysqld-help"
656 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null 661 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
657 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 \
658 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 \
659 ndbcluster \ 664 ndbcluster \
660 ; do 665 ; do
661 optexp="--(skip-)?${opt}" optfull="--skip-${opt}" 666 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
665 egrep -sq external-locking "${helpfile}" && \ 670 egrep -sq external-locking "${helpfile}" && \
666 options="${options/skip-locking/skip-external-locking}" 671 options="${options/skip-locking/skip-external-locking}"
667 672
668 # Filling timezones, see 673 # Filling timezones, see
669 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 674 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
670 "${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
671 676
672 if [[ -r "${help_tables}" ]] ; then 677 if [[ -r "${help_tables}" ]] ; then
673 cat "${help_tables}" >> "${sqltmp}" 678 cat "${help_tables}" >> "${sqltmp}"
674 fi 679 fi
675 680
676 einfo "Creating the mysql database and setting proper" 681 einfo "Creating the mysql database and setting proper"
677 einfo "permissions on it ..." 682 einfo "permissions on it ..."
678 683
679 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 684 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
680 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 685 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
681 local mysqld="${ROOT}/usr/sbin/mysqld \ 686 local mysqld="${EROOT}/usr/sbin/mysqld \
682 ${options} \ 687 ${options} \
683 --user=mysql \ 688 --user=mysql \
684 --basedir=${ROOT}/usr \ 689 --basedir=${EROOT}/usr \
685 --datadir=${ROOT}/${MY_DATADIR} \ 690 --datadir=${ROOT}/${MY_DATADIR} \
686 --max_allowed_packet=8M \ 691 --max_allowed_packet=8M \
687 --net_buffer_length=16K \ 692 --net_buffer_length=16K \
688 --default-storage-engine=MyISAM \ 693 --default-storage-engine=MyISAM \
689 --socket=${socket} \ 694 --socket=${socket} \
704 fi 709 fi
705 710
706 ebegin "Setting root password" 711 ebegin "Setting root password"
707 # 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
708 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'"
709 "${ROOT}/usr/bin/mysql" \ 714 "${EROOT}/usr/bin/mysql" \
710 --socket=${socket} \ 715 --socket=${socket} \
711 -hlocalhost \ 716 -hlocalhost \
712 -e "${sql}" 717 -e "${sql}"
713 eend $? 718 eend $?
714 719
715 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 720 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
716 "${ROOT}/usr/bin/mysql" \ 721 "${EROOT}/usr/bin/mysql" \
717 --socket=${socket} \ 722 --socket=${socket} \
718 -hlocalhost \ 723 -hlocalhost \
719 -uroot \ 724 -uroot \
720 -p"${MYSQL_ROOT_PASSWORD}" \ 725 -p"${MYSQL_ROOT_PASSWORD}" \
721 mysql < "${sqltmp}" 726 mysql < "${sqltmp}"
734# @FUNCTION: mysql-v2_pkg_postrm 739# @FUNCTION: mysql-v2_pkg_postrm
735# @DESCRIPTION: 740# @DESCRIPTION:
736# Remove mysql symlinks. 741# Remove mysql symlinks.
737mysql-v2_pkg_postrm() { 742mysql-v2_pkg_postrm() {
738 743
739 : # mysql_lib_symlinks "${D}" 744 : # mysql_lib_symlinks "${ED}"
740} 745}

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

  ViewVC Help
Powered by ViewVC 1.1.20