summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2012-11-01 20:22:57 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2012-11-01 20:22:57 +0000
commit89db4200139c2c6774d2fa683ff0ed0f97f402a1 (patch)
treeb837ce90cff9c1a9c5d7d38762b1661b7e9f0579 /eclass/mysql-v2.eclass
parentinitial commit (diff)
downloadgentoo-2-89db4200139c2c6774d2fa683ff0ed0f97f402a1.tar.gz
gentoo-2-89db4200139c2c6774d2fa683ff0ed0f97f402a1.tar.bz2
gentoo-2-89db4200139c2c6774d2fa683ff0ed0f97f402a1.zip
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.
Diffstat (limited to 'eclass/mysql-v2.eclass')
-rw-r--r--eclass/mysql-v2.eclass96
1 files changed, 74 insertions, 22 deletions
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 $?