/[gentoo-x86]/eclass/mysql.eclass
Gentoo

Diff of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.138 Revision 1.182
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2015 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/Attic/mysql.eclass,v 1.138 2010/03/15 19:05:51 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/mysql.eclass,v 1.182 2015/05/01 12:34:31 grknight Exp $
4 4
5# @ECLASS: mysql.eclass 5# @ECLASS: mysql.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Author: Francesco Riosa (Retired) <vivo@gentoo.org>
8# Maintainers: MySQL Team <mysql-bugs@gentoo.org> 7# MySQL Team <mysql-bugs@gentoo.org>
9# - Luca Longinotti <chtekk@gentoo.org> 8# Luca Longinotti <chtekk@gentoo.org>
10# - Robin H. Johnson <robbat2@gentoo.org> 9# Robin H. Johnson <robbat2@gentoo.org>
10# @AUTHOR:
11# Francesco Riosa (Retired) <vivo@gentoo.org>
11# @BLURB: This eclass provides most of the functions for mysql ebuilds 12# @BLURB: This eclass provides most of the functions for mysql ebuilds
12# @DESCRIPTION: 13# @DESCRIPTION:
13# The mysql.eclass provides almost all the code to build the mysql ebuilds 14# The mysql.eclass provides almost all the code to build the mysql ebuilds
14# including the src_unpack, src_prepare, src_configure, src_compile, 15# including the src_unpack, src_prepare, src_configure, src_compile,
15# scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm 16# scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
16# phase hooks. 17# phase hooks.
17 18
18WANT_AUTOCONF="latest" 19WANT_AUTOCONF="latest"
19WANT_AUTOMAKE="latest" 20WANT_AUTOMAKE="latest"
20 21
21inherit eutils flag-o-matic gnuconfig autotools mysql_fx versionator toolchain-funcs 22inherit eutils flag-o-matic gnuconfig autotools multilib mysql_fx versionator toolchain-funcs
22 23
23# Shorten the path because the socket path length must be shorter than 107 chars 24# Shorten the path because the socket path length must be shorter than 107 chars
24# and we will run a mysql server during test phase 25# and we will run a mysql server during test phase
25S="${WORKDIR}/mysql" 26S="${WORKDIR}/mysql"
26 27
27[[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z" 28[[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
28if [[ "${MY_EXTRAS_VER}" == "live" ]]; then 29if [[ "${MY_EXTRAS_VER}" == "live" ]]; then
29 EGIT_PROJECT=mysql-extras
30 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git" 30 EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
31 EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
32 EGIT_CLONE_TYPE=shallow
31 inherit git 33 inherit git-r3
32fi 34fi
33 35
34case "${EAPI:-0}" in 36case "${EAPI:-0}" in
35 2) 37 2|3|4|5)
36 EXPORT_FUNCTIONS pkg_setup \ 38 EXPORT_FUNCTIONS pkg_setup \
37 src_unpack src_prepare \ 39 src_unpack src_prepare \
38 src_configure src_compile \ 40 src_configure src_compile \
39 src_install \ 41 src_install \
40 pkg_preinst pkg_postinst \ 42 pkg_preinst pkg_postinst \
59# Upstream MySQL considers the first two parts of the version number to be the 61# Upstream MySQL considers the first two parts of the version number to be the
60# major version. Upgrades that change major version should always run 62# major version. Upgrades that change major version should always run
61# mysql_upgrade. 63# mysql_upgrade.
62MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" 64MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
63 65
66# Cluster is a special case...
67if [[ "${PN}" == "mysql-cluster" ]]; then
68 case $PV in
69 6.1*|7.0*|7.1*) MYSQL_PV_MAJOR=5.1 ;;
70 esac
71fi
72
73
64# @ECLASS-VARIABLE: MYSQL_VERSION_ID 74# @ECLASS-VARIABLE: MYSQL_VERSION_ID
65# @DESCRIPTION: 75# @DESCRIPTION:
66# MYSQL_VERSION_ID will be: 76# MYSQL_VERSION_ID will be:
67# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] 77# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
68# This is an important part, because many of the choices the MySQL ebuild will do 78# This is an important part, because many of the choices the MySQL ebuild will do
95 MYSQL_COMMUNITY_FEATURES=1 105 MYSQL_COMMUNITY_FEATURES=1
96elif [ "${PV#5.4}" != "${PV}" ] ; then 106elif [ "${PV#5.4}" != "${PV}" ] ; then
97 MYSQL_COMMUNITY_FEATURES=1 107 MYSQL_COMMUNITY_FEATURES=1
98elif [ "${PV#5.5}" != "${PV}" ] ; then 108elif [ "${PV#5.5}" != "${PV}" ] ; then
99 MYSQL_COMMUNITY_FEATURES=1 109 MYSQL_COMMUNITY_FEATURES=1
100elif [ "${PV#6.0}" != "${PV}" ] ; then 110elif [ "${PV#6}" != "${PV}" ] ; then
111 MYSQL_COMMUNITY_FEATURES=1
112elif [ "${PV#7}" != "${PV}" ] ; then
101 MYSQL_COMMUNITY_FEATURES=1 113 MYSQL_COMMUNITY_FEATURES=1
102else 114else
103 MYSQL_COMMUNITY_FEATURES=0 115 MYSQL_COMMUNITY_FEATURES=0
104fi 116fi
105 117
114PERCONA_VER="${PERCONA_VER}" 126PERCONA_VER="${PERCONA_VER}"
115 127
116# Be warned, *DEPEND are version-dependant 128# Be warned, *DEPEND are version-dependant
117# These are used for both runtime and compiletime 129# These are used for both runtime and compiletime
118DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d ) 130DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
119 userland_GNU? ( sys-process/procps ) 131 kernel_linux? ( sys-process/procps )
120 >=sys-apps/sed-4 132 >=sys-apps/sed-4
121 >=sys-apps/texinfo-4.7-r1 133 >=sys-apps/texinfo-4.7-r1
122 >=sys-libs/readline-4.1 134 >=sys-libs/readline-4.1
123 >=sys-libs/zlib-1.2.3" 135 >=sys-libs/zlib-1.2.3"
124 136
125[[ "${PN}" == "mariadb" ]] \ 137[[ "${PN}" == "mariadb" ]] \
126&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" 138&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
127 139
128# Having different flavours at the same time is not a good idea 140# Having different flavours at the same time is not a good idea
129for i in "mysql" "mysql-community" "mariadb" ; do 141for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do
130 [[ "${i}" == ${PN} ]] || 142 [[ "${i}" == ${PN} ]] ||
131 DEPEND="${DEPEND} !dev-db/${i}" 143 DEPEND="${DEPEND} !dev-db/${i}"
132done 144done
133 145
146# prefix: first need to implement something for #196294
134RDEPEND="${DEPEND} 147RDEPEND="${DEPEND}
135 !minimal? ( dev-db/mysql-init-scripts ) 148 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
136 selinux? ( sec-policy/selinux-mysql )" 149 selinux? ( sec-policy/selinux-mysql )"
150
151DEPEND="${DEPEND}
152 virtual/yacc"
153
154if [ "${EAPI:-0}" = "2" ]; then
155 DEPEND="${DEPEND} static? ( sys-libs/ncurses[static-libs] )"
156fi
137 157
138# compile-time-only 158# compile-time-only
139mysql_version_is_at_least "5.1" \ 159mysql_version_is_at_least "5.1" \
140|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )" 160|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )"
141 161
142# compile-time-only 162# compile-time-only
143mysql_version_is_at_least "5.1.12" \ 163mysql_version_is_at_least "5.1.12" \
144&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 164&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
165
166[[ "${PN}" == "mariadb" ]] \
167&& mysql_version_is_at_least "5.2" \
168&& DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )"
169#SphinxSE is included but is not available in 5.2.4 due to a missing plug.in file
170# sphinx? ( app-misc/sphinx )"
145 171
146# dev-perl/DBD-mysql is needed by some scripts installed by MySQL 172# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
147PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 173PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
148 174
149# For other stuff to bring us in 175# For other stuff to bring us in
152# Work out the default SERVER_URI correctly 178# Work out the default SERVER_URI correctly
153if [ -z "${SERVER_URI}" ]; then 179if [ -z "${SERVER_URI}" ]; then
154 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}" 180 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
155 if [ "${PN}" == "mariadb" ]; then 181 if [ "${PN}" == "mariadb" ]; then
156 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})" 182 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})"
183 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
184 SERVER_URI="
185 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
186 http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
187 http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
157 SERVER_URI="http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/mariadb-${MARIA_FULL_PV}.tar.gz" 188 http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz
189 http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
190 http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
191 "
158 # The community build is on the mirrors 192 # The community and cluster builds are on the mirrors
159 elif [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then 193 elif [[ "${MYSQL_COMMUNITY_FEATURES}" == "1" || ${PN} == "mysql-cluster" ]] ; then
160 SERVER_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/mysql-${MY_PV}.tar.gz" 194 if [[ "${PN}" == "mysql-cluster" ]] ; then
195 URI_DIR="MySQL-Cluster"
196 URI_FILE="mysql-cluster-gpl"
197 else
198 URI_DIR="MySQL"
199 URI_FILE="mysql"
200 fi
201 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
202 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
203 # Recently upstream switched to an archive site, and not on mirrors
204 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
205 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
161 # The (old) enterprise source is on the primary site only 206 # The (old) enterprise source is on the primary site only
162 elif [ "${PN}" == "mysql" ]; then 207 elif [ "${PN}" == "mysql" ]; then
163 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz" 208 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz"
164 fi 209 fi
165fi 210fi
178HOMEPAGE="http://www.mysql.com/" 223HOMEPAGE="http://www.mysql.com/"
179if [[ "${PN}" == "mariadb" ]]; then 224if [[ "${PN}" == "mariadb" ]]; then
180 HOMEPAGE="http://askmonty.org/" 225 HOMEPAGE="http://askmonty.org/"
181 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged." 226 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
182fi 227fi
228if [[ "${PN}" == "mysql-community" ]]; then
229 DESCRIPTION="${DESCRIPTION} (obsolete, move to dev-db/mysql)"
230fi
183LICENSE="GPL-2" 231LICENSE="GPL-2"
184SLOT="0" 232SLOT="0"
185IUSE="big-tables debug embedded minimal ${IUSE_DEFAULT_ON}perl selinux ssl static test" 233IUSE="big-tables debug embedded minimal ${IUSE_DEFAULT_ON}perl selinux ssl static test"
186 234
187mysql_version_is_at_least "4.1" \ 235mysql_version_is_at_least "4.1" \
188&& IUSE="${IUSE} latin1" 236&& IUSE="${IUSE} latin1"
189 237
190mysql_version_is_at_least "4.1.3" \ 238if mysql_version_is_at_least "4.1.3" ; then
191&& IUSE="${IUSE} cluster extraengine" 239 IUSE="${IUSE} extraengine"
240 if [[ "${PN}" != "mysql-cluster" ]] ; then
241 IUSE="${IUSE} cluster"
242 fi
243fi
192 244
193mysql_version_is_at_least "5.0" \ 245mysql_version_is_at_least "5.0" \
194|| IUSE="${IUSE} raid" 246|| IUSE="${IUSE} raid"
195 247
196mysql_version_is_at_least "5.0.18" \ 248mysql_version_is_at_least "5.0.18" \
202[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \ 254[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \
203&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling" 255&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling"
204 256
205[[ "${PN}" == "mariadb" ]] \ 257[[ "${PN}" == "mariadb" ]] \
206&& IUSE="${IUSE} libevent" 258&& IUSE="${IUSE} libevent"
259
260[[ "${PN}" == "mariadb" ]] \
261&& mysql_version_is_at_least "5.2" \
262&& IUSE="${IUSE} oqgraph"
263#SphinxSE is included but is not available in 5.2.4 due to a missing plug.in file
264#&& IUSE="${IUSE} oqgraph sphinx"
207 265
208# MariaDB has integrated PBXT 266# MariaDB has integrated PBXT
209# PBXT_VERSION means that we have a PBXT patch for this PV 267# PBXT_VERSION means that we have a PBXT patch for this PV
210# PBXT was only introduced after 5.1.12 268# PBXT was only introduced after 5.1.12
211pbxt_patch_available() { 269pbxt_patch_available() {
229 && mysql_version_is_at_least "5.1.26" \ 287 && mysql_version_is_at_least "5.1.26" \
230 && [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]] 288 && [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]]
231 return $? 289 return $?
232} 290}
233 291
292
234pbxt_patch_available \ 293pbxt_patch_available \
235&& PBXT_P="pbxt-${PBXT_VERSION}" \ 294&& PBXT_P="pbxt-${PBXT_VERSION}" \
236&& PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" \ 295&& PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" \
237&& SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" \ 296&& SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" \
238 297
298# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
299# vs. built outside the dir
239pbxt_available \ 300pbxt_available \
240&& IUSE="${IUSE} pbxt" 301&& IUSE="${IUSE} pbxt" \
302&& mysql_version_is_at_least "5.1.40" \
303&& PBXT_NEWSTYLE=1
241 304
242xtradb_patch_available \ 305xtradb_patch_available \
243&& XTRADB_P="percona-xtradb-${XTRADB_VER}" \ 306&& XTRADB_P="percona-xtradb-${XTRADB_VER}" \
244&& XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" \ 307&& XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" \
245&& XTRADB_SRC_URI1="http://www.percona.com/percona-builds/xtradb/${XTRADB_SRC_URI_COMMON}" \ 308&& XTRADB_SRC_B1="http://www.percona.com/" \
309&& XTRADB_SRC_B2="${XTRADB_SRC_B1}/percona-builds/" \
310&& XTRADB_SRC_URI1="${XTRADB_SRC_B2}/Percona-Server/Percona-Server-${XTRADB_SRC_URI_COMMON}" \
246&& XTRADB_SRC_URI2="http://www.percona.com/${PN}/xtradb/${XTRADB_SRC_URI_COMMON}" \ 311&& XTRADB_SRC_URI2="${XTRADB_SRC_B2}/xtradb/${XTRADB_SRC_URI_COMMON}" \
312&& XTRADB_SRC_URI3="${XTRADB_SRC_B1}/${PN}/xtradb/${XTRADB_SRC_URI_COMMON}" \
247&& SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI1} ${XTRADB_SRC_URI2} )" \ 313&& SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI1} ${XTRADB_SRC_URI2} ${XTRADB_SRC_URI3} )" \
248&& IUSE="${IUSE} xtradb" 314&& IUSE="${IUSE} xtradb"
249 315
250# 316#
251# HELPER FUNCTIONS: 317# HELPER FUNCTIONS:
252# 318#
257mysql_disable_test() { 323mysql_disable_test() {
258 local rawtestname testname testsuite reason mysql_disable_file 324 local rawtestname testname testsuite reason mysql_disable_file
259 rawtestname="${1}" ; shift 325 rawtestname="${1}" ; shift
260 reason="${@}" 326 reason="${@}"
261 ewarn "test '${rawtestname}' disabled: '${reason}'" 327 ewarn "test '${rawtestname}' disabled: '${reason}'"
262 328
263 testsuite="${rawtestname/.*}" 329 testsuite="${rawtestname/.*}"
264 testname="${rawtestname/*.}" 330 testname="${rawtestname/*.}"
265 mysql_disable_file="${S}/mysql-test/t/disabled.def" 331 mysql_disable_file="${S}/mysql-test/t/disabled.def"
266 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}" 332 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
267 echo ${testname} : ${reason} >> "${mysql_disable_file}" 333 echo ${testname} : ${reason} >> "${mysql_disable_file}"
297# @DESCRIPTION: 363# @DESCRIPTION:
298# void mysql_init_vars() 364# void mysql_init_vars()
299# Initialize global variables 365# Initialize global variables
300# 2005-11-19 <vivo@gentoo.org> 366# 2005-11-19 <vivo@gentoo.org>
301mysql_init_vars() { 367mysql_init_vars() {
302 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"} 368 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
303 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"} 369 MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
304 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"} 370 MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
305 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"} 371 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
306 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"} 372 MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
307 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"} 373 MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
308 374
309 if [[ -z "${MY_DATADIR}" ]] ; then 375 if [[ -z "${MY_DATADIR}" ]] ; then
310 MY_DATADIR="" 376 MY_DATADIR=""
311 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then 377 if [[ -f ${MY_SYSCONFDIR}/my.cnf ]] ; then
312 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ 378 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
313 | sed -ne '/datadir/s|^--datadir=||p' \ 379 | sed -ne '/datadir/s|^--datadir=||p' \
314 | tail -n1` 380 | tail -n1`
315 if [[ -z "${MY_DATADIR}" ]] ; then 381 if [[ -z "${MY_DATADIR}" ]] ; then
316 MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ 382 MY_DATADIR=`grep ^datadir ${MY_SYSCONFDIR}/my.cnf \
317 | sed -e 's/.*=\s*//' \ 383 | sed -e 's/.*=\s*//' \
318 | tail -n1` 384 | tail -n1`
319 fi 385 fi
320 fi 386 fi
321 if [[ -z "${MY_DATADIR}" ]] ; then 387 if [[ -z "${MY_DATADIR}" ]] ; then
349 MY_DATADIR="${new_MY_DATADIR}" 415 MY_DATADIR="${new_MY_DATADIR}"
350 fi 416 fi
351 fi 417 fi
352 fi 418 fi
353 419
420 if [ "${MY_SOURCEDIR:-unset}" == "unset" ]; then
354 MY_SOURCEDIR=${SERVER_URI##*/} 421 MY_SOURCEDIR=${SERVER_URI##*/}
355 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*} 422 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
423 fi
356 424
357 export MY_SHAREDSTATEDIR MY_SYSCONFDIR 425 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
358 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR 426 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
359 export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR 427 export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR
360} 428}
389 457
390configure_common() { 458configure_common() {
391 myconf="${myconf} $(use_with big-tables)" 459 myconf="${myconf} $(use_with big-tables)"
392 myconf="${myconf} --enable-local-infile" 460 myconf="${myconf} --enable-local-infile"
393 myconf="${myconf} --with-extra-charsets=all" 461 myconf="${myconf} --with-extra-charsets=all"
394 myconf="${myconf} --with-mysqld-user=mysql" 462 use prefix || myconf="${myconf} --with-mysqld-user=mysql"
395 myconf="${myconf} --with-server" 463 myconf="${myconf} --with-server"
396 myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock" 464 myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
397 myconf="${myconf} --without-libwrap" 465 myconf="${myconf} --without-libwrap"
398 466
399 if use static ; then 467 if use static ; then
400 myconf="${myconf} --with-mysqld-ldflags=-all-static" 468 myconf="${myconf} --with-mysqld-ldflags=-all-static"
401 myconf="${myconf} --with-client-ldflags=-all-static" 469 myconf="${myconf} --with-client-ldflags=-all-static"
407 if use debug ; then 475 if use debug ; then
408 myconf="${myconf} --with-debug=full" 476 myconf="${myconf} --with-debug=full"
409 else 477 else
410 myconf="${myconf} --without-debug" 478 myconf="${myconf} --without-debug"
411 mysql_version_is_at_least "4.1.3" \ 479 mysql_version_is_at_least "4.1.3" \
412 && use cluster \ 480 && ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) \
413 && myconf="${myconf} --without-ndb-debug" 481 && myconf="${myconf} --without-ndb-debug"
414 fi 482 fi
415 483
416 if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then 484 if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
417 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" 485 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
436 fi 504 fi
437 505
438} 506}
439 507
440configure_40_41_50() { 508configure_40_41_50() {
509 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr"
441 myconf="${myconf} $(use_with perl bench)" 510 myconf="${myconf} $(use_with perl bench)"
442 myconf="${myconf} --enable-assembler" 511 myconf="${myconf} --enable-assembler"
443 myconf="${myconf} --with-extra-tools" 512 myconf="${myconf} --with-extra-tools"
444 myconf="${myconf} --with-innodb" 513 myconf="${myconf} --with-innodb"
445 myconf="${myconf} --without-readline" 514 myconf="${myconf} --without-readline"
446 myconf="${myconf} $(use_with ssl openssl)" 515 myconf="${myconf} $(use_with ssl openssl "${EPREFIX}/usr")"
447 mysql_version_is_at_least "5.0" || myconf="${myconf} $(use_with raid)" 516 mysql_version_is_at_least "5.0" || myconf="${myconf} $(use_with raid)"
448 517
449 # --with-vio is not needed anymore, it's on by default and 518 # --with-vio is not needed anymore, it's on by default and
450 # has been removed from configure 519 # has been removed from configure
451 # Apply to 4.x and 5.0.[0-3] 520 # Apply to 4.x and 5.0.[0-3]
474 myconf="${myconf} --without-berkeley-db" 543 myconf="${myconf} --without-berkeley-db"
475 fi 544 fi
476 545
477 if mysql_version_is_at_least "4.1.3" ; then 546 if mysql_version_is_at_least "4.1.3" ; then
478 myconf="${myconf} --with-geometry" 547 myconf="${myconf} --with-geometry"
548 if [[ "${PN}" != "mysql-cluster" ]] ; then
479 myconf="${myconf} $(use_with cluster ndbcluster)" 549 myconf="${myconf} $(use_with cluster ndbcluster)"
550 fi
480 fi 551 fi
481 552
482 if mysql_version_is_at_least "4.1.3" && use extraengine ; then 553 if mysql_version_is_at_least "4.1.3" && use extraengine ; then
483 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html 554 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html
484 myconf="${myconf} --with-archive-storage-engine" 555 myconf="${myconf} --with-archive-storage-engine"
515 586
516configure_51() { 587configure_51() {
517 # TODO: !!!! readd --without-readline 588 # TODO: !!!! readd --without-readline
518 # the failure depend upon config/ac-macros/readline.m4 checking into 589 # the failure depend upon config/ac-macros/readline.m4 checking into
519 # readline.h instead of history.h 590 # readline.h instead of history.h
520 myconf="${myconf} $(use_with ssl ssl /usr)" 591 myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
521 myconf="${myconf} --enable-assembler" 592 myconf="${myconf} --enable-assembler"
522 myconf="${myconf} --with-geometry" 593 myconf="${myconf} --with-geometry"
523 myconf="${myconf} --with-readline" 594 myconf="${myconf} --with-readline"
524 myconf="${myconf} --with-zlib-dir=/usr/" 595 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
525 myconf="${myconf} --without-pstack" 596 myconf="${myconf} --without-pstack"
597 myconf="${myconf} --with-plugindir=${EPREFIX}/usr/$(get_libdir)/mysql/plugin"
598
599 # This is an explict die here, because if we just forcibly disable it, then the
600 # user's data is not accessible.
601 use max-idx-128 && die "Bug #336027: upstream has a corruption issue with max-idx-128 presently"
526 use max-idx-128 && myconf="${myconf} --with-max-indexes=128" 602 #use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
527 if [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then 603 if [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then
528 myconf="${myconf} $(use_enable community community-features)" 604 myconf="${myconf} $(use_enable community community-features)"
529 if use community; then 605 if use community; then
530 myconf="${myconf} $(use_enable profiling)" 606 myconf="${myconf} $(use_enable profiling)"
531 else 607 else
532 myconf="${myconf} --disable-profiling" 608 myconf="${myconf} --disable-profiling"
533 fi 609 fi
534 fi 610 fi
535 611
612 # Scan for all available plugins
613 local plugins_avail="$(
614 LANG=C \
615 find "${S}" \
616 \( \
617 -name 'plug.in' \
618 -o -iname 'configure.in' \
619 -o -iname 'configure.ac' \
620 \) \
621 -print0 \
622 | xargs -0 sed -r -n \
623 -e '/^MYSQL_STORAGE_ENGINE/{
624 s~MYSQL_STORAGE_ENGINE\([[:space:]]*\[?([-_a-z0-9]+)\]?.*,~\1 ~g ;
625 s~^([^ ]+).*~\1~gp;
626 }' \
627 | tr -s '\n' ' '
628 )"
629
536 # 5.1 introduces a new way to manage storage engines (plugins) 630 # 5.1 introduces a new way to manage storage engines (plugins)
537 # like configuration=none 631 # like configuration=none
632 # This base set are required, and will always be statically built.
538 local plugins="csv,myisam,myisammrg,heap" 633 local plugins_sta="csv myisam myisammrg heap"
634 local plugins_dyn=""
635 local plugins_dis="example ibmdb2i"
636
637 # These aren't actually required by the base set, but are really useful:
638 plugins_sta="${plugins_sta} archive blackhole"
639
640 # default in 5.5.4
641 if mysql_version_is_at_least "5.5.4" ; then
642 plugins_sta="${plugins_sta} partition"
643 fi
644 # Now the extras
539 if use extraengine ; then 645 if use extraengine ; then
540 # like configuration=max-no-ndb, archive and example removed in 5.1.11 646 # like configuration=max-no-ndb, archive and example removed in 5.1.11
541 # not added yet: ibmdb2i 647 # not added yet: ibmdb2i
542 # Not supporting as examples: example,daemon_example,ftexample 648 # Not supporting as examples: example,daemon_example,ftexample
543 plugins="${plugins},archive,blackhole,federated,partition" 649 plugins_sta="${plugins_sta} partition"
544 650
545 if [[ "${PN}" != "mariadb" ]] ; then 651 if [[ "${PN}" != "mariadb" ]] ; then
546 elog "Before using the Federated storage engine, please be sure to read" 652 elog "Before using the Federated storage engine, please be sure to read"
547 elog "http://dev.mysql.com/doc/refman/5.1/en/federated-limitations.html" 653 elog "http://dev.mysql.com/doc/refman/5.1/en/federated-limitations.html"
654 plugins_dyn="${plugins_sta} federated"
548 else 655 else
549 elog "MariaDB includes the FederatedX engine. Be sure to read" 656 elog "MariaDB includes the FederatedX engine. Be sure to read"
550 elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine" 657 elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine"
658 plugins_dyn="${plugins_sta} federatedx"
551 fi 659 fi
660 else
661 plugins_dis="${plugins_dis} partition federated"
552 fi 662 fi
553 663
554 # Upstream specifically requests that InnoDB always be built: 664 # Upstream specifically requests that InnoDB always be built:
555 # - innobase, innodb_plugin 665 # - innobase, innodb_plugin
556 # Build falcon if available for 6.x series. 666 # Build falcon if available for 6.x series.
557 for i in innobase innodb_plugin falcon ; do 667 for i in innobase falcon ; do
558 [ -e "${S}"/storage/${i} ] && plugins="${plugins},${i}" 668 [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
559 done 669 done
670 for i in innodb_plugin ; do
671 [ -e "${S}"/storage/${i} ] && plugins_dyn="${plugins_dyn} ${i}"
672 done
560 673
561 # like configuration=max-no-ndb 674 # like configuration=max-no-ndb
562 if use cluster ; then 675 if ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) ; then
563 plugins="${plugins},ndbcluster" 676 plugins_sta="${plugins_sta} ndbcluster partition"
677 plugins_dis="${plugins_dis//partition}"
564 myconf="${myconf} --with-ndb-binlog" 678 myconf="${myconf} --with-ndb-binlog"
679 else
680 plugins_dis="${plugins_dis} ndbcluster"
565 fi 681 fi
566 682
567 if [[ "${PN}" == "mariadb" ]] ; then 683 if [[ "${PN}" == "mariadb" ]] ; then
568 # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not 684 # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not
569 # caught above. 685 # caught above.
570 plugins="${plugins},maria,innobase"
571 if use pbxt ; then
572 plugins="${plugins},pbxt"
573 else
574 myconf="${myconf} --without-plugin-pbxt"
575 fi
576 myconf="${myconf} $(use_with libevent)"
577 # This is not optional, without it several upstream testcases fail. 686 # This is not optional, without it several upstream testcases fail.
578 # Also strongly recommended by upstream. 687 # Also strongly recommended by upstream.
688 if [[ "${PV}" < "5.2.0" ]] ; then
579 myconf="${myconf} --with-maria-tmp-tables" 689 myconf="${myconf} --with-maria-tmp-tables"
690 plugins_sta="${plugins_sta} maria"
691 else
692 myconf="${myconf} --with-aria-tmp-tables"
693 plugins_sta="${plugins_sta} aria"
580 fi 694 fi
581 695
696 [ -e "${S}"/storage/innobase ] || [ -e "${S}"/storage/xtradb ] ||
697 die "The ${P} package doesn't provide innobase nor xtradb"
698
699 for i in innobase xtradb ; do
700 [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
701 done
702
703 myconf="${myconf} $(use_with libevent)"
704
705 if mysql_version_is_at_least "5.2" ; then
706 #This should include sphinx, but the 5.2.4 archive forgot the plug.in file
707 #for i in oqgraph sphinx ; do
708 for i in oqgraph ; do
709 use ${i} \
710 && plugins_dyn="${plugins_dyn} ${i}" \
711 || plugins_dis="${plugins_dis} ${i}"
712 done
713 fi
714 fi
715
716 if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then
717 use pbxt \
718 && plugins_sta="${plugins_sta} pbxt" \
719 || plugins_dis="${plugins_dis} pbxt"
720 fi
721
722 use static && \
723 plugins_sta="${plugins_sta} ${plugins_dyn}" && \
724 plugins_dyn=""
725
726 einfo "Available plugins: ${plugins_avail}"
727 einfo "Dynamic plugins: ${plugins_dyn}"
728 einfo "Static plugins: ${plugins_sta}"
729 einfo "Disabled plugins: ${plugins_dis}"
730
731 # These are the static plugins
582 myconf="${myconf} --with-plugins=${plugins}" 732 myconf="${myconf} --with-plugins=${plugins_sta// /,}"
733 # And the disabled ones
734 for i in ${plugins_dis} ; do
735 myconf="${myconf} --without-plugin-${i}"
736 done
583} 737}
584 738
585pbxt_src_configure() { 739pbxt_src_configure() {
586 mysql_init_vars 740 mysql_init_vars
587 741
588 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null 742 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
589 743
590 einfo "Reconfiguring dir '${PWD}'" 744 einfo "Reconfiguring dir '${PWD}'"
591 AT_GNUCONF_UPDATE="yes" eautoreconf 745 eautoreconf
592 746
593 local myconf="" 747 local myconf=""
594 myconf="${myconf} --with-mysql=${S} --libdir=/usr/$(get_libdir)" 748 myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
595 use debug && myconf="${myconf} --with-debug=full" 749 use debug && myconf="${myconf} --with-debug=full"
596 econf ${myconf} || die "Problem configuring PBXT storage engine" 750 econf ${myconf} || die "Problem configuring PBXT storage engine"
597} 751}
598 752
599pbxt_src_compile() { 753pbxt_src_compile() {
754
600 # Be backwards compatible for now 755 # Be backwards compatible for now
601 if [[ $EAPI != 2 ]]; then 756 if [[ $EAPI != 2 ]]; then
602 pbxt_src_configure 757 pbxt_src_configure
603 fi 758 fi
604 # TODO: is it safe/needed to use emake here ? 759 # TODO: is it safe/needed to use emake here ?
623# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv" 778# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
624# check for conflicting use flags 779# check for conflicting use flags
625# create new user and group for mysql 780# create new user and group for mysql
626# warn about deprecated features 781# warn about deprecated features
627mysql_pkg_setup() { 782mysql_pkg_setup() {
628 if hasq test ${FEATURES} ; then 783 if has test ${FEATURES} ; then
629 if ! use minimal ; then 784 if ! use minimal ; then
630 if [[ $UID -eq 0 ]]; then 785 if [[ $UID -eq 0 ]]; then
631 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." 786 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
632 fi 787 fi
633 fi 788 fi
634 fi 789 fi
635 790
791 # bug 350844
792 case "${EAPI:-0}" in
793 0 | 1)
794 if use static && ! built_with_use sys-libs/ncurses static-libs; then
795 die "To build MySQL statically you need to enable static-libs for sys-libs/ncurses"
796 fi
797 ;;
798 esac
799
636 # Check for USE flag problems in pkg_setup 800 # Check for USE flag problems in pkg_setup
637 if use static && use ssl ; then 801 if use static && use ssl ; then
638 eerror "MySQL does not support being built statically with SSL support enabled!"
639 die "MySQL does not support being built statically with SSL support enabled!" 802 M="MySQL does not support being built statically with SSL support enabled!"
803 eerror "${M}"
804 die "${M}"
805 fi
806
807 if mysql_version_is_at_least "5.1.51" \
808 && ! mysql_version_is_at_least "5.2" \
809 && use debug ; then
810 # Also in package.use.mask
811 die "Bug #344885: Upstream has broken USE=debug for 5.1 series >=5.1.51"
640 fi 812 fi
641 813
642 if ! mysql_version_is_at_least "5.0" \ 814 if ! mysql_version_is_at_least "5.0" \
643 && use raid \ 815 && use raid \
644 && use static ; then 816 && use static ; then
646 eerror "with RAID support enabled." 818 eerror "with RAID support enabled."
647 die "USE flags 'raid' and 'static' conflict!" 819 die "USE flags 'raid' and 'static' conflict!"
648 fi 820 fi
649 821
650 if mysql_version_is_at_least "4.1.3" \ 822 if mysql_version_is_at_least "4.1.3" \
651 && ( use cluster || use extraengine ) \ 823 && ( use cluster || use extraengine || use embedded ) \
652 && use minimal ; then 824 && use minimal ; then
653 eerror "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
654 die "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!" 825 M="USE flags 'cluster', 'extraengine', 'embedded' conflict with 'minimal' USE flag!"
826 eerror "${M}"
827 die "${M}"
655 fi 828 fi
656 829
657 # Bug #290570 fun. Upstream made us need a fairly new GCC4.
658 if mysql_version_is_at_least "5.0.83" ; then 830 if mysql_version_is_at_least "5.1" \
831 && xtradb_patch_available \
832 && use xtradb \
833 && use embedded ; then
834 M="USE flags 'xtradb' and 'embedded' conflict and cause build failures"
835 eerror "${M}"
836 die "${M}"
837 fi
838
839 # Bug #290570, 284946, 307251
840 # Upstream changes made us need a fairly new GCC4.
841 # But only for 5.0.8[3-6]!
842 if mysql_version_is_at_least "5.0.83" && ! mysql_version_is_at_least 5.0.87 ; then
659 GCC_VER=$(gcc-version) 843 GCC_VER=$(gcc-version)
660 case ${GCC_VER} in 844 case ${CHOST}:${GCC_VER} in
661 2*|3*|4.0|4.1|4.2) die "Active GCC too old! Must have at least GCC4.3" ;; 845 *-darwin*:4.*) : ;; # bug #310615
846 *:2*|*:3*|*:4.0|*:4.1|*:4.2)
847 eerror "Some releases of MySQL required a very new GCC, and then"
848 eerror "later release relaxed that requirement again. Either pick a"
849 eerror "MySQL >=5.0.87, or use a newer GCC."
850 die "Active GCC too old!" ;;
662 esac 851 esac
663 fi 852 fi
664 853
665 # This should come after all of the die statements 854 # This should come after all of the die statements
666 enewgroup mysql 60 || die "problem adding 'mysql' group" 855 enewgroup mysql 60 || die "problem adding 'mysql' group"
688 # Initialize the proper variables first 877 # Initialize the proper variables first
689 mysql_init_vars 878 mysql_init_vars
690 879
691 unpack ${A} 880 unpack ${A}
692 # Grab the patches 881 # Grab the patches
693 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack 882 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
694 883
695 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}" 884 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
696 885
697 # Be backwards compatible for now 886 # Be backwards compatible for now
698 case ${EAPI:-0} in 887 case ${EAPI:-0} in
716 mysql_mv_patches 905 mysql_mv_patches
717 # And apply 906 # And apply
718 epatch 907 epatch
719 908
720 # last -fPIC fixup, per bug #305873 909 # last -fPIC fixup, per bug #305873
721 i="${S}"/storage/innodb_plugin/plug.in 910 i="${S}"/storage/innodb_plugin/plug.in
722 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}" 911 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
723 912
724 # Additional checks, remove bundled zlib 913 # Additional checks, remove bundled zlib (Cluster needs this, for static
914 # memory management in zlib, leave available for Cluster)
915 if [[ "${PN}" != "mysql-cluster" ]] ; then
725 rm -f "${S}/zlib/"*.[ch] 916 rm -f "${S}/zlib/"*.[ch]
726 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in" 917 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
918 fi
727 rm -f "scripts/mysqlbug" 919 rm -f "scripts/mysqlbug"
728 920
729 # Make charsets install in the right place 921 # Make charsets install in the right place
730 find . -name 'Makefile.am' \ 922 find . -name 'Makefile.am' \
731 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \; 923 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
742 fi 934 fi
743 935
744 local rebuilddirlist d 936 local rebuilddirlist d
745 937
746 if xtradb_patch_available && use xtradb ; then 938 if xtradb_patch_available && use xtradb ; then
747 einfo "Replacing InnoDB with Percona XtraDB" 939 einfo "Adding storage engine: Percona XtraDB (replacing InnoDB)"
748 pushd "${S}"/storage 940 pushd "${S}"/storage >/dev/null
749 i="innobase" 941 i="innobase"
750 o="${WORKDIR}/storage-${i}.mysql-upstream" 942 o="${WORKDIR}/storage-${i}.mysql-upstream"
751 # Have we been here already? 943 # Have we been here already?
752 [ -d "${o}" ] && rm -f "${i}" 944 [ -d "${o}" ] && rm -f "${i}"
753 # Or maybe we haven't 945 # Or maybe we haven't
754 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}" 946 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}"
755 cp -ra "${WORKDIR}/${XTRADB_P}" "${i}" 947 cp -ral "${WORKDIR}/${XTRADB_P}" "${i}"
756 popd 948 popd >/dev/null
949 fi
950
951 if pbxt_patch_available && [[ "${PBXT_NEWSTYLE}" == "1" ]] && use pbxt ; then
952 einfo "Adding storage engine: PBXT"
953 pushd "${S}"/storage >/dev/null
954 i='pbxt'
955 [ -d "${i}" ] && rm -rf "${i}"
956 cp -ral "${WORKDIR}/${PBXT_P}" "${i}"
957 popd >/dev/null
757 fi 958 fi
758 959
759 if mysql_version_is_at_least "5.1.12" ; then 960 if mysql_version_is_at_least "5.1.12" ; then
760 rebuilddirlist="." 961 rebuilddirlist="."
761 # This does not seem to be needed presently. robbat2 2010/02/23 962 # This does not seem to be needed presently. robbat2 2010/02/23
770 fi 971 fi
771 972
772 for d in ${rebuilddirlist} ; do 973 for d in ${rebuilddirlist} ; do
773 einfo "Reconfiguring dir '${d}'" 974 einfo "Reconfiguring dir '${d}'"
774 pushd "${d}" &>/dev/null 975 pushd "${d}" &>/dev/null
775 AT_GNUCONF_UPDATE="yes" eautoreconf 976 eautoreconf
776 popd &>/dev/null 977 popd &>/dev/null
777 done 978 done
778 979
779 if mysql_check_version_range "4.1 to 5.0.99.99" \ 980 if mysql_check_version_range "4.1 to 5.0.99.99" \
780 && use berkdb ; then 981 && use berkdb ; then
781 einfo "Fixing up berkdb buildsystem" 982 einfo "Fixing up berkdb buildsystem"
782 [[ -w "bdb/dist/ltmain.sh" ]] && cp -f "ltmain.sh" "bdb/dist/ltmain.sh" 983 [[ -w "bdb/dist/ltmain.sh" ]] && cp -f "ltmain.sh" "bdb/dist/ltmain.sh"
783 cp -f "/usr/share/aclocal/libtool.m4" "bdb/dist/aclocal/libtool.ac" \ 984 cp -f "${EPREFIX}/usr/share/aclocal/libtool.m4" "bdb/dist/aclocal/libtool.ac" \
784 || die "Could not copy libtool.m4 to bdb/dist/" 985 || die "Could not copy libtool.m4 to bdb/dist/"
785 #These files exist only with libtool-2*, and need to be included. 986 #These files exist only with libtool-2*, and need to be included.
786 if [ -f '/usr/share/aclocal/ltsugar.m4' ]; then 987 if [ -f ${EPREFIX}'/usr/share/aclocal/ltsugar.m4' ]; then
787 cat "/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac" 988 cat "${EPREFIX}/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac"
788 cat "/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac" 989 cat "${EPREFIX}/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac"
789 cat "/usr/share/aclocal/lt~obsolete.m4" >> "bdb/dist/aclocal/libtool.ac" 990 cat "${EPREFIX}/usr/share/aclocal/lt~obsolete.m4" >> "bdb/dist/aclocal/libtool.ac"
790 cat "/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac" 991 cat "${EPREFIX}/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac"
791 fi 992 fi
792 pushd "bdb/dist" &>/dev/null 993 pushd "bdb/dist" &>/dev/null
793 sh s_all \ 994 sh s_all \
794 || die "Failed bdb reconfigure" 995 || die "Failed bdb reconfigure"
795 popd &>/dev/null 996 popd &>/dev/null
819 1020
820 # Bug #114895, bug #110149 1021 # Bug #114895, bug #110149
821 filter-flags "-O" "-O[01]" 1022 filter-flags "-O" "-O[01]"
822 1023
823 # glib-2.3.2_pre fix, bug #16496 1024 # glib-2.3.2_pre fix, bug #16496
824 append-flags "-DHAVE_ERRNO_AS_DEFINE=1" 1025 append-cppflags "-DHAVE_ERRNO_AS_DEFINE=1"
825 1026
826 # As discovered by bug #246652, doing a double-level of SSP causes NDB to 1027 # As discovered by bug #246652, doing a double-level of SSP causes NDB to
827 # fail badly during cluster startup. 1028 # fail badly during cluster startup.
828 if [[ $(gcc-major-version) -lt 4 ]]; then 1029 if [[ $(gcc-major-version) -lt 4 ]]; then
829 filter-flags "-fstack-protector-all" 1030 filter-flags "-fstack-protector-all"
836 export CXXFLAGS 1037 export CXXFLAGS
837 1038
838 # bug #283926, with GCC4.4, this is required to get correct behavior. 1039 # bug #283926, with GCC4.4, this is required to get correct behavior.
839 append-flags -fno-strict-aliasing 1040 append-flags -fno-strict-aliasing
840 1041
1042 # bug #335185, #335995, with >= GCC4.3.3 on x86 only, omit-frame-pointer
1043 # causes a mis-compile.
1044 # Upstream bugs:
1045 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38562
1046 # http://bugs.mysql.com/bug.php?id=45205
1047 use x86 && version_is_at_least "4.3.3" "$(gcc-fullversion)" && \
1048 append-flags -fno-omit-frame-pointer && \
1049 filter-flags -fomit-frame-pointer
1050
841 econf \ 1051 econf \
842 --libexecdir="/usr/sbin" \ 1052 --libexecdir="${EPREFIX}"/usr/sbin \
843 --sysconfdir="${MY_SYSCONFDIR}" \ 1053 --sysconfdir=${MY_SYSCONFDIR} \
844 --localstatedir="${MY_LOCALSTATEDIR}" \ 1054 --localstatedir=${MY_LOCALSTATEDIR} \
845 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 1055 --sharedstatedir=${MY_SHAREDSTATEDIR} \
846 --libdir="${MY_LIBDIR}" \ 1056 --libdir=${MY_LIBDIR} \
847 --includedir="${MY_INCLUDEDIR}" \ 1057 --includedir=${MY_INCLUDEDIR} \
848 --with-low-memory \ 1058 --with-low-memory \
849 --with-client-ldflags=-lstdc++ \ 1059 --with-client-ldflags=-lstdc++ \
850 --enable-thread-safe-client \ 1060 --enable-thread-safe-client \
851 --with-comment="Gentoo Linux ${PF}" \ 1061 --with-comment="Gentoo Linux ${PF}" \
852 --without-docs \ 1062 --without-docs \
1063 --with-LIBDIR="$(get_libdir)" \
853 ${myconf} || die "econf failed" 1064 ${myconf} || die "econf failed"
854 1065
855 # TODO: Move this before autoreconf !!! 1066 # TODO: Move this before autoreconf !!!
856 find . -type f -name Makefile -print0 \ 1067 find . -type f -name Makefile -print0 \
857 | xargs -0 -n100 sed -i \ 1068 | xargs -0 -n100 sed -i \
858 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|' 1069 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
859 1070
860 if [[ $EAPI == 2 ]]; then 1071 if [[ $EAPI == 2 ]] && [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
861 pbxt_patch_available && use pbxt && pbxt_src_configure 1072 pbxt_patch_available && use pbxt && pbxt_src_configure
862 fi 1073 fi
863} 1074}
864 1075
865# @FUNCTION: mysql_src_compile 1076# @FUNCTION: mysql_src_compile
872 0 | 1) mysql_src_configure ;; 1083 0 | 1) mysql_src_configure ;;
873 esac 1084 esac
874 1085
875 emake || die "emake failed" 1086 emake || die "emake failed"
876 1087
1088 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
877 pbxt_patch_available && use pbxt && pbxt_src_compile 1089 pbxt_patch_available && use pbxt && pbxt_src_compile
1090 fi
878} 1091}
879 1092
880# @FUNCTION: mysql_src_install 1093# @FUNCTION: mysql_src_install
881# @DESCRIPTION: 1094# @DESCRIPTION:
882# Install mysql. 1095# Install mysql.
884 # Make sure the vars are correctly initialized 1097 # Make sure the vars are correctly initialized
885 mysql_init_vars 1098 mysql_init_vars
886 1099
887 emake install \ 1100 emake install \
888 DESTDIR="${D}" \ 1101 DESTDIR="${D}" \
889 benchdir_root="${MY_SHAREDSTATEDIR}" \ 1102 benchdir_root=${MY_SHAREDSTATEDIR} \
890 testroot="${MY_SHAREDSTATEDIR}" \ 1103 testroot="${MY_SHAREDSTATEDIR}" \
891 || die "emake install failed" 1104 || die "emake install failed"
892 1105
1106 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
893 pbxt_patch_available && use pbxt && pbxt_src_install 1107 pbxt_patch_available && use pbxt && pbxt_src_install
1108 fi
894 1109
895 # Convenience links 1110 # Convenience links
896 einfo "Making Convenience links for mysqlcheck multi-call binary" 1111 einfo "Making Convenience links for mysqlcheck multi-call binary"
897 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze" 1112 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
898 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair" 1113 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
899 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize" 1114 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
900 1115
901 # Various junk (my-*.cnf moved elsewhere) 1116 # Various junk (my-*.cnf moved elsewhere)
902 einfo "Removing duplicate /usr/share/mysql files" 1117 einfo "Removing duplicate /usr/share/mysql files"
903 rm -Rf "${D}/usr/share/info" 1118 rm -Rf "${ED}/usr/share/info"
904 for removeme in "mysql-log-rotate" mysql.server* \ 1119 for removeme in "mysql-log-rotate" mysql.server* \
905 binary-configure* my-*.cnf mi_test_all* 1120 binary-configure* my-*.cnf mi_test_all*
906 do 1121 do
907 rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme} 1122 rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme}
908 done 1123 done
909 1124
910 # Clean up stuff for a minimal build 1125 # Clean up stuff for a minimal build
911 if use minimal ; then 1126 if use minimal ; then
912 einfo "Remove all extra content for minimal build" 1127 einfo "Remove all extra content for minimal build"
913 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench} 1128 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
914 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} 1129 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}
915 rm -f "${D}/usr/sbin/mysqld" 1130 rm -f "${ED}/usr/sbin/mysqld"
916 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a 1131 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
917 fi 1132 fi
918 1133
919 # Unless they explicitly specific USE=test, then do not install the 1134 # Unless they explicitly specific USE=test, then do not install the
920 # testsuite. It DOES have a use to be installed, esp. when you want to do a 1135 # testsuite. It DOES have a use to be installed, esp. when you want to do a
922 if use !test ; then 1137 if use !test ; then
923 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test 1138 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
924 fi 1139 fi
925 1140
926 # Configuration stuff 1141 # Configuration stuff
927 if mysql_version_is_at_least "4.1" ; then 1142 case ${MYSQL_PV_MAJOR} in
928 mysql_mycnf_version="4.1"
929 else
930 mysql_mycnf_version="4.0" 1143 3*|4.0) mysql_mycnf_version="4.0" ;;
931 fi 1144 4.[1-9]|5.0) mysql_mycnf_version="4.1" ;;
932 einfo "Building default my.cnf" 1145 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
1146 esac
1147 einfo "Building default my.cnf (${mysql_mycnf_version})"
933 insinto "${MY_SYSCONFDIR}" 1148 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
934 doins scripts/mysqlaccess.conf 1149 doins scripts/mysqlaccess.conf
1150 mycnf_src="my.cnf-${mysql_mycnf_version}"
935 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ 1151 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
936 "${FILESDIR}/my.cnf-${mysql_mycnf_version}" \ 1152 -e "s!/tmp!${EPREFIX}/tmp!" \
1153 -e "s!/usr!${EPREFIX}/usr!" \
1154 -e "s!= /var!= ${EPREFIX}/var!" \
1155 "${FILESDIR}/${mycnf_src}" \
937 > "${TMPDIR}/my.cnf.ok" 1156 > "${TMPDIR}/my.cnf.ok"
938 if mysql_version_is_at_least "4.1" && use latin1 ; then 1157 use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
939 sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok" 1158 if use latin1 ; then
1159 sed -i \
1160 -e "/character-set/s|utf8|latin1|g" \
1161 "${TMPDIR}/my.cnf.ok"
940 fi 1162 fi
941 newins "${TMPDIR}/my.cnf.ok" my.cnf 1163 newins "${TMPDIR}/my.cnf.ok" my.cnf
942 1164
943 # Minimal builds don't have the MySQL server 1165 # Minimal builds don't have the MySQL server
944 if ! use minimal ; then 1166 if ! use minimal ; then
945 einfo "Creating initial directories" 1167 einfo "Creating initial directories"
946 # Empty directories ... 1168 # Empty directories ...
947 diropts "-m0750" 1169 diropts "-m0750"
948 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then 1170 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
949 dodir "${MY_DATADIR}" 1171 dodir "${MY_DATADIR#${EPREFIX}}"
950 keepdir "${MY_DATADIR}" 1172 keepdir "${MY_DATADIR#${EPREFIX}}"
951 chown -R mysql:mysql "${D}/${MY_DATADIR}" 1173 chown -R mysql:mysql "${D}/${MY_DATADIR}"
952 fi 1174 fi
953 1175
954 diropts "-m0755" 1176 diropts "-m0755"
955 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do 1177 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
956 dodir "${folder}" 1178 dodir "${folder}"
957 keepdir "${folder}" 1179 keepdir "${folder}"
958 chown -R mysql:mysql "${D}/${folder}" 1180 chown -R mysql:mysql "${ED}/${folder}"
959 done 1181 done
960 fi 1182 fi
961 1183
962 # Docs 1184 # Docs
963 einfo "Installing docs" 1185 einfo "Installing docs"
964 dodoc README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE 1186 for i in README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE ; do
1187 [[ -f "$i" ]] && dodoc "$i"
1188 done
965 doinfo "${S}"/Docs/mysql.info 1189 doinfo "${S}"/Docs/mysql.info
966 1190
967 # Minimal builds don't have the MySQL server 1191 # Minimal builds don't have the MySQL server
968 if ! use minimal ; then 1192 if ! use minimal ; then
969 einfo "Including support files and sample configurations" 1193 einfo "Including support files and sample configurations"
981 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}" 1205 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
982 done 1206 done
983 1207
984 fi 1208 fi
985 1209
986 mysql_lib_symlinks "${D}" 1210 mysql_lib_symlinks "${ED}"
987} 1211}
988 1212
989# @FUNCTION: mysql_pkg_preinst 1213# @FUNCTION: mysql_pkg_preinst
990# @DESCRIPTION: 1214# @DESCRIPTION:
991# Create the user and groups for mysql - die if that fails. 1215# Create the user and groups for mysql - die if that fails.
1005mysql_pkg_postinst() { 1229mysql_pkg_postinst() {
1006 # Make sure the vars are correctly initialized 1230 # Make sure the vars are correctly initialized
1007 mysql_init_vars 1231 mysql_init_vars
1008 1232
1009 # Check FEATURES="collision-protect" before removing this 1233 # Check FEATURES="collision-protect" before removing this
1010 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 1234 [[ -d "${EROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
1011 1235
1012 # Secure the logfiles 1236 # Secure the logfiles
1013 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 1237 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
1014 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 1238 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
1015 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 1239 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
1036 einfo 1260 einfo
1037 elog "You might want to run:" 1261 elog "You might want to run:"
1038 elog "\"emerge --config =${CATEGORY}/${PF}\"" 1262 elog "\"emerge --config =${CATEGORY}/${PF}\""
1039 elog "if this is a new install." 1263 elog "if this is a new install."
1040 einfo 1264 einfo
1265
1266 einfo
1267 elog "If you are upgrading major versions, you should run the"
1268 elog "mysql_upgrade tool."
1269 einfo
1041 fi 1270 fi
1042 1271
1043 if pbxt_available && use pbxt ; then 1272 if pbxt_available && use pbxt ; then
1044 # TODO: explain it better 1273 elog "Note: PBXT is now statically built when enabled."
1045 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" 1274 elog ""
1046 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" 1275 elog "If, you previously installed as a plugin and "
1047 elog "if, after that, you cannot start the MySQL server," 1276 elog "you cannot start the MySQL server,"
1048 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" 1277 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
1049 elog "use the MySQL upgrade script to restore the table" 1278 elog "use the MySQL upgrade script to restore the table"
1050 elog "or execute the following SQL command:" 1279 elog "or execute the following SQL command:"
1051 elog " CREATE TABLE IF NOT EXISTS plugin (" 1280 elog " CREATE TABLE IF NOT EXISTS plugin ("
1052 elog " name char(64) binary DEFAULT '' NOT NULL," 1281 elog " name char(64) binary DEFAULT '' NOT NULL,"
1058 mysql_check_version_range "4.0 to 5.0.99.99" \ 1287 mysql_check_version_range "4.0 to 5.0.99.99" \
1059 && use berkdb \ 1288 && use berkdb \
1060 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 1289 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
1061} 1290}
1062 1291
1292# @FUNCTION: mysql_getopt
1293# @DESCRIPTION:
1294# Use my_print_defaults to extract specific config options
1295mysql_getopt() {
1296 local mypd="${EROOT}"/usr/bin/my_print_defaults
1297 section="$1"
1298 flag="--${2}="
1299 "${mypd}" $section | sed -n "/^${flag}/p"
1300}
1301
1302# @FUNCTION: mysql_getoptval
1303# @DESCRIPTION:
1304# Use my_print_defaults to extract specific config options
1305mysql_getoptval() {
1306 local mypd="${EROOT}"/usr/bin/my_print_defaults
1307 section="$1"
1308 flag="--${2}="
1309 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
1310}
1311
1063# @FUNCTION: mysql_pkg_config 1312# @FUNCTION: mysql_pkg_config
1064# @DESCRIPTION: 1313# @DESCRIPTION:
1065# Configure mysql environment. 1314# Configure mysql environment.
1066mysql_pkg_config() { 1315mysql_pkg_config() {
1067 local old_MY_DATADIR="${MY_DATADIR}" 1316 local old_MY_DATADIR="${MY_DATADIR}"
1317 local old_HOME="${HOME}"
1318 # my_print_defaults needs to read stuff in $HOME/.my.cnf
1319 export HOME=/root
1068 1320
1069 # Make sure the vars are correctly initialized 1321 # Make sure the vars are correctly initialized
1070 mysql_init_vars 1322 mysql_init_vars
1071 1323
1072 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 1324 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
1074 if built_with_use ${CATEGORY}/${PN} minimal ; then 1326 if built_with_use ${CATEGORY}/${PN} minimal ; then
1075 die "Minimal builds do NOT include the MySQL server" 1327 die "Minimal builds do NOT include the MySQL server"
1076 fi 1328 fi
1077 1329
1078 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 1330 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
1079 local MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${MY_DATADIR})" 1331 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
1332 MY_DATADIR_s="${MY_DATADIR_s%%/}"
1080 local old_MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${old_MY_DATADIR})" 1333 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
1334 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
1081 1335
1082 if [[ -d "${old_MY_DATADIR_s}" ]]; then 1336 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
1083 if [[ -d "${MY_DATADIR_s}" ]]; then 1337 if [[ -d "${MY_DATADIR_s}" ]]; then
1084 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 1338 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
1085 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" 1339 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
1086 else 1340 else
1087 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" 1341 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
1099 fi 1353 fi
1100 fi 1354 fi
1101 1355
1102 local pwd1="a" 1356 local pwd1="a"
1103 local pwd2="b" 1357 local pwd2="b"
1104 local maxtry=5 1358 local maxtry=15
1359
1360 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1361 MYSQL_ROOT_PASSWORD="$(mysql_getoptval 'client mysql' password)"
1362 fi
1363 MYSQL_TMPDIR="$(mysql_getoptval mysqld tmpdir)"
1364 # These are dir+prefix
1365 MYSQL_RELAY_LOG="$(mysql_getoptval mysqld relay-log)"
1366 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
1367 MYSQL_LOG_BIN="$(mysql_getoptval mysqld log-bin)"
1368 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1369
1370 if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
1371 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
1372 install -d -m 770 -o mysql -g mysql "${ROOT}"/$MYSQL_TMPDIR
1373 fi
1374 if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
1375 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
1376 install -d -m 770 -o mysql -g mysql "${ROOT}"/$MYSQL_LOG_BIN
1377 fi
1378 if [[ ! -d "${ROOT}"/$MYSQL_RELAY_LOG ]]; then
1379 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
1380 install -d -m 770 -o mysql -g mysql "${ROOT}"/$MYSQL_RELAY_LOG
1381 fi
1105 1382
1106 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 1383 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1107 ewarn "You have already a MySQL database in place." 1384 ewarn "You have already a MySQL database in place."
1108 ewarn "(${ROOT}/${MY_DATADIR}/*)" 1385 ewarn "(${ROOT}/${MY_DATADIR}/*)"
1109 ewarn "Please rename or delete it if you wish to replace it." 1386 ewarn "Please rename or delete it if you wish to replace it."
1112 1389
1113 # Bug #213475 - MySQL _will_ object strenously if your machine is named 1390 # Bug #213475 - MySQL _will_ object strenously if your machine is named
1114 # localhost. Also causes weird failures. 1391 # localhost. Also causes weird failures.
1115 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" 1392 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1116 1393
1117 einfo "Creating the mysql database and setting proper" 1394 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1118 einfo "permissions on it ..."
1119 1395
1120 einfo "Insert a password for the mysql 'root' user" 1396 einfo "Please provide a password for the mysql 'root' user now, in the"
1397 einfo "MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file."
1121 ewarn "Avoid [\"'\\_%] characters in the password" 1398 ewarn "Avoid [\"'\\_%] characters in the password"
1122 read -rsp " >" pwd1 ; echo 1399 read -rsp " >" pwd1 ; echo
1123 1400
1124 einfo "Retype the password" 1401 einfo "Retype the password"
1125 read -rsp " >" pwd2 ; echo 1402 read -rsp " >" pwd2 ; echo
1126 1403
1127 if [[ "x$pwd1" != "x$pwd2" ]] ; then 1404 if [[ "x$pwd1" != "x$pwd2" ]] ; then
1128 die "Passwords are not the same" 1405 die "Passwords are not the same"
1129 fi 1406 fi
1407 MYSQL_ROOT_PASSWORD="${pwd1}"
1408 unset pwd1 pwd2
1409 fi
1130 1410
1131 local options="" 1411 local options="--log-warnings=0"
1132 local sqltmp="$(emktemp)" 1412 local sqltmp="$(emktemp)"
1133 1413
1134 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 1414 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
1135 [[ -r "${help_tables}" ]] \ 1415 [[ -r "${help_tables}" ]] \
1136 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 1416 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
1137 || touch "${TMPDIR}/fill_help_tables.sql" 1417 || touch "${TMPDIR}/fill_help_tables.sql"
1138 help_tables="${TMPDIR}/fill_help_tables.sql" 1418 help_tables="${TMPDIR}/fill_help_tables.sql"
1139 1419
1420 # Figure out which options we need to disable to do the setup
1421 helpfile="${TMPDIR}/mysqld-help"
1422 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
1423 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
1424 federated innodb ssl log-bin relay-log slow-query-log external-locking \
1425 ndbcluster log-slave-updates \
1426 ; do
1427 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1428 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1429 done
1430 # But some options changed names
1431 egrep -sq external-locking "${helpfile}" && \
1432 options="${options/skip-locking/skip-external-locking}"
1433
1434 use prefix || options="${options} --user=mysql"
1435
1140 pushd "${TMPDIR}" &>/dev/null 1436 pushd "${TMPDIR}" &>/dev/null
1141 "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 1437 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
1438 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
1439 [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db
1440 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}"
1441 einfo "Command: $cmd"
1442 eval $cmd \
1443 >"${TMPDIR}"/mysql_install_db.log 2>&1
1142 if [ $? -ne 0 ]; then 1444 if [ $? -ne 0 ]; then
1143 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 1445 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1144 die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" 1446 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1145 fi 1447 fi
1146 popd &>/dev/null 1448 popd &>/dev/null
1147 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 1449 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1148 || die "MySQL databases not installed" 1450 || die "MySQL databases not installed"
1149 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 1451 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1150 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 1452 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1151 1453
1152 if mysql_version_is_at_least "4.1.3" ; then 1454 if mysql_version_is_at_least "4.1.3" ; then
1153 options="--skip-ndbcluster"
1154
1155 # Filling timezones, see 1455 # Filling timezones, see
1156 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 1456 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1157 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null 1457 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1158 1458
1159 if [[ -r "${help_tables}" ]] ; then 1459 if [[ -r "${help_tables}" ]] ; then
1160 cat "${help_tables}" >> "${sqltmp}" 1460 cat "${help_tables}" >> "${sqltmp}"
1161 fi 1461 fi
1162 fi 1462 fi
1163 1463
1464 einfo "Creating the mysql database and setting proper"
1465 einfo "permissions on it ..."
1466
1164 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 1467 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1165 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 1468 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1166 local mysqld="${ROOT}/usr/sbin/mysqld \ 1469 local mysqld="${EROOT}/usr/sbin/mysqld \
1167 ${options} \ 1470 ${options} \
1168 --user=mysql \ 1471 $(use prefix || echo --user=mysql) \
1169 --skip-grant-tables \ 1472 --log-warnings=0 \
1170 --basedir=${ROOT}/usr \ 1473 --basedir=${EROOT}/usr \
1171 --datadir=${ROOT}/${MY_DATADIR} \ 1474 --datadir=${ROOT}/${MY_DATADIR} \
1172 --skip-innodb \
1173 --skip-bdb \
1174 --skip-networking \
1175 --max_allowed_packet=8M \ 1475 --max_allowed_packet=8M \
1176 --net_buffer_length=16K \ 1476 --net_buffer_length=16K \
1477 --default-storage-engine=MyISAM \
1177 --socket=${socket} \ 1478 --socket=${socket} \
1178 --pid-file=${pidfile}" 1479 --pid-file=${pidfile}"
1480 #einfo "About to start mysqld: ${mysqld}"
1481 ebegin "Starting mysqld"
1482 einfo "Command ${mysqld}"
1179 ${mysqld} & 1483 ${mysqld} &
1484 rc=$?
1180 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 1485 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1181 maxtry=$((${maxtry}-1)) 1486 maxtry=$((${maxtry}-1))
1182 echo -n "." 1487 echo -n "."
1183 sleep 1 1488 sleep 1
1184 done 1489 done
1490 eend $rc
1185 1491
1492 if ! [[ -S "${socket}" ]]; then
1493 die "Completely failed to start up mysqld with: ${mysqld}"
1494 fi
1495
1496 ebegin "Setting root password"
1186 # Do this from memory, as we don't want clear text passwords in temp files 1497 # Do this from memory, as we don't want clear text passwords in temp files
1187 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'" 1498 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
1188 "${ROOT}/usr/bin/mysql" \ 1499 "${EROOT}/usr/bin/mysql" \
1189 --socket=${socket} \ 1500 --socket=${socket} \
1190 -hlocalhost \ 1501 -hlocalhost \
1191 -e "${sql}" 1502 -e "${sql}"
1503 eend $?
1192 1504
1193 einfo "Loading \"zoneinfo\", this step may require a few seconds ..." 1505 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
1194
1195 "${ROOT}/usr/bin/mysql" \ 1506 "${EROOT}/usr/bin/mysql" \
1196 --socket=${socket} \ 1507 --socket=${socket} \
1197 -hlocalhost \ 1508 -hlocalhost \
1198 -uroot \ 1509 -uroot \
1199 -p"${pwd1}" \ 1510 --password="${MYSQL_ROOT_PASSWORD}" \
1200 mysql < "${sqltmp}" 1511 mysql < "${sqltmp}"
1512 rc=$?
1513 eend $?
1514 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
1201 1515
1202 # Stop the server and cleanup 1516 # Stop the server and cleanup
1517 einfo "Stopping the server ..."
1203 kill $(< "${pidfile}" ) 1518 kill $(< "${pidfile}" )
1204 rm -f "${sqltmp}" 1519 rm -f "${sqltmp}"
1205 einfo "Stopping the server ..."
1206 wait %1 1520 wait %1
1207 einfo "Done" 1521 einfo "Done"
1208} 1522}
1209 1523
1210# @FUNCTION: mysql_pkg_postrm 1524# @FUNCTION: mysql_pkg_postrm
1211# @DESCRIPTION: 1525# @DESCRIPTION:
1212# Remove mysql symlinks. 1526# Remove mysql symlinks.
1213mysql_pkg_postrm() { 1527mysql_pkg_postrm() {
1214 : # mysql_lib_symlinks "${D}" 1528 : # mysql_lib_symlinks "${ED}"
1215} 1529}

Legend:
Removed from v.1.138  
changed lines
  Added in v.1.182

  ViewVC Help
Powered by ViewVC 1.1.20