diff options
-rw-r--r-- | eclass/ChangeLog | 11 | ||||
-rw-r--r-- | eclass/mysql-v2.eclass | 96 | ||||
-rw-r--r-- | eclass/mysql.eclass | 104 |
3 files changed, 161 insertions, 50 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index 1b4cc7886a51..f83b1b36f22c 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for eclass directory # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.494 2012/11/01 12:19:22 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.495 2012/11/01 20:22:57 robbat2 Exp $ + + 01 Nov 2012; Robin H. Johnson <robbat2@gentoo.org> mysql.eclass, + mysql-v2.eclass: + Bug #392361: Fix mysql_install_db cases to work between all versions & + variations of MySQL. Also add in checks for tmpdir/log-bin/relay-log + directories that must exist otherwise the install_db will fail. 01 Nov 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass: Export PYTHONPATH for phases in out-of-source builds. @@ -280,6 +286,9 @@ Fixed tc-ninja_magic_to_arch() to also use KV_FULL and fail if no kernel version specified, bug 432390 + 08 Oct 2012; Robin H. Johnson <robbat2@gentoo.org> db.eclass: + Fix typo in src_test runner: makeopts_jobs not makeopts_job. + 27 Sep 2012; Ian Stakenvicius <axs@gentoo.org> eutils.eclass: Made 'usex' declaration conditional on lack of PM or EAPI5+ support diff --git a/eclass/mysql-v2.eclass b/eclass/mysql-v2.eclass index 0fd86447f01f..f98c5dba971b 100644 --- a/eclass/mysql-v2.eclass +++ b/eclass/mysql-v2.eclass @@ -1,6 +1,6 @@ # 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.19 2012/09/27 16:35:41 axs Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.20 2012/11/01 20:22:57 robbat2 Exp $ # @ECLASS: mysql-v2.eclass # @MAINTAINER: @@ -514,12 +514,35 @@ mysql-v2_pkg_postinst() { && elog "Berkeley DB support is deprecated and will be removed in future versions!" } +# @FUNCTION: mysql-v2_getopt +# @DESCRIPTION: +# Use my_print_defaults to extract specific config options +mysql-v2_getopt() { + local mypd="${EROOT}"/usr/bin/my_print_defaults + section="$1" + flag="--${2}=" + "${mypd}" $section | sed -n "/^${flag}/p" +} + +# @FUNCTION: mysql-v2_getoptval +# @DESCRIPTION: +# Use my_print_defaults to extract specific config options +mysql-v2_getoptval() { + local mypd="${EROOT}"/usr/bin/my_print_defaults + section="$1" + flag="--${2}=" + "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp" +} + # @FUNCTION: mysql-v2_pkg_config # @DESCRIPTION: # Configure mysql environment. mysql-v2_pkg_config() { local old_MY_DATADIR="${MY_DATADIR}" + local old_HOME="${HOME}" + # my_print_defaults needs to read stuff in $HOME/.my.cnf + export HOME=/root # Make sure the vars are correctly initialized mysql_init_vars @@ -533,10 +556,10 @@ mysql-v2_pkg_config() { if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then local MY_DATADIR_s="${ROOT}/${MY_DATADIR}" MY_DATADIR_s="${MY_DATADIR_s%%/}" - local old_MY_DATADIR_s="${ROOT}/old_MY_DATADIR}" + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" - if [[ -d "${old_MY_DATADIR_s}" ]]; then + if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then if [[ -d "${MY_DATADIR_s}" ]]; then ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" @@ -560,8 +583,27 @@ mysql-v2_pkg_config() { local pwd2="b" local maxtry=15 - 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")" + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)" + fi + MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR + fi + if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN + fi + if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG fi if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then @@ -592,7 +634,7 @@ mysql-v2_pkg_config() { unset pwd1 pwd2 fi - local options="" + local options="--log-warnings=0" local sqltmp="$(emktemp)" local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" @@ -600,33 +642,41 @@ mysql-v2_pkg_config() { && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ || touch "${TMPDIR}/fill_help_tables.sql" help_tables="${TMPDIR}/fill_help_tables.sql" - - pushd "${TMPDIR}" &>/dev/null - "${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 ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" - fi - popd &>/dev/null - [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ - || die "MySQL databases not installed" - chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null - chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null - + # Figure out which options we need to disable to do the setup helpfile="${TMPDIR}/mysqld-help" ${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 \ + ndbcluster log-slave-updates \ ; do - optexp="--(skip-)?${opt}" optfull="--skip-${opt}" + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" done # But some options changed names egrep -sq external-locking "${helpfile}" && \ options="${options/skip-locking/skip-external-locking}" + use prefix || options="${options} --user=mysql" + + pushd "${TMPDIR}" &>/dev/null + #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}" + cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db + [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db + cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}" + einfo "Command: $cmd" + eval $cmd \ + >"${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 ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" + fi + popd &>/dev/null + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ + || die "MySQL databases not installed" + chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null + chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null + # Filling timezones, see # http://dev.mysql.com/doc/mysql/en/time-zone-support.html "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null @@ -643,6 +693,7 @@ mysql-v2_pkg_config() { local mysqld="${EROOT}/usr/sbin/mysqld \ ${options} \ --user=mysql \ + --log-warnings=0 \ --basedir=${EROOT}/usr \ --datadir=${ROOT}/${MY_DATADIR} \ --max_allowed_packet=8M \ @@ -652,6 +703,7 @@ mysql-v2_pkg_config() { --pid-file=${pidfile}" #einfo "About to start mysqld: ${mysqld}" ebegin "Starting mysqld" + einfo "Command ${mysqld}" ${mysqld} & rc=$? while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do @@ -679,7 +731,7 @@ mysql-v2_pkg_config() { --socket=${socket} \ -hlocalhost \ -uroot \ - -p"${MYSQL_ROOT_PASSWORD}" \ + --password="${MYSQL_ROOT_PASSWORD}" \ mysql < "${sqltmp}" rc=$? eend $? diff --git a/eclass/mysql.eclass b/eclass/mysql.eclass index 0448cbe9d78f..18367624f54d 100644 --- a/eclass/mysql.eclass +++ b/eclass/mysql.eclass @@ -1,6 +1,6 @@ # 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.175 2012/09/27 16:35:41 axs Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.176 2012/11/01 20:22:57 robbat2 Exp $ # @ECLASS: mysql.eclass # @MAINTAINER: @@ -714,7 +714,7 @@ configure_51() { if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then use pbxt \ - && plugins_dyn="${plugins_dyn} pbxt" \ + && plugins_sta="${plugins_sta} pbxt" \ || plugins_dis="${plugins_dis} pbxt" fi @@ -1269,10 +1269,10 @@ mysql_pkg_postinst() { fi if pbxt_available && use pbxt ; then - # TODO: explain it better - elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" - elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" - elog "if, after that, you cannot start the MySQL server," + elog "Note: PBXT is now statically built when enabled." + elog "" + elog "If, you previously installed as a plugin and " + elog "you cannot start the MySQL server," elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" elog "use the MySQL upgrade script to restore the table" elog "or execute the following SQL command:" @@ -1288,11 +1288,34 @@ mysql_pkg_postinst() { && elog "Berkeley DB support is deprecated and will be removed in future versions!" } +# @FUNCTION: mysql_getopt +# @DESCRIPTION: +# Use my_print_defaults to extract specific config options +mysql_getopt() { + local mypd="${EROOT}"/usr/bin/my_print_defaults + section="$1" + flag="--${2}=" + "${mypd}" $section | sed -n "/^${flag}/p" +} + +# @FUNCTION: mysql_getoptval +# @DESCRIPTION: +# Use my_print_defaults to extract specific config options +mysql_getoptval() { + local mypd="${EROOT}"/usr/bin/my_print_defaults + section="$1" + flag="--${2}=" + "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp" +} + # @FUNCTION: mysql_pkg_config # @DESCRIPTION: # Configure mysql environment. mysql_pkg_config() { local old_MY_DATADIR="${MY_DATADIR}" + local old_HOME="${HOME}" + # my_print_defaults needs to read stuff in $HOME/.my.cnf + export HOME=/root # Make sure the vars are correctly initialized mysql_init_vars @@ -1309,7 +1332,7 @@ mysql_pkg_config() { local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" - if [[ -d "${old_MY_DATADIR_s}" ]]; then + if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then if [[ -d "${MY_DATADIR_s}" ]]; then ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" @@ -1333,8 +1356,27 @@ mysql_pkg_config() { local pwd2="b" local maxtry=15 - 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")" + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + MYSQL_ROOT_PASSWORD="$(mysql_getoptval 'client mysql' password)" + fi + MYSQL_TMPDIR="$(mysql_getoptval mysqld tmpdir)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(mysql_getoptval mysqld relay-log)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(mysql_getoptval mysqld log-bin)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR + fi + if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN + fi + if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG fi if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then @@ -1365,7 +1407,7 @@ mysql_pkg_config() { unset pwd1 pwd2 fi - local options="" + local options="--log-warnings=0" local sqltmp="$(emktemp)" local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" @@ -1374,32 +1416,40 @@ mysql_pkg_config() { || touch "${TMPDIR}/fill_help_tables.sql" help_tables="${TMPDIR}/fill_help_tables.sql" - pushd "${TMPDIR}" &>/dev/null - "${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" - fi - popd &>/dev/null - [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ - || die "MySQL databases not installed" - chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null - chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null - # Figure out which options we need to disable to do the setup helpfile="${TMPDIR}/mysqld-help" ${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 \ + ndbcluster log-slave-updates \ ; do - optexp="--(skip-)?${opt}" optfull="--skip-${opt}" + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" done # But some options changed names egrep -sq external-locking "${helpfile}" && \ options="${options/skip-locking/skip-external-locking}" + use prefix || options="${options} --user=mysql" + + pushd "${TMPDIR}" &>/dev/null + #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}" + cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db + [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db + cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}" + einfo "Command: $cmd" + eval $cmd \ + >"${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 ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" + fi + popd &>/dev/null + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ + || die "MySQL databases not installed" + chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null + chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null + if mysql_version_is_at_least "4.1.3" ; then # Filling timezones, see # http://dev.mysql.com/doc/mysql/en/time-zone-support.html @@ -1413,13 +1463,12 @@ mysql_pkg_config() { einfo "Creating the mysql database and setting proper" einfo "permissions on it ..." - 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 \ + --log-warnings=0 \ --basedir=${EROOT}/usr \ --datadir=${ROOT}/${MY_DATADIR} \ --max_allowed_packet=8M \ @@ -1429,6 +1478,7 @@ mysql_pkg_config() { --pid-file=${pidfile}" #einfo "About to start mysqld: ${mysqld}" ebegin "Starting mysqld" + einfo "Command ${mysqld}" ${mysqld} & rc=$? while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do @@ -1456,7 +1506,7 @@ mysql_pkg_config() { --socket=${socket} \ -hlocalhost \ -uroot \ - -p"${MYSQL_ROOT_PASSWORD}" \ + --password="${MYSQL_ROOT_PASSWORD}" \ mysql < "${sqltmp}" rc=$? eend $? |