/[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.12 Revision 1.21
1# Copyright 1999-2012 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.12 2012/01/06 21:32:48 jmbsvicetto Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.21 2012/11/01 23:57:50 robbat2 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>
13# The mysql-v2.eclass is the base eclass to build the mysql and 13# The mysql-v2.eclass is the base eclass to build the mysql and
14# alternative projects (mariadb) ebuilds. 14# alternative projects (mariadb) ebuilds.
15# This eclass uses the mysql-autotools and mysql-cmake eclasses for the 15# This eclass uses the mysql-autotools and mysql-cmake eclasses for the
16# specific bits related to the build system. 16# specific bits related to the build system.
17# It provides the src_unpack, src_prepare, src_configure, src_compile, 17# It provides the src_unpack, src_prepare, src_configure, src_compile,
18# scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm 18# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
19# phase hooks. 19# phase hooks.
20 20
21# @ECLASS-VARIABLE: BUILD 21# @ECLASS-VARIABLE: BUILD
22# @DESCRIPTION: 22# @DESCRIPTION:
23# Build type of the mysql version 23# Build type of the mysql version
51# 51#
52# Supported EAPI versions and export functions 52# Supported EAPI versions and export functions
53# 53#
54 54
55case "${EAPI:-0}" in 55case "${EAPI:-0}" in
56 3|4) ;; 56 3|4|5) ;;
57 *) die "Unsupported EAPI: ${EAPI}" ;; 57 *) die "Unsupported EAPI: ${EAPI}" ;;
58esac 58esac
59 59
60EXPORT_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
61 61
77# @DESCRIPTION: 77# @DESCRIPTION:
78# Upstream MySQL considers the first two parts of the version number to be the 78# Upstream MySQL considers the first two parts of the version number to be the
79# major version. Upgrades that change major version should always run 79# major version. Upgrades that change major version should always run
80# mysql_upgrade. 80# mysql_upgrade.
81MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" 81MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
82
83# Cluster is a special case...
84if [[ "${PN}" == "mysql-cluster" ]]; then
85 case $PV in
86 6.1*|7.0*|7.1*) MYSQL_PV_MAJOR=5.1 ;;
87 esac
88fi
89
90 82
91# @ECLASS-VARIABLE: MYSQL_VERSION_ID 83# @ECLASS-VARIABLE: MYSQL_VERSION_ID
92# @DESCRIPTION: 84# @DESCRIPTION:
93# MYSQL_VERSION_ID will be: 85# MYSQL_VERSION_ID will be:
94# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] 86# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
108MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} 100MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
109 101
110# This eclass should only be used with at least mysql-5.1.50 102# This eclass should only be used with at least mysql-5.1.50
111mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50" 103mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50"
112 104
113# @ECLASS-VARIABLE: MYSQL_COMMUNITY_FEATURES
114# @DESCRIPTION:
115# Specifiy if community features are available. Possible values are 1 (yes)
116# and 0 (no).
117# Community features are available in mysql-community
118# AND in the re-merged mysql-5.0.82 and newer
119if [ "${PN}" == "mysql-community" -o "${PN}" == "mariadb" ]; then
120 MYSQL_COMMUNITY_FEATURES=1
121elif [ "${MYSQL_PV_MAJOR}" == "5.1" ]; then
122 MYSQL_COMMUNITY_FEATURES=1
123elif mysql_version_is_at_least "5.4.0"; then
124 MYSQL_COMMUNITY_FEATURES=1
125else
126 MYSQL_COMMUNITY_FEATURES=0
127fi
128
129
130# @ECLASS-VARIABLE: XTRADB_VER 105# @ECLASS-VARIABLE: XTRADB_VER
131# @DEFAULT_UNSET 106# @DEFAULT_UNSET
132# @DESCRIPTION: 107# @DESCRIPTION:
133# Version of the XTRADB storage engine 108# Version of the XTRADB storage engine
134 109
139 114
140# Work out the default SERVER_URI correctly 115# Work out the default SERVER_URI correctly
141if [ -z "${SERVER_URI}" ]; then 116if [ -z "${SERVER_URI}" ]; then
142 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}" 117 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
143 if [ "${PN}" == "mariadb" ]; then 118 if [ "${PN}" == "mariadb" ]; then
144 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})" 119 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${MY_PV})"
145 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}" 120 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
146 SERVER_URI=" 121 SERVER_URI="
147 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 122 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
148 http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 123 http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
149 http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 124 http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
150 http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz 125 http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz
151 http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 126 http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
152 http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 127 http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
153 " 128 "
154 # The community and cluster builds are on the mirrors
155 elif [[ "${MYSQL_COMMUNITY_FEATURES}" == "1" || ${PN} == "mysql-cluster" ]] ; then
156 if [[ "${PN}" == "mysql-cluster" ]] ; then
157 URI_DIR="MySQL-Cluster"
158 URI_FILE="mysql-cluster-gpl"
159 else 129 else
160 URI_DIR="MySQL" 130 URI_DIR="MySQL"
161 URI_FILE="mysql" 131 URI_FILE="mysql"
162 fi
163 URI_A="${URI_FILE}-${MY_PV}.tar.gz" 132 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
164 MIRROR_PV=$(get_version_component_range 1-2 ${PV}) 133 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
165 # Recently upstream switched to an archive site, and not on mirrors 134 # Recently upstream switched to an archive site, and not on mirrors
166 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A} 135 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
167 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}" 136 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
168 # The (old) enterprise source is on the primary site only
169 elif [ "${PN}" == "mysql" ]; then
170 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz"
171 fi 137 fi
172fi 138fi
173 139
174# Define correct SRC_URIs 140# Define correct SRC_URIs
175SRC_URI="${SERVER_URI}" 141SRC_URI="${SERVER_URI}"
185DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." 151DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
186HOMEPAGE="http://www.mysql.com/" 152HOMEPAGE="http://www.mysql.com/"
187if [[ "${PN}" == "mariadb" ]]; then 153if [[ "${PN}" == "mariadb" ]]; then
188 HOMEPAGE="http://mariadb.org/" 154 HOMEPAGE="http://mariadb.org/"
189 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged." 155 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
190fi
191if [[ "${PN}" == "mysql-community" ]]; then
192 DESCRIPTION="${DESCRIPTION} (obsolete, move to dev-db/mysql)"
193fi 156fi
194LICENSE="GPL-2" 157LICENSE="GPL-2"
195SLOT="0" 158SLOT="0"
196 159
197case "${BUILD}" in 160case "${BUILD}" in
204esac 167esac
205 168
206IUSE="${IUSE} latin1" 169IUSE="${IUSE} latin1"
207 170
208IUSE="${IUSE} extraengine" 171IUSE="${IUSE} extraengine"
209if [[ ${PN} != "mysql-cluster" ]] ; then
210 IUSE="${IUSE} cluster" 172IUSE="${IUSE} cluster"
211fi
212 173
213IUSE="${IUSE} max-idx-128" 174IUSE="${IUSE} max-idx-128"
214IUSE="${IUSE} berkdb" 175IUSE="${IUSE} berkdb"
215
216[[ ${MYSQL_COMMUNITY_FEATURES} == 1 ]] \
217&& IUSE="${IUSE} +community profiling" 176IUSE="${IUSE} +community profiling"
218 177
219[[ ${PN} == "mariadb" ]] \ 178[[ ${PN} == "mariadb" ]] \
179&& mysql_check_version_range "5.1.38 to 5.3.99" \
220&& IUSE="${IUSE} libevent" 180&& IUSE="${IUSE} libevent"
221 181
222[[ ${PN} == "mariadb" ]] \ 182[[ ${PN} == "mariadb" ]] \
223&& mysql_version_is_at_least "5.2" \ 183&& mysql_version_is_at_least "5.2" \
224&& IUSE="${IUSE} oqgraph" 184&& IUSE="${IUSE} oqgraph"
225 185
226[[ ${PN} == "mariadb" ]] \ 186[[ ${PN} == "mariadb" ]] \
227&& mysql_version_is_at_least "5.2.5" \ 187&& mysql_version_is_at_least "5.2.5" \
228&& IUSE="${IUSE} sphinx" 188&& IUSE="${IUSE} sphinx"
189
190if mysql_version_is_at_least "5.5"; then
191 REQUIRED_USE="tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )"
192 IUSE="${IUSE} jemalloc tcmalloc"
193fi
229 194
230mysql_version_is_at_least "5.5.7" \ 195mysql_version_is_at_least "5.5.7" \
231&& IUSE="${IUSE} systemtap" 196&& IUSE="${IUSE} systemtap"
232 197
233# 198#
244 >=sys-libs/readline-4.1 209 >=sys-libs/readline-4.1
245 >=sys-libs/zlib-1.2.3 210 >=sys-libs/zlib-1.2.3
246" 211"
247 212
248[[ ${PN} == mariadb ]] \ 213[[ ${PN} == mariadb ]] \
214&& mysql_check_version_range "5.1.38 to 5.3.99" \
249&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" 215&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
250 216
251# Having different flavours at the same time is not a good idea 217# Having different flavours at the same time is not a good idea
252for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do 218for i in "mysql" "mariadb" ; do
253 [[ ${i} == ${PN} ]] || 219 [[ ${i} == ${PN} ]] ||
254 DEPEND="${DEPEND} !dev-db/${i}" 220 DEPEND="${DEPEND} !dev-db/${i}"
255done 221done
256 222
257# prefix: first need to implement something for #196294 223# prefix: first need to implement something for #196294
262 228
263DEPEND="${DEPEND} 229DEPEND="${DEPEND}
264 virtual/yacc 230 virtual/yacc
265" 231"
266 232
267DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )" 233DEPEND="${DEPEND} static? ( sys-libs/ncurses[static-libs] )"
268 234
269# compile-time-only 235# compile-time-only
270DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 236DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
271 237
272# compile-time-only 238# compile-time-only
280[[ "${PN}" == "mariadb" ]] \ 246[[ "${PN}" == "mariadb" ]] \
281&& mysql_version_is_at_least "5.2.5" \ 247&& mysql_version_is_at_least "5.2.5" \
282&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" 248&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
283 249
284mysql_version_is_at_least "5.5.7" \ 250mysql_version_is_at_least "5.5.7" \
285&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )" 251&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )" \
252&& DEPEND="${DEPEND} kernel_linux? ( dev-libs/libaio )"
253
254mysql_version_is_at_least "5.5" \
255&& DEPEND="${DEPEND} jemalloc? ( dev-libs/jemalloc )"
256
257mysql_version_is_at_least "5.5" \
258&& DEPEND="${DEPEND} tcmalloc? ( dev-util/google-perftools )"
286 259
287# dev-perl/DBD-mysql is needed by some scripts installed by MySQL 260# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
288PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 261PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
289 262
290# For other stuff to bring us in 263# For other stuff to bring us in
291PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" 264PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
292
293 265
294# 266#
295# External patches 267# External patches
296# 268#
297 269
324 296
325 PBXT_P="pbxt-${PBXT_VERSION}" 297 PBXT_P="pbxt-${PBXT_VERSION}"
326 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" 298 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz"
327 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" 299 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
328 300
301fi
302
329 # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins 303# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
330 # vs. built outside the dir 304# vs. built outside the dir
331 if pbxt_available; then 305if pbxt_available; then
332 306
333 IUSE="${IUSE} pbxt" 307 IUSE="${IUSE} pbxt"
334 PBXT_NEWSTYLE=1 308 PBXT_NEWSTYLE=1
335 fi
336fi 309fi
337 310
338if xtradb_patch_available; then 311if xtradb_patch_available; then
339 XTRADB_P="percona-xtradb-${XTRADB_VER}" 312 XTRADB_P="percona-xtradb-${XTRADB_VER}"
340 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" 313 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz"
423 396
424 # This should come after all of the die statements 397 # This should come after all of the die statements
425 enewgroup mysql 60 || die "problem adding 'mysql' group" 398 enewgroup mysql 60 || die "problem adding 'mysql' group"
426 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" 399 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
427 400
428 if [ "${PN}" != "mysql-cluster" ] && use cluster; then 401 if use cluster; then
429 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and" 402 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
430 ewarn "5.1 series should NOT be put into production. In the near" 403 ewarn "5.1 series should NOT be put into production. In the near"
431 ewarn "future, it will be disabled from building." 404 ewarn "future, it will be disabled from building."
432 ewarn ""
433 ewarn "If you need NDB support, you should instead move to the new"
434 ewarn "mysql-cluster package that represents that upstream NDB"
435 ewarn "development."
436 fi 405 fi
437} 406}
438 407
439# @FUNCTION: mysql-v2_src_unpack 408# @FUNCTION: mysql-v2_src_unpack
440# @DESCRIPTION: 409# @DESCRIPTION:
538 elog "mysql_upgrade tool." 507 elog "mysql_upgrade tool."
539 einfo 508 einfo
540 fi 509 fi
541 510
542 if pbxt_available && use pbxt ; then 511 if pbxt_available && use pbxt ; then
543 # TODO: explain it better 512 elog "Note: PBXT is now statically built when enabled."
544 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" 513 elog ""
545 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" 514 elog "If, you previously installed as a plugin and "
546 elog "if, after that, you cannot start the MySQL server," 515 elog "you cannot start the MySQL server,"
547 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" 516 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
548 elog "use the MySQL upgrade script to restore the table" 517 elog "use the MySQL upgrade script to restore the table"
549 elog "or execute the following SQL command:" 518 elog "or execute the following SQL command:"
550 elog " CREATE TABLE IF NOT EXISTS plugin (" 519 elog " CREATE TABLE IF NOT EXISTS plugin ("
551 elog " name char(64) binary DEFAULT '' NOT NULL," 520 elog " name char(64) binary DEFAULT '' NOT NULL,"
557 mysql_check_version_range "4.0 to 5.0.99.99" \ 526 mysql_check_version_range "4.0 to 5.0.99.99" \
558 && use berkdb \ 527 && use berkdb \
559 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 528 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
560} 529}
561 530
531# @FUNCTION: mysql-v2_getopt
532# @DESCRIPTION:
533# Use my_print_defaults to extract specific config options
534mysql-v2_getopt() {
535 local mypd="${EROOT}"/usr/bin/my_print_defaults
536 section="$1"
537 flag="--${2}="
538 "${mypd}" $section | sed -n "/^${flag}/p"
539}
540
541# @FUNCTION: mysql-v2_getoptval
542# @DESCRIPTION:
543# Use my_print_defaults to extract specific config options
544mysql-v2_getoptval() {
545 local mypd="${EROOT}"/usr/bin/my_print_defaults
546 section="$1"
547 flag="--${2}="
548 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
549}
550
562# @FUNCTION: mysql-v2_pkg_config 551# @FUNCTION: mysql-v2_pkg_config
563# @DESCRIPTION: 552# @DESCRIPTION:
564# Configure mysql environment. 553# Configure mysql environment.
565mysql-v2_pkg_config() { 554mysql-v2_pkg_config() {
566 555
567 local old_MY_DATADIR="${MY_DATADIR}" 556 local old_MY_DATADIR="${MY_DATADIR}"
557 local old_HOME="${HOME}"
558 # my_print_defaults needs to read stuff in $HOME/.my.cnf
559 export HOME=/root
568 560
569 # Make sure the vars are correctly initialized 561 # Make sure the vars are correctly initialized
570 mysql_init_vars 562 mysql_init_vars
571 563
572 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 564 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
574 if built_with_use ${CATEGORY}/${PN} minimal ; then 566 if built_with_use ${CATEGORY}/${PN} minimal ; then
575 die "Minimal builds do NOT include the MySQL server" 567 die "Minimal builds do NOT include the MySQL server"
576 fi 568 fi
577 569
578 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 570 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
579 local MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${MY_DATADIR})" 571 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
572 MY_DATADIR_s="${MY_DATADIR_s%%/}"
580 local old_MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${old_MY_DATADIR})" 573 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
574 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
581 575
582 if [[ -d "${old_MY_DATADIR_s}" ]]; then 576 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
583 if [[ -d "${MY_DATADIR_s}" ]]; then 577 if [[ -d "${MY_DATADIR_s}" ]]; then
584 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 578 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
585 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" 579 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
586 else 580 else
587 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" 581 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
601 595
602 local pwd1="a" 596 local pwd1="a"
603 local pwd2="b" 597 local pwd2="b"
604 local maxtry=15 598 local maxtry=15
605 599
606 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then 600 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
607 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")" 601 MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)"
602 fi
603 MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)"
604 # These are dir+prefix
605 MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)"
606 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
607 MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)"
608 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
609
610 if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then
611 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
612 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
613 fi
614 if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then
615 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
616 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
617 fi
618 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
619 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
620 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
608 fi 621 fi
609 622
610 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 623 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
611 ewarn "You have already a MySQL database in place." 624 ewarn "You have already a MySQL database in place."
612 ewarn "(${ROOT}/${MY_DATADIR}/*)" 625 ewarn "(${ROOT}/${MY_DATADIR}/*)"
633 fi 646 fi
634 MYSQL_ROOT_PASSWORD="${pwd1}" 647 MYSQL_ROOT_PASSWORD="${pwd1}"
635 unset pwd1 pwd2 648 unset pwd1 pwd2
636 fi 649 fi
637 650
638 local options="" 651 local options="--log-warnings=0"
639 local sqltmp="$(emktemp)" 652 local sqltmp="$(emktemp)"
640 653
641 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 654 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
642 [[ -r "${help_tables}" ]] \ 655 [[ -r "${help_tables}" ]] \
643 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 656 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
644 || touch "${TMPDIR}/fill_help_tables.sql" 657 || touch "${TMPDIR}/fill_help_tables.sql"
645 help_tables="${TMPDIR}/fill_help_tables.sql" 658 help_tables="${TMPDIR}/fill_help_tables.sql"
659
660 # Figure out which options we need to disable to do the setup
661 helpfile="${TMPDIR}/mysqld-help"
662 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
663 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
664 federated innodb ssl log-bin relay-log slow-query-log external-locking \
665 ndbcluster log-slave-updates \
666 ; do
667 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
668 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
669 done
670 # But some options changed names
671 egrep -sq external-locking "${helpfile}" && \
672 options="${options/skip-locking/skip-external-locking}"
673
674 use prefix || options="${options} --user=mysql"
646 675
647 pushd "${TMPDIR}" &>/dev/null 676 pushd "${TMPDIR}" &>/dev/null
648 "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1 677 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
678 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
679 [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db
680 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}"
681 einfo "Command: $cmd"
682 eval $cmd \
683 >"${TMPDIR}"/mysql_install_db.log 2>&1
649 if [ $? -ne 0 ]; then 684 if [ $? -ne 0 ]; then
650 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 685 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
651 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" 686 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
652 fi 687 fi
653 popd &>/dev/null 688 popd &>/dev/null
654 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 689 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
655 || die "MySQL databases not installed" 690 || die "MySQL databases not installed"
656 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 691 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
657 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 692 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
658 693
659 # Figure out which options we need to disable to do the setup
660 helpfile="${TMPDIR}/mysqld-help"
661 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
662 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
663 federated innodb ssl log-bin relay-log slow-query-log external-locking \
664 ndbcluster \
665 ; do
666 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
667 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
668 done
669 # But some options changed names
670 egrep -sq external-locking "${helpfile}" && \
671 options="${options/skip-locking/skip-external-locking}"
672
673 # Filling timezones, see 694 # Filling timezones, see
674 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 695 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
675 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null 696 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
676 697
677 if [[ -r "${help_tables}" ]] ; then 698 if [[ -r "${help_tables}" ]] ; then
684 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 705 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
685 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 706 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
686 local mysqld="${EROOT}/usr/sbin/mysqld \ 707 local mysqld="${EROOT}/usr/sbin/mysqld \
687 ${options} \ 708 ${options} \
688 --user=mysql \ 709 --user=mysql \
710 --log-warnings=0 \
689 --basedir=${EROOT}/usr \ 711 --basedir=${EROOT}/usr \
690 --datadir=${ROOT}/${MY_DATADIR} \ 712 --datadir=${ROOT}/${MY_DATADIR} \
691 --max_allowed_packet=8M \ 713 --max_allowed_packet=8M \
692 --net_buffer_length=16K \ 714 --net_buffer_length=16K \
693 --default-storage-engine=MyISAM \ 715 --default-storage-engine=MyISAM \
694 --socket=${socket} \ 716 --socket=${socket} \
695 --pid-file=${pidfile}" 717 --pid-file=${pidfile}"
696 #einfo "About to start mysqld: ${mysqld}" 718 #einfo "About to start mysqld: ${mysqld}"
697 ebegin "Starting mysqld" 719 ebegin "Starting mysqld"
720 einfo "Command ${mysqld}"
698 ${mysqld} & 721 ${mysqld} &
699 rc=$? 722 rc=$?
700 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 723 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
701 maxtry=$((${maxtry}-1)) 724 maxtry=$((${maxtry}-1))
702 echo -n "." 725 echo -n "."
720 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 743 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
721 "${EROOT}/usr/bin/mysql" \ 744 "${EROOT}/usr/bin/mysql" \
722 --socket=${socket} \ 745 --socket=${socket} \
723 -hlocalhost \ 746 -hlocalhost \
724 -uroot \ 747 -uroot \
725 -p"${MYSQL_ROOT_PASSWORD}" \ 748 --password="${MYSQL_ROOT_PASSWORD}" \
726 mysql < "${sqltmp}" 749 mysql < "${sqltmp}"
727 rc=$? 750 rc=$?
728 eend $? 751 eend $?
729 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!" 752 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
730 753

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

  ViewVC Help
Powered by ViewVC 1.1.20