/[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.7 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.7 2011/08/22 04:46:32 vapier 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>
41MYSQL_EXTRAS="" 41MYSQL_EXTRAS=""
42 42
43# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER 43# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
44# @DESCRIPTION: 44# @DESCRIPTION:
45# The version of the MYSQL_EXTRAS repo to use to build mysql 45# The version of the MYSQL_EXTRAS repo to use to build mysql
46# Use "none" to disable it's use
46[[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2" 47[[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2"
47 48
48inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs 49inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs
49 50
50# 51#
51# Supported EAPI versions and export functions 52# Supported EAPI versions and export functions
52# 53#
53 54
54case "${EAPI:-0}" in 55case "${EAPI:-0}" in
55 2|3|4) ;; 56 3|4) ;;
56 *) die "Unsupported EAPI: ${EAPI}" ;; 57 *) die "Unsupported EAPI: ${EAPI}" ;;
57esac 58esac
58 59
59EXPORT_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
60 61
172 173
173# Define correct SRC_URIs 174# Define correct SRC_URIs
174SRC_URI="${SERVER_URI}" 175SRC_URI="${SERVER_URI}"
175 176
176# Gentoo patches to MySQL 177# Gentoo patches to MySQL
177[[ ${MY_EXTRAS_VER} != live ]] \ 178[[ ${MY_EXTRAS_VER} != live ]] && [[ ${MY_EXTRAS_VER} != none ]] \
178&& SRC_URI="${SRC_URI} 179&& SRC_URI="${SRC_URI}
179 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 180 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
180 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 181 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
181 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 182 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
182 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" 183 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
224 225
225[[ ${PN} == "mariadb" ]] \ 226[[ ${PN} == "mariadb" ]] \
226&& mysql_version_is_at_least "5.2.5" \ 227&& mysql_version_is_at_least "5.2.5" \
227&& IUSE="${IUSE} sphinx" 228&& IUSE="${IUSE} sphinx"
228 229
230mysql_version_is_at_least "5.5.7" \
231&& IUSE="${IUSE} systemtap"
229 232
230# 233#
231# DEPENDENCIES: 234# DEPENDENCIES:
232# 235#
233 236
234# Be warned, *DEPEND are version-dependant 237# Be warned, *DEPEND are version-dependant
235# These are used for both runtime and compiletime 238# These are used for both runtime and compiletime
236DEPEND=" 239DEPEND="
237 ssl? ( >=dev-libs/openssl-0.9.6d ) 240 ssl? ( >=dev-libs/openssl-0.9.6d )
238 userland_GNU? ( sys-process/procps ) 241 kernel_linux? ( sys-process/procps )
239 >=sys-apps/sed-4 242 >=sys-apps/sed-4
240 >=sys-apps/texinfo-4.7-r1 243 >=sys-apps/texinfo-4.7-r1
241 >=sys-libs/readline-4.1 244 >=sys-libs/readline-4.1
242 >=sys-libs/zlib-1.2.3 245 >=sys-libs/zlib-1.2.3
243" 246"
249for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do 252for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do
250 [[ ${i} == ${PN} ]] || 253 [[ ${i} == ${PN} ]] ||
251 DEPEND="${DEPEND} !dev-db/${i}" 254 DEPEND="${DEPEND} !dev-db/${i}"
252done 255done
253 256
257# prefix: first need to implement something for #196294
254RDEPEND="${DEPEND} 258RDEPEND="${DEPEND}
255 !minimal? ( dev-db/mysql-init-scripts ) 259 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
256 selinux? ( sec-policy/selinux-mysql ) 260 selinux? ( sec-policy/selinux-mysql )
257" 261"
258 262
259DEPEND="${DEPEND} 263DEPEND="${DEPEND}
260 virtual/yacc 264 virtual/yacc
274&& DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )" 278&& DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )"
275 279
276[[ "${PN}" == "mariadb" ]] \ 280[[ "${PN}" == "mariadb" ]] \
277&& mysql_version_is_at_least "5.2.5" \ 281&& mysql_version_is_at_least "5.2.5" \
278&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" 282&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
283
284mysql_version_is_at_least "5.5.7" \
285&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )"
279 286
280# 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
281PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 288PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
282 289
283# For other stuff to bring us in 290# For other stuff to bring us in
378# warn about deprecated features 385# warn about deprecated features
379mysql-v2_pkg_setup() { 386mysql-v2_pkg_setup() {
380 387
381 if has test ${FEATURES} ; then 388 if has test ${FEATURES} ; then
382 if ! use minimal ; then 389 if ! use minimal ; then
383 if [[ $UID -eq 0 ]]; then 390 if ! has userpriv ${FEATURES} ; then
384 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."
385 fi 392 fi
386 fi 393 fi
387 fi 394 fi
388 395
492 499
493 # Make sure the vars are correctly initialized 500 # Make sure the vars are correctly initialized
494 mysql_init_vars 501 mysql_init_vars
495 502
496 # Check FEATURES="collision-protect" before removing this 503 # Check FEATURES="collision-protect" before removing this
497 [[ -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}"
498 505
499 # Secure the logfiles 506 # Secure the logfiles
500 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 507 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
501 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 508 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
502 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 509 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
594 601
595 local pwd1="a" 602 local pwd1="a"
596 local pwd2="b" 603 local pwd2="b"
597 local maxtry=15 604 local maxtry=15
598 605
599 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
600 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")"
601 fi 608 fi
602 609
603 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 610 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
604 ewarn "You have already a MySQL database in place." 611 ewarn "You have already a MySQL database in place."
605 ewarn "(${ROOT}/${MY_DATADIR}/*)" 612 ewarn "(${ROOT}/${MY_DATADIR}/*)"
636 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 643 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
637 || touch "${TMPDIR}/fill_help_tables.sql" 644 || touch "${TMPDIR}/fill_help_tables.sql"
638 help_tables="${TMPDIR}/fill_help_tables.sql" 645 help_tables="${TMPDIR}/fill_help_tables.sql"
639 646
640 pushd "${TMPDIR}" &>/dev/null 647 pushd "${TMPDIR}" &>/dev/null
641 "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 648 "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1
642 if [ $? -ne 0 ]; then 649 if [ $? -ne 0 ]; then
643 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
644 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"
645 fi 652 fi
646 popd &>/dev/null 653 popd &>/dev/null
647 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 654 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
648 || die "MySQL databases not installed" 655 || die "MySQL databases not installed"
649 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 656 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
650 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 657 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
651 658
652 # 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
653 helpfile="${TMPDIR}/mysqld-help" 660 helpfile="${TMPDIR}/mysqld-help"
654 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null 661 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
655 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 \
656 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 \
657 ndbcluster \ 664 ndbcluster \
658 ; do 665 ; do
659 optexp="--(skip-)?${opt}" optfull="--skip-${opt}" 666 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
663 egrep -sq external-locking "${helpfile}" && \ 670 egrep -sq external-locking "${helpfile}" && \
664 options="${options/skip-locking/skip-external-locking}" 671 options="${options/skip-locking/skip-external-locking}"
665 672
666 # Filling timezones, see 673 # Filling timezones, see
667 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 674 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
668 "${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
669 676
670 if [[ -r "${help_tables}" ]] ; then 677 if [[ -r "${help_tables}" ]] ; then
671 cat "${help_tables}" >> "${sqltmp}" 678 cat "${help_tables}" >> "${sqltmp}"
672 fi 679 fi
673 680
674 einfo "Creating the mysql database and setting proper" 681 einfo "Creating the mysql database and setting proper"
675 einfo "permissions on it ..." 682 einfo "permissions on it ..."
676 683
677 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 684 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
678 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 685 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
679 local mysqld="${ROOT}/usr/sbin/mysqld \ 686 local mysqld="${EROOT}/usr/sbin/mysqld \
680 ${options} \ 687 ${options} \
681 --user=mysql \ 688 --user=mysql \
682 --basedir=${ROOT}/usr \ 689 --basedir=${EROOT}/usr \
683 --datadir=${ROOT}/${MY_DATADIR} \ 690 --datadir=${ROOT}/${MY_DATADIR} \
684 --max_allowed_packet=8M \ 691 --max_allowed_packet=8M \
685 --net_buffer_length=16K \ 692 --net_buffer_length=16K \
686 --default-storage-engine=MyISAM \ 693 --default-storage-engine=MyISAM \
687 --socket=${socket} \ 694 --socket=${socket} \
702 fi 709 fi
703 710
704 ebegin "Setting root password" 711 ebegin "Setting root password"
705 # 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
706 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'"
707 "${ROOT}/usr/bin/mysql" \ 714 "${EROOT}/usr/bin/mysql" \
708 --socket=${socket} \ 715 --socket=${socket} \
709 -hlocalhost \ 716 -hlocalhost \
710 -e "${sql}" 717 -e "${sql}"
711 eend $? 718 eend $?
712 719
713 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 720 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
714 "${ROOT}/usr/bin/mysql" \ 721 "${EROOT}/usr/bin/mysql" \
715 --socket=${socket} \ 722 --socket=${socket} \
716 -hlocalhost \ 723 -hlocalhost \
717 -uroot \ 724 -uroot \
718 -p"${MYSQL_ROOT_PASSWORD}" \ 725 -p"${MYSQL_ROOT_PASSWORD}" \
719 mysql < "${sqltmp}" 726 mysql < "${sqltmp}"
732# @FUNCTION: mysql-v2_pkg_postrm 739# @FUNCTION: mysql-v2_pkg_postrm
733# @DESCRIPTION: 740# @DESCRIPTION:
734# Remove mysql symlinks. 741# Remove mysql symlinks.
735mysql-v2_pkg_postrm() { 742mysql-v2_pkg_postrm() {
736 743
737 : # mysql_lib_symlinks "${D}" 744 : # mysql_lib_symlinks "${ED}"
738} 745}

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

  ViewVC Help
Powered by ViewVC 1.1.20