From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id CD5E2138010 for ; Thu, 1 Nov 2012 20:20:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 25040E04EC; Thu, 1 Nov 2012 20:20:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 75FD2E04EC for ; Thu, 1 Nov 2012 20:20:16 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8B18733D918 for ; Thu, 1 Nov 2012 20:20:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 26B35E5447 for ; Thu, 1 Nov 2012 20:20:14 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1351801169.f73d71536e2fa0c17c523b3b57c4dfe488b63ad5.robbat2@gentoo> Subject: [gentoo-commits] proj/mysql:master commit in: eclass/ X-VCS-Repository: proj/mysql X-VCS-Files: eclass/mysql-v2.eclass eclass/mysql.eclass X-VCS-Directories: eclass/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: f73d71536e2fa0c17c523b3b57c4dfe488b63ad5 X-VCS-Branch: master Date: Thu, 1 Nov 2012 20:20:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 2096feb8-4e98-4e43-8949-e7b18370a42a X-Archives-Hash: 2fe83d3cd810e8c75462d5d0e0a36687 commit: f73d71536e2fa0c17c523b3b57c4dfe488b63ad5 Author: Robin H. Johnson gentoo org> AuthorDate: Thu Nov 1 20:13:25 2012 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Thu Nov 1 20:19:29 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/mysql.git;a=commit;h=f73d7153 Bring in improved pkg_config block to fix bug #392361. --- eclass/mysql-v2.eclass | 94 +++++++++++++++++++++++++++++++++++++----------- eclass/mysql.eclass | 92 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 144 insertions(+), 42 deletions(-) diff --git a/eclass/mysql-v2.eclass b/eclass/mysql-v2.eclass index 4c8d635..685b444 100644 --- a/eclass/mysql-v2.eclass +++ b/eclass/mysql-v2.eclass @@ -528,12 +528,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 @@ -547,10 +570,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}" @@ -574,8 +597,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 @@ -606,7 +648,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" @@ -614,33 +656,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 @@ -657,6 +707,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 \ @@ -666,6 +717,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 @@ -693,7 +745,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 f14023a..9ead224 100644 --- a/eclass/mysql.eclass +++ b/eclass/mysql.eclass @@ -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 $?