[mysql eclasses] Added prefix support for eclasses - fixes bug 348788 and bug 388125.
authorJorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
Fri, 6 Jan 2012 21:32:48 +0000 (21:32 +0000)
committerJorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
Fri, 6 Jan 2012 21:32:48 +0000 (21:32 +0000)
Bumped required EAPI to 3 due to the prefix support.
Fix -userpriv detection - fixes bug 312809.

eclass/ChangeLog
eclass/mysql-autotools.eclass
eclass/mysql-cmake.eclass
eclass/mysql-v2.eclass
eclass/mysql.eclass
eclass/mysql_fx.eclass

index 32d92e0205aefda155545d8d6212096faaf988db..6174ed573722d00f392b71b221d662b837feff2b 100644 (file)
@@ -1,6 +1,14 @@
 # ChangeLog for eclass directory
 # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.72 2012/01/05 23:20:02 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.73 2012/01/06 21:32:48 jmbsvicetto Exp $
+
+  06 Jan 2012; Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
+  mysql.eclass, mysql-autotools.eclass, mysql-cmake.eclass, mysql-v2.eclass,
+  mysql_fx.eclass:
+  [mysql eclasses] Added prefix support for eclasses - fixes bug 348788 and bug
+  388125.
+  Bumped required EAPI to 3 due to the prefix support.
+  Fix -userpriv detection - fixes bug 312809.
 
   05 Jan 2012; Michał Górny <mgorny@gentoo.org> systemd.eclass:
   Fix use of dosym with directory destination.
index cf710f9825d1ac7ed1fca68503c8f15f109ae004..bf9042e63c2d15513e51c88074f6df078a0def84 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v 1.2 2011/08/22 04:46:32 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v 1.3 2012/01/06 21:32:48 jmbsvicetto Exp $
 
 # @ECLASS: mysql-autotools.eclass
 # @MAINTAINER:
@@ -108,7 +108,7 @@ mysql-autotools_configure_common() {
        myconf="${myconf} --with-extra-charsets=all"
        myconf="${myconf} --with-mysqld-user=mysql"
        myconf="${myconf} --with-server"
-       myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock"
+       myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
        myconf="${myconf} --without-libwrap"
 
        if use static ; then
@@ -160,13 +160,13 @@ mysql-autotools_configure_51() {
        # TODO: !!!! readd --without-readline
        # the failure depend upon config/ac-macros/readline.m4 checking into
        # readline.h instead of history.h
-       myconf="${myconf} $(use_with ssl ssl /usr)"
+       myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
        myconf="${myconf} --enable-assembler"
        myconf="${myconf} --with-geometry"
        myconf="${myconf} --with-readline"
-       myconf="${myconf} --with-zlib-dir=/usr/"
+       myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
        myconf="${myconf} --without-pstack"
-       myconf="${myconf} --with-plugindir=/usr/$(get_libdir)/mysql/plugin"
+       myconf="${myconf} --with-plugindir=${EPREFIX}/usr/$(get_libdir)/mysql/plugin"
 
        # This is an explict die here, because if we just forcibly disable it, then the
        # user's data is not accessible.
@@ -320,7 +320,7 @@ pbxt_src_configure() {
        eautoreconf
 
        local myconf=""
-       myconf="${myconf} --with-mysql=${S} --libdir=/usr/$(get_libdir)"
+       myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
        use debug && myconf="${myconf} --with-debug=full"
        econf ${myconf} || die "Problem configuring PBXT storage engine"
 }
@@ -477,7 +477,7 @@ mysql-autotools_src_configure() {
                filter-flags -fomit-frame-pointer
 
        econf \
-               --libexecdir="/usr/sbin" \
+               --libexecdir="${EPREFIX}/usr/sbin" \
                --sysconfdir="${MY_SYSCONFDIR}" \
                --localstatedir="${MY_LOCALSTATEDIR}" \
                --sharedstatedir="${MY_SHAREDSTATEDIR}" \
@@ -539,7 +539,7 @@ mysql-autotools_src_install() {
 
        # Various junk (my-*.cnf moved elsewhere)
        einfo "Removing duplicate /usr/share/mysql files"
-       rm -Rf "${D}/usr/share/info"
+       rm -Rf "${ED}/usr/share/info"
        for removeme in  "mysql-log-rotate" mysql.server* \
                binary-configure* my-*.cnf mi_test_all*
        do
@@ -550,8 +550,8 @@ mysql-autotools_src_install() {
        if use minimal ; then
                einfo "Remove all extra content for minimal build"
                rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
-               rm -f "${D}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
-               rm -f "${D}/usr/sbin/mysqld"
+               rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
+               rm -f "${ED}/usr/sbin/mysqld"
                rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
        fi
 
@@ -567,10 +567,13 @@ mysql-autotools_src_install() {
                5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
        esac
        einfo "Building default my.cnf (${mysql_mycnf_version})"
-       insinto "${MY_SYSCONFDIR}"
+       insinto "${MY_SYSCONFDIR#${EPREFIX}}"
        doins scripts/mysqlaccess.conf
        mycnf_src="my.cnf-${mysql_mycnf_version}"
        sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
+               -e "s!/tmp!${EPREFIX}/tmp!" \
+               -e "s!/usr!${EPREFIX}/usr!" \
+               -e "s!= /var!= ${EPREFIX}/var!" \
                "${FILESDIR}/${mycnf_src}" \
                > "${TMPDIR}/my.cnf.ok"
        if use latin1 ; then
@@ -586,16 +589,16 @@ mysql-autotools_src_install() {
                # Empty directories ...
                diropts "-m0750"
                if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
-                       dodir "${MY_DATADIR}"
-                       keepdir "${MY_DATADIR}"
+                       dodir "${MY_DATADIR#${EPREFIX}}"
+                       keepdir "${MY_DATADIR#${EPREFIX}}"
                        chown -R mysql:mysql "${D}/${MY_DATADIR}"
                fi
 
                diropts "-m0755"
-               for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
+               for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
                        dodir "${folder}"
                        keepdir "${folder}"
-                       chown -R mysql:mysql "${D}/${folder}"
+                       chown -R mysql:mysql "${ED}/${folder}"
                done
        fi
 
@@ -625,5 +628,5 @@ mysql-autotools_src_install() {
 
        fi
 
-       mysql_lib_symlinks "${D}"
+       mysql_lib_symlinks "${ED}"
 }
index a8cebb5d26270632f4c67d03f03d4378b75d96e7..053f56c430c2fec96dca92377f5b6cad45788884 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.4 2011/12/27 07:37:20 robbat2 Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.5 2012/01/06 21:32:48 jmbsvicetto Exp $
 
 # @ECLASS: mysql-cmake.eclass
 # @MAINTAINER:
@@ -117,7 +117,7 @@ configure_cmake_standard() {
                -DENABLED_LOCAL_INFILE=1
                -DEXTRA_CHARSETS=all
                -DMYSQL_USER=mysql
-               -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock
+               -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
                -DWITHOUT_READLINE=1
                -DWITH_ZLIB=system
                -DWITHOUT_LIBWRAP=1
@@ -191,9 +191,9 @@ mysql-cmake_src_configure() {
        CMAKE_BUILD_TYPE="RelWithDebInfo"
 
        mycmakeargs=(
-               -DCMAKE_INSTALL_PREFIX=/usr
-               -DMYSQL_DATADIR=/var/lib/mysql
-               -DSYSCONFDIR=/etc/mysql
+               -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
+               -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
+               -DSYSCONFDIR=${EPREFIX}/etc/mysql
                -DINSTALL_BINDIR=bin
                -DINSTALL_DOCDIR=share/doc/${P}
                -DINSTALL_DOCREADMEDIR=share/doc/${P}
@@ -201,14 +201,14 @@ mysql-cmake_src_configure() {
                -DINSTALL_INFODIR=share/info
                -DINSTALL_LIBDIR=$(get_libdir)/mysql
                -DINSTALL_MANDIR=share/man
-               -DINSTALL_MYSQLDATADIR=/var/lib/mysql
+               -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
                -DINSTALL_MYSQLSHAREDIR=share/mysql
                -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
                -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
                -DINSTALL_SBINDIR=sbin
                -DINSTALL_SCRIPTDIR=share/mysql/scripts
                -DINSTALL_SQLBENCHDIR=share/mysql
-               -DINSTALL_SUPPORTFILESDIR=/usr/share/mysql
+               -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
                -DWITH_COMMENT="Gentoo Linux ${PF}"
                -DWITHOUT_UNIT_TESTS=1
        )
@@ -264,7 +264,7 @@ mysql-cmake_src_install() {
        dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
 
        # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
-       rm -Rf "${D}/usr/data"
+       rm -Rf "${ED}/usr/data"
 
        # Various junk (my-*.cnf moved elsewhere)
        einfo "Removing duplicate /usr/share/mysql files"
@@ -273,8 +273,8 @@ mysql-cmake_src_install() {
 #      if use minimal ; then
 #              einfo "Remove all extra content for minimal build"
 #              rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
-#              rm -f "${D}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
-#              rm -f "${D}/usr/sbin/mysqld"
+#              rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
+#              rm -f "${ED}/usr/sbin/mysqld"
 #              rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
 #      fi
 
@@ -309,16 +309,16 @@ mysql-cmake_src_install() {
                # Empty directories ...
                diropts "-m0750"
                if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
-                       dodir "${MY_DATADIR}"
-                       keepdir "${MY_DATADIR}"
+                       dodir "${MY_DATADIR#${EPREFIX}}"
+                       keepdir "${MY_DATADIR#${EPREFIX}}"
                        chown -R mysql:mysql "${D}/${MY_DATADIR}"
                fi
 
                diropts "-m0755"
-               for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
+               for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
                        dodir "${folder}"
                        keepdir "${folder}"
-                       chown -R mysql:mysql "${D}/${folder}"
+                       chown -R mysql:mysql "${ED}/${folder}"
                done
        fi
 
@@ -341,5 +341,5 @@ mysql-cmake_src_install() {
 
        fi
 
-       mysql_lib_symlinks "${D}"
+       mysql_lib_symlinks "${ED}"
 }
index 33d9cf9f36d851112f3bda0c999b3d13dc6c3696..061fcc91303727a20889ad5278f8fc5784968921 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.11 2011/12/27 07:37:20 robbat2 Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.12 2012/01/06 21:32:48 jmbsvicetto Exp $
 
 # @ECLASS: mysql-v2.eclass
 # @MAINTAINER:
@@ -53,7 +53,7 @@ inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx
 #
 
 case "${EAPI:-0}" in
-       2|3|4) ;;
+       3|4) ;;
        *) die "Unsupported EAPI: ${EAPI}" ;;
 esac
 
@@ -230,7 +230,6 @@ IUSE="${IUSE} berkdb"
 mysql_version_is_at_least "5.5.7" \
 && IUSE="${IUSE} systemtap"
 
-
 #
 # DEPENDENCIES:
 #
@@ -388,7 +387,7 @@ mysql-v2_pkg_setup() {
 
        if has test ${FEATURES} ; then
                if ! use minimal ; then
-                       if [[ $UID -eq 0 ]]; then
+                       if ! has userpriv ${FEATURES} ; then
                                eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
                        fi
                fi
@@ -502,7 +501,7 @@ mysql-v2_pkg_postinst() {
        mysql_init_vars
 
        # Check FEATURES="collision-protect" before removing this
-       [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
+       [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
 
        # Secure the logfiles
        touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
@@ -604,8 +603,8 @@ mysql-v2_pkg_config() {
        local pwd2="b"
        local maxtry=15
 
-       if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then
-               MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")"
+       if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then
+               MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")"
        fi
 
        if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
@@ -646,10 +645,10 @@ mysql-v2_pkg_config() {
        help_tables="${TMPDIR}/fill_help_tables.sql"
 
        pushd "${TMPDIR}" &>/dev/null
-       "${ROOT}/usr/bin/mysql_install_db" --basedir=/usr >"${TMPDIR}"/mysql_install_db.log 2>&1
+       "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1
        if [ $? -ne 0 ]; then
                grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
-               die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
+               die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
        fi
        popd &>/dev/null
        [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
@@ -659,7 +658,7 @@ mysql-v2_pkg_config() {
 
        # Figure out which options we need to disable to do the setup
        helpfile="${TMPDIR}/mysqld-help"
-       ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
+       ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
        for opt in grant-tables host-cache name-resolve networking slave-start bdb \
                federated innodb ssl log-bin relay-log slow-query-log external-locking \
                ndbcluster \
@@ -673,7 +672,7 @@ mysql-v2_pkg_config() {
 
        # Filling timezones, see
        # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
-       "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
+       "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
 
        if [[ -r "${help_tables}" ]] ; then
                cat "${help_tables}" >> "${sqltmp}"
@@ -682,12 +681,12 @@ mysql-v2_pkg_config() {
        einfo "Creating the mysql database and setting proper"
        einfo "permissions on it ..."
 
-       local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
-       local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
-       local mysqld="${ROOT}/usr/sbin/mysqld \
+       local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
+       local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
+       local mysqld="${EROOT}/usr/sbin/mysqld \
                ${options} \
                --user=mysql \
-               --basedir=${ROOT}/usr \
+               --basedir=${EROOT}/usr \
                --datadir=${ROOT}/${MY_DATADIR} \
                --max_allowed_packet=8M \
                --net_buffer_length=16K \
@@ -712,14 +711,14 @@ mysql-v2_pkg_config() {
        ebegin "Setting root password"
        # Do this from memory, as we don't want clear text passwords in temp files
        local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
-       "${ROOT}/usr/bin/mysql" \
+       "${EROOT}/usr/bin/mysql" \
                --socket=${socket} \
                -hlocalhost \
                -e "${sql}"
        eend $?
 
        ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
-       "${ROOT}/usr/bin/mysql" \
+       "${EROOT}/usr/bin/mysql" \
                --socket=${socket} \
                -hlocalhost \
                -uroot \
@@ -742,5 +741,5 @@ mysql-v2_pkg_config() {
 # Remove mysql symlinks.
 mysql-v2_pkg_postrm() {
 
-       : # mysql_lib_symlinks "${D}"
+       : # mysql_lib_symlinks "${ED}"
 }
index 78b482b383f228d74b3970a1b61577790e6bed46..fb949dae299f29b95801c1ba613ebd8b32c45c71 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.166 2011/09/25 12:43:28 grobian Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.167 2012/01/06 21:32:48 jmbsvicetto Exp $
 
 # @ECLASS: mysql.eclass
 # @MAINTAINER:
@@ -127,7 +127,7 @@ PERCONA_VER="${PERCONA_VER}"
 # Be warned, *DEPEND are version-dependant
 # These are used for both runtime and compiletime
 DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
-               userland_GNU? ( sys-process/procps )
+               kernel_linux? ( sys-process/procps )
                >=sys-apps/sed-4
                >=sys-apps/texinfo-4.7-r1
                >=sys-libs/readline-4.1
@@ -364,21 +364,21 @@ mysql_disable_test() {
 # Initialize global variables
 # 2005-11-19 <vivo@gentoo.org>
 mysql_init_vars() {
-       MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"}
-       MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
-       MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"}
-       MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
-       MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"}
-       MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"}
+       MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
+       MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
+       MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
+       MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
+       MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
+       MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
 
        if [[ -z "${MY_DATADIR}" ]] ; then
                MY_DATADIR=""
-               if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
+               if [[ -f ${MY_SYSCONFDIR}/my.cnf ]] ; then
                        MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
                                | sed -ne '/datadir/s|^--datadir=||p' \
                                | tail -n1`
                        if [[ -z "${MY_DATADIR}" ]] ; then
-                               MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
+                               MY_DATADIR=`grep ^datadir ${MY_SYSCONFDIR}/my.cnf \
                                | sed -e 's/.*=\s*//' \
                                | tail -n1`
                        fi
@@ -460,7 +460,7 @@ configure_common() {
        myconf="${myconf} --with-extra-charsets=all"
        myconf="${myconf} --with-mysqld-user=mysql"
        myconf="${myconf} --with-server"
-       myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock"
+       myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
        myconf="${myconf} --without-libwrap"
 
        if use static ; then
@@ -505,12 +505,13 @@ configure_common() {
 }
 
 configure_40_41_50() {
+       myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr"
        myconf="${myconf} $(use_with perl bench)"
        myconf="${myconf} --enable-assembler"
        myconf="${myconf} --with-extra-tools"
        myconf="${myconf} --with-innodb"
        myconf="${myconf} --without-readline"
-       myconf="${myconf} $(use_with ssl openssl)"
+       myconf="${myconf} $(use_with ssl openssl "${EPREFIX}/usr")"
        mysql_version_is_at_least "5.0" || myconf="${myconf} $(use_with raid)"
 
        # --with-vio is not needed anymore, it's on by default and
@@ -586,13 +587,13 @@ configure_51() {
        # TODO: !!!! readd --without-readline
        # the failure depend upon config/ac-macros/readline.m4 checking into
        # readline.h instead of history.h
-       myconf="${myconf} $(use_with ssl ssl /usr)"
+       myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
        myconf="${myconf} --enable-assembler"
        myconf="${myconf} --with-geometry"
        myconf="${myconf} --with-readline"
-       myconf="${myconf} --with-zlib-dir=/usr/"
+       myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
        myconf="${myconf} --without-pstack"
-       myconf="${myconf} --with-plugindir=/usr/$(get_libdir)/mysql/plugin"
+       myconf="${myconf} --with-plugindir=${EPREFIX}/usr/$(get_libdir)/mysql/plugin"
 
        # This is an explict die here, because if we just forcibly disable it, then the
        # user's data is not accessible.
@@ -743,7 +744,7 @@ pbxt_src_configure() {
        eautoreconf
 
        local myconf=""
-       myconf="${myconf} --with-mysql=${S} --libdir=/usr/$(get_libdir)"
+       myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
        use debug && myconf="${myconf} --with-debug=full"
        econf ${myconf} || die "Problem configuring PBXT storage engine"
 }
@@ -839,8 +840,9 @@ mysql_pkg_setup() {
        # But only for 5.0.8[3-6]!
        if mysql_version_is_at_least "5.0.83"  && ! mysql_version_is_at_least 5.0.87 ; then
                GCC_VER=$(gcc-version)
-               case ${GCC_VER} in
-                       2*|3*|4.0|4.1|4.2)
+               case ${CHOST}:${GCC_VER} in
+                       *-darwin*:4.*) : ;; # bug #310615
+                       *:2*|*:3*|*:4.0|*:4.1|*:4.2)
                        eerror "Some releases of MySQL required a very new GCC, and then"
                        eerror "later release relaxed that requirement again. Either pick a"
                        eerror "MySQL >=5.0.87, or use a newer GCC."
@@ -978,14 +980,14 @@ mysql_src_prepare() {
        && use berkdb ; then
                einfo "Fixing up berkdb buildsystem"
                [[ -w "bdb/dist/ltmain.sh" ]] && cp -f "ltmain.sh" "bdb/dist/ltmain.sh"
-               cp -f "/usr/share/aclocal/libtool.m4" "bdb/dist/aclocal/libtool.ac" \
+               cp -f "${EPREFIX}/usr/share/aclocal/libtool.m4" "bdb/dist/aclocal/libtool.ac" \
                || die "Could not copy libtool.m4 to bdb/dist/"
                #These files exist only with libtool-2*, and need to be included.
-               if [ -f '/usr/share/aclocal/ltsugar.m4' ]; then
-                       cat "/usr/share/aclocal/ltsugar.m4" >>  "bdb/dist/aclocal/libtool.ac"
-                       cat "/usr/share/aclocal/ltversion.m4" >>  "bdb/dist/aclocal/libtool.ac"
-                       cat "/usr/share/aclocal/lt~obsolete.m4" >>  "bdb/dist/aclocal/libtool.ac"
-                       cat "/usr/share/aclocal/ltoptions.m4" >>  "bdb/dist/aclocal/libtool.ac"
+               if [ -f ${EPREFIX}'/usr/share/aclocal/ltsugar.m4' ]; then
+                       cat "${EPREFIX}/usr/share/aclocal/ltsugar.m4" >>  "bdb/dist/aclocal/libtool.ac"
+                       cat "${EPREFIX}/usr/share/aclocal/ltversion.m4" >>  "bdb/dist/aclocal/libtool.ac"
+                       cat "${EPREFIX}/usr/share/aclocal/lt~obsolete.m4" >>  "bdb/dist/aclocal/libtool.ac"
+                       cat "${EPREFIX}/usr/share/aclocal/ltoptions.m4" >>  "bdb/dist/aclocal/libtool.ac"
                fi
                pushd "bdb/dist" &>/dev/null
                sh s_all \
@@ -1046,12 +1048,12 @@ mysql_src_configure() {
                filter-flags -fomit-frame-pointer
 
        econf \
-               --libexecdir="/usr/sbin" \
-               --sysconfdir="${MY_SYSCONFDIR}" \
-               --localstatedir="${MY_LOCALSTATEDIR}" \
-               --sharedstatedir="${MY_SHAREDSTATEDIR}" \
-               --libdir="${MY_LIBDIR}" \
-               --includedir="${MY_INCLUDEDIR}" \
+               --libexecdir="${EPREFIX}"/usr/sbin \
+               --sysconfdir=${MY_SYSCONFDIR} \
+               --localstatedir=${MY_LOCALSTATEDIR} \
+               --sharedstatedir=${MY_SHAREDSTATEDIR} \
+               --libdir=${MY_LIBDIR} \
+               --includedir=${MY_INCLUDEDIR} \
                --with-low-memory \
                --with-client-ldflags=-lstdc++ \
                --enable-thread-safe-client \
@@ -1096,7 +1098,7 @@ mysql_src_install() {
 
        emake install \
                DESTDIR="${D}" \
-               benchdir_root="${MY_SHAREDSTATEDIR}" \
+               benchdir_root=${MY_SHAREDSTATEDIR} \
                testroot="${MY_SHAREDSTATEDIR}" \
                || die "emake install failed"
 
@@ -1112,7 +1114,7 @@ mysql_src_install() {
 
        # Various junk (my-*.cnf moved elsewhere)
        einfo "Removing duplicate /usr/share/mysql files"
-       rm -Rf "${D}/usr/share/info"
+       rm -Rf "${ED}/usr/share/info"
        for removeme in  "mysql-log-rotate" mysql.server* \
                binary-configure* my-*.cnf mi_test_all*
        do
@@ -1123,8 +1125,8 @@ mysql_src_install() {
        if use minimal ; then
                einfo "Remove all extra content for minimal build"
                rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
-               rm -f "${D}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
-               rm -f "${D}/usr/sbin/mysqld"
+               rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
+               rm -f "${ED}/usr/sbin/mysqld"
                rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
        fi
 
@@ -1142,12 +1144,16 @@ mysql_src_install() {
                5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
        esac
        einfo "Building default my.cnf (${mysql_mycnf_version})"
-       insinto "${MY_SYSCONFDIR}"
+       insinto "${MY_SYSCONFDIR#${EPREFIX}}"
        doins scripts/mysqlaccess.conf
        mycnf_src="my.cnf-${mysql_mycnf_version}"
        sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
+               -e "s!/tmp!${EPREFIX}/tmp!" \
+               -e "s!/usr!${EPREFIX}/usr!" \
+               -e "s!= /var!= ${EPREFIX}/var!" \
                "${FILESDIR}/${mycnf_src}" \
                > "${TMPDIR}/my.cnf.ok"
+       use prefix && sed -i -e '/^user[        ]*= mysql$/d' "${TMPDIR}/my.cnf.ok"
        if use latin1 ; then
                sed -i \
                        -e "/character-set/s|utf8|latin1|g" \
@@ -1161,16 +1167,16 @@ mysql_src_install() {
                # Empty directories ...
                diropts "-m0750"
                if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
-                       dodir "${MY_DATADIR}"
-                       keepdir "${MY_DATADIR}"
+                       dodir "${MY_DATADIR#${EPREFIX}}"
+                       keepdir "${MY_DATADIR#${EPREFIX}}"
                        chown -R mysql:mysql "${D}/${MY_DATADIR}"
                fi
 
                diropts "-m0755"
-               for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
+               for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
                        dodir "${folder}"
                        keepdir "${folder}"
-                       chown -R mysql:mysql "${D}/${folder}"
+                       chown -R mysql:mysql "${ED}/${folder}"
                done
        fi
 
@@ -1200,7 +1206,7 @@ mysql_src_install() {
 
        fi
 
-       mysql_lib_symlinks "${D}"
+       mysql_lib_symlinks "${ED}"
 }
 
 # @FUNCTION: mysql_pkg_preinst
@@ -1224,7 +1230,7 @@ mysql_pkg_postinst() {
        mysql_init_vars
 
        # Check FEATURES="collision-protect" before removing this
-       [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
+       [[ -d "${EROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
 
        # Secure the logfiles
        touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
@@ -1325,8 +1331,8 @@ mysql_pkg_config() {
        local pwd2="b"
        local maxtry=15
 
-       if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then
-               MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")"
+       if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then
+               MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")"
        fi
 
        if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
@@ -1367,7 +1373,7 @@ mysql_pkg_config() {
        help_tables="${TMPDIR}/fill_help_tables.sql"
 
        pushd "${TMPDIR}" &>/dev/null
-       "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1
+       "${EROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1
        if [ $? -ne 0 ]; then
                grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
                die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
@@ -1380,7 +1386,7 @@ mysql_pkg_config() {
 
        # Figure out which options we need to disable to do the setup
        helpfile="${TMPDIR}/mysqld-help"
-       ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
+       ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
        for opt in grant-tables host-cache name-resolve networking slave-start bdb \
                federated innodb ssl log-bin relay-log slow-query-log external-locking \
                ndbcluster \
@@ -1395,7 +1401,7 @@ mysql_pkg_config() {
        if mysql_version_is_at_least "4.1.3" ; then
                # Filling timezones, see
                # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
-               "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
+               "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
 
                if [[ -r "${help_tables}" ]] ; then
                        cat "${help_tables}" >> "${sqltmp}"
@@ -1405,12 +1411,14 @@ mysql_pkg_config() {
        einfo "Creating the mysql database and setting proper"
        einfo "permissions on it ..."
 
-       local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
-       local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
-       local mysqld="${ROOT}/usr/sbin/mysqld \
+       use prefix || options="${options} --user=mysql"
+
+       local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
+       local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
+       local mysqld="${EROOT}/usr/sbin/mysqld \
                ${options} \
                --user=mysql \
-               --basedir=${ROOT}/usr \
+               --basedir=${EROOT}/usr \
                --datadir=${ROOT}/${MY_DATADIR} \
                --max_allowed_packet=8M \
                --net_buffer_length=16K \
@@ -1435,14 +1443,14 @@ mysql_pkg_config() {
        ebegin "Setting root password"
        # Do this from memory, as we don't want clear text passwords in temp files
        local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
-       "${ROOT}/usr/bin/mysql" \
+       "${EROOT}/usr/bin/mysql" \
                --socket=${socket} \
                -hlocalhost \
                -e "${sql}"
        eend $?
 
        ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
-       "${ROOT}/usr/bin/mysql" \
+       "${EROOT}/usr/bin/mysql" \
                --socket=${socket} \
                -hlocalhost \
                -uroot \
@@ -1464,5 +1472,5 @@ mysql_pkg_config() {
 # @DESCRIPTION:
 # Remove mysql symlinks.
 mysql_pkg_postrm() {
-       : # mysql_lib_symlinks "${D}"
+       : # mysql_lib_symlinks "${ED}"
 }
index 49d001259df287dcb4613adace06cd820a0b1eee..172a3d00281372a3a5b76d7beb156939ed217277 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.27 2011/12/27 17:55:12 fauli Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.28 2012/01/06 21:32:48 jmbsvicetto Exp $
 
 # Author: Francesco Riosa (Retired) <vivo@gentoo.org>
 # Maintainer:
@@ -205,14 +205,32 @@ mysql_lib_symlinks() {
                        libnameln=${libname##*/}
                        # loop in version of the library to link it, similar to how
                        # libtool works
-                       while [[ ${libnameln:0-3} != '${libsuffix}' ]] && [[ ${maxdots} -lt 6 ]] ; do
+                       if [[ ${CHOST} == *-darwin* ]] ; then
+                               # macho: libname.x.y.z.dylib
+                               local libbasename=${libnameln%%.*}       # libname
+                               local libver=${libnameln#${libbasename}} # .x.y.z.dylib
+                               libver=${libver%${libsuffix}}            # .x.y.z
+                               while [[ -n ${libver} ]] && [[ ${maxdots} -lt 6 ]] ; do
+                                       libnameln="${libbasename}${libver}${libsuffix}"
+                                       rm -f "${libnameln}"
+                                       ln -s "${libname}" "${libnameln}"
+                                       (( ++maxdots ))
+                                       libver=${libver%.*}
+                               done
+                               libnameln="${libbasename}${libsuffix}"
                                rm -f "${libnameln}"
                                ln -s "${libname}" "${libnameln}"
-                               (( ++maxdots ))
-                               libnameln="${libnameln%.*}"
-                       done
-                       rm -f "${libnameln}"
-                       ln -s "${libname}" "${libnameln}"
+                       else
+                               # elf: libname.so.x.y.z
+                               while [[ ${libnameln:0-3} != '${libsuffix}' ]] && [[ ${maxdots} -lt 6 ]] ; do
+                                       rm -f "${libnameln}"
+                                       ln -s "${libname}" "${libnameln}"
+                                       (( ++maxdots ))
+                                       libnameln="${libnameln%.*}"
+                               done
+                               rm -f "${libnameln}"
+                               ln -s "${libname}" "${libnameln}"
+                       fi
                done
        done
 
@@ -225,12 +243,12 @@ mysql_lib_symlinks() {
 # Initialize global variables
 # 2005-11-19 <vivo@gentoo.org>
 mysql_init_vars() {
-       MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"}
-       MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
-       MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
-       MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"}
-       MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"}
-       MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"}
+       MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
+       MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
+       MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
+       MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
+       MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
+       MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
 
        if [[ -z "${MY_DATADIR}" ]] ; then
                MY_DATADIR=""
@@ -272,7 +290,6 @@ mysql_init_vars() {
                                ewarn "MySQL MY_DATADIR has changed"
                                ewarn "from ${MY_DATADIR}"
                                ewarn "to ${new_MY_DATADIR}"
-                               MY_DATADIR="${new_MY_DATADIR}"
                        fi
                fi
        fi