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

Diff of /eclass/mysql.eclass

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

Revision 1.127 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.127 2010/02/01 01:07:08 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 \
51 ;; 53 ;;
52 *) 54 *)
53 die "Unsupported EAPI: ${EAPI}" ;; 55 die "Unsupported EAPI: ${EAPI}" ;;
54esac 56esac
55 57
58
59# @ECLASS-VARIABLE: MYSQL_PV_MAJOR
60# @DESCRIPTION:
61# Upstream MySQL considers the first two parts of the version number to be the
62# major version. Upgrades that change major version should always run
63# mysql_upgrade.
64MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
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
56# @ECLASS-VARIABLE: MYSQL_VERSION_ID 74# @ECLASS-VARIABLE: MYSQL_VERSION_ID
57# @DESCRIPTION: 75# @DESCRIPTION:
58# MYSQL_VERSION_ID will be: 76# MYSQL_VERSION_ID will be:
59# 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]
60# 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
77# @DESCRIPTION: 95# @DESCRIPTION:
78# Specifiy if community features are available. Possible values are 1 (yes) 96# Specifiy if community features are available. Possible values are 1 (yes)
79# and 0 (no). 97# and 0 (no).
80# Community features are available in mysql-community 98# Community features are available in mysql-community
81# AND in the re-merged mysql-5.0.82 and newer 99# AND in the re-merged mysql-5.0.82 and newer
82if [ "${PN}" == "mysql-community" ]; then 100if [ "${PN}" == "mysql-community" -o "${PN}" == "mariadb" ]; then
83 MYSQL_COMMUNITY_FEATURES=1 101 MYSQL_COMMUNITY_FEATURES=1
84elif [ "${PV#5.0}" != "${PV}" ] && mysql_version_is_at_least "5.0.82"; then 102elif [ "${PV#5.0}" != "${PV}" ] && mysql_version_is_at_least "5.0.82"; then
85 MYSQL_COMMUNITY_FEATURES=1 103 MYSQL_COMMUNITY_FEATURES=1
86elif [ "${PV#5.1}" != "${PV}" ] && mysql_version_is_at_least "5.1.28"; then 104elif [ "${PV#5.1}" != "${PV}" ] && mysql_version_is_at_least "5.1.28"; then
87 MYSQL_COMMUNITY_FEATURES=1 105 MYSQL_COMMUNITY_FEATURES=1
88elif [ "${PV#5.4}" != "${PV}" ]; then 106elif [ "${PV#5.4}" != "${PV}" ] ; then
107 MYSQL_COMMUNITY_FEATURES=1
108elif [ "${PV#5.5}" != "${PV}" ] ; then
109 MYSQL_COMMUNITY_FEATURES=1
110elif [ "${PV#6}" != "${PV}" ] ; then
111 MYSQL_COMMUNITY_FEATURES=1
112elif [ "${PV#7}" != "${PV}" ] ; then
89 MYSQL_COMMUNITY_FEATURES=1 113 MYSQL_COMMUNITY_FEATURES=1
90else 114else
91 MYSQL_COMMUNITY_FEATURES=0 115 MYSQL_COMMUNITY_FEATURES=0
92fi 116fi
93 117
102PERCONA_VER="${PERCONA_VER}" 126PERCONA_VER="${PERCONA_VER}"
103 127
104# Be warned, *DEPEND are version-dependant 128# Be warned, *DEPEND are version-dependant
105# These are used for both runtime and compiletime 129# These are used for both runtime and compiletime
106DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d ) 130DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
107 userland_GNU? ( sys-process/procps ) 131 kernel_linux? ( sys-process/procps )
108 >=sys-apps/sed-4 132 >=sys-apps/sed-4
109 >=sys-apps/texinfo-4.7-r1 133 >=sys-apps/texinfo-4.7-r1
110 >=sys-libs/readline-4.1 134 >=sys-libs/readline-4.1
111 >=sys-libs/zlib-1.2.3" 135 >=sys-libs/zlib-1.2.3"
112 136
137[[ "${PN}" == "mariadb" ]] \
138&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
139
113# 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
114for i in "" "-community" ; do 141for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do
115 [[ "${i}" == ${PN#mysql} ]] || 142 [[ "${i}" == ${PN} ]] ||
116 DEPEND="${DEPEND} !dev-db/mysql${i}" 143 DEPEND="${DEPEND} !dev-db/${i}"
117done 144done
118 145
146# prefix: first need to implement something for #196294
119RDEPEND="${DEPEND} 147RDEPEND="${DEPEND}
120 !minimal? ( dev-db/mysql-init-scripts ) 148 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
121 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
122 157
123# compile-time-only 158# compile-time-only
124mysql_version_is_at_least "5.1" \ 159mysql_version_is_at_least "5.1" \
125|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )" 160|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )"
126 161
127# compile-time-only 162# compile-time-only
128mysql_version_is_at_least "5.1.12" \ 163mysql_version_is_at_least "5.1.12" \
129&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 164&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
130 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 )"
171
131# 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
132PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 173PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
133 174
134# For other stuff to bring us in 175# For other stuff to bring us in
135PDEPEND="${PDEPEND} =virtual/mysql-$(get_version_component_range 1-2 ${PV})" 176PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
136 177
137# Work out the default SERVER_URI correctly 178# Work out the default SERVER_URI correctly
138if [ -z "${SERVER_URI}" ]; then 179if [ -z "${SERVER_URI}" ]; then
180 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
181 if [ "${PN}" == "mariadb" ]; then
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
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 "
139 # The community build is on the mirrors 192 # The community and cluster builds are on the mirrors
140 if [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then 193 elif [[ "${MYSQL_COMMUNITY_FEATURES}" == "1" || ${PN} == "mysql-cluster" ]] ; then
141 SERVER_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/mysql-${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}"
142 # The (old) enterprise source is on the primary site only 206 # The (old) enterprise source is on the primary site only
143 elif [ "${PN}" == "mysql" ]; then 207 elif [ "${PN}" == "mysql" ]; then
144 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${PV//_/-}.tar.gz" 208 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz"
145 fi 209 fi
146fi 210fi
147 211
148# Define correct SRC_URIs 212# Define correct SRC_URIs
149SRC_URI="${SERVER_URI}" 213SRC_URI="${SERVER_URI}"
153&& SRC_URI="${SRC_URI} 217&& SRC_URI="${SRC_URI}
154 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 218 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
155 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 219 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
156 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" 220 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
157 221
158# PBXT engine
159mysql_version_is_at_least "5.1.12" \
160&& [[ -n "${PBXT_VERSION}" ]] \
161&& PBXT_P="pbxt-${PBXT_VERSION}" \
162&& PBXT_SRC_URI="mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" \
163&& SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
164
165# Get the percona tarball if XTRADB_VER and PERCONA_VER are both set
166mysql_version_is_at_least "5.1.26" \
167&& [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]] \
168&& XTRADB_P="percona-xtradb-${XTRADB_VER}" \
169&& XTRADB_SRC_URI="http://www.percona.com/${PN}/xtradb/${PERCONA_VER}/source/${XTRADB_P}.tar.gz" \
170&& SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI} )"
171
172DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." 222DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
173HOMEPAGE="http://www.mysql.com/" 223HOMEPAGE="http://www.mysql.com/"
224if [[ "${PN}" == "mariadb" ]]; then
225 HOMEPAGE="http://askmonty.org/"
226 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
227fi
228if [[ "${PN}" == "mysql-community" ]]; then
229 DESCRIPTION="${DESCRIPTION} (obsolete, move to dev-db/mysql)"
230fi
174LICENSE="GPL-2" 231LICENSE="GPL-2"
175SLOT="0" 232SLOT="0"
176IUSE="big-tables debug embedded minimal ${IUSE_DEFAULT_ON}perl selinux ssl static" 233IUSE="big-tables debug embedded minimal ${IUSE_DEFAULT_ON}perl selinux ssl static test"
177 234
178mysql_version_is_at_least "4.1" \ 235mysql_version_is_at_least "4.1" \
179&& IUSE="${IUSE} latin1" 236&& IUSE="${IUSE} latin1"
180 237
181mysql_version_is_at_least "4.1.3" \ 238if mysql_version_is_at_least "4.1.3" ; then
182&& IUSE="${IUSE} cluster extraengine" 239 IUSE="${IUSE} extraengine"
240 if [[ "${PN}" != "mysql-cluster" ]] ; then
241 IUSE="${IUSE} cluster"
242 fi
243fi
183 244
184mysql_version_is_at_least "5.0" \ 245mysql_version_is_at_least "5.0" \
185|| IUSE="${IUSE} raid" 246|| IUSE="${IUSE} raid"
186 247
187mysql_version_is_at_least "5.0.18" \ 248mysql_version_is_at_least "5.0.18" \
188&& IUSE="${IUSE} max-idx-128" 249&& IUSE="${IUSE} max-idx-128"
189 250
190mysql_version_is_at_least "5.1" \ 251mysql_version_is_at_least "5.1" \
191|| IUSE="${IUSE} berkdb" 252|| IUSE="${IUSE} berkdb"
192 253
193mysql_version_is_at_least "5.1.12" \
194&& [[ -n "${PBXT_VERSION}" ]] \
195&& IUSE="${IUSE} pbxt"
196
197mysql_version_is_at_least "5.1.26" \
198&& [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]] \
199&& IUSE="${IUSE} xtradb"
200
201[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \ 254[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \
202&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling" 255&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling"
256
257[[ "${PN}" == "mariadb" ]] \
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"
265
266# MariaDB has integrated PBXT
267# PBXT_VERSION means that we have a PBXT patch for this PV
268# PBXT was only introduced after 5.1.12
269pbxt_patch_available() {
270 [[ "${PN}" != "mariadb" ]] \
271 && mysql_version_is_at_least "5.1.12" \
272 && [[ -n "${PBXT_VERSION}" ]]
273 return $?
274}
275
276pbxt_available() {
277 pbxt_patch_available || [[ "${PN}" == "mariadb" ]]
278 return $?
279}
280
281# Get the percona tarball if XTRADB_VER and PERCONA_VER are both set
282# MariaDB has integrated XtraDB
283# XTRADB_VERS means that we have a XTRADB patch for this PV
284# XTRADB was only introduced after 5.1.26
285xtradb_patch_available() {
286 [[ "${PN}" != "mariadb" ]] \
287 && mysql_version_is_at_least "5.1.26" \
288 && [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]]
289 return $?
290}
291
292
293pbxt_patch_available \
294&& PBXT_P="pbxt-${PBXT_VERSION}" \
295&& PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" \
296&& SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" \
297
298# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
299# vs. built outside the dir
300pbxt_available \
301&& IUSE="${IUSE} pbxt" \
302&& mysql_version_is_at_least "5.1.40" \
303&& PBXT_NEWSTYLE=1
304
305xtradb_patch_available \
306&& XTRADB_P="percona-xtradb-${XTRADB_VER}" \
307&& XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" \
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}" \
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}" \
313&& SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI1} ${XTRADB_SRC_URI2} ${XTRADB_SRC_URI3} )" \
314&& IUSE="${IUSE} xtradb"
203 315
204# 316#
205# HELPER FUNCTIONS: 317# HELPER FUNCTIONS:
206# 318#
207 319
211mysql_disable_test() { 323mysql_disable_test() {
212 local rawtestname testname testsuite reason mysql_disable_file 324 local rawtestname testname testsuite reason mysql_disable_file
213 rawtestname="${1}" ; shift 325 rawtestname="${1}" ; shift
214 reason="${@}" 326 reason="${@}"
215 ewarn "test '${rawtestname}' disabled: '${reason}'" 327 ewarn "test '${rawtestname}' disabled: '${reason}'"
216 328
217 testsuite="${rawtestname/.*}" 329 testsuite="${rawtestname/.*}"
218 testname="${rawtestname/*.}" 330 testname="${rawtestname/*.}"
219 mysql_disable_file="${S}/mysql-test/t/disabled.def" 331 mysql_disable_file="${S}/mysql-test/t/disabled.def"
220 einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}" 332 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
221 echo ${testname} : ${reason} >> "${mysql_disable_file}" 333 echo ${testname} : ${reason} >> "${mysql_disable_file}"
222 334
223 # ${S}/mysql-tests/t/disabled.def 335 # ${S}/mysql-tests/t/disabled.def
224 # 336 #
225 # ${S}/mysql-tests/suite/federated/disabled.def 337 # ${S}/mysql-tests/suite/federated/disabled.def
251# @DESCRIPTION: 363# @DESCRIPTION:
252# void mysql_init_vars() 364# void mysql_init_vars()
253# Initialize global variables 365# Initialize global variables
254# 2005-11-19 <vivo@gentoo.org> 366# 2005-11-19 <vivo@gentoo.org>
255mysql_init_vars() { 367mysql_init_vars() {
256 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"} 368 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
257 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"} 369 MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
258 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"} 370 MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
259 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"} 371 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
260 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"} 372 MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
261 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"} 373 MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
262 374
263 if [[ -z "${MY_DATADIR}" ]] ; then 375 if [[ -z "${MY_DATADIR}" ]] ; then
264 MY_DATADIR="" 376 MY_DATADIR=""
265 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then 377 if [[ -f ${MY_SYSCONFDIR}/my.cnf ]] ; then
266 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ 378 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
267 | sed -ne '/datadir/s|^--datadir=||p' \ 379 | sed -ne '/datadir/s|^--datadir=||p' \
268 | tail -n1` 380 | tail -n1`
269 if [[ -z "${MY_DATADIR}" ]] ; then 381 if [[ -z "${MY_DATADIR}" ]] ; then
270 MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ 382 MY_DATADIR=`grep ^datadir ${MY_SYSCONFDIR}/my.cnf \
271 | sed -e 's/.*=\s*//' \ 383 | sed -e 's/.*=\s*//' \
272 | tail -n1` 384 | tail -n1`
273 fi 385 fi
274 fi 386 fi
275 if [[ -z "${MY_DATADIR}" ]] ; then 387 if [[ -z "${MY_DATADIR}" ]] ; then
303 MY_DATADIR="${new_MY_DATADIR}" 415 MY_DATADIR="${new_MY_DATADIR}"
304 fi 416 fi
305 fi 417 fi
306 fi 418 fi
307 419
420 if [ "${MY_SOURCEDIR:-unset}" == "unset" ]; then
308 MY_SOURCEDIR=${SERVER_URI##*/} 421 MY_SOURCEDIR=${SERVER_URI##*/}
309 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*} 422 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
423 fi
310 424
311 export MY_SHAREDSTATEDIR MY_SYSCONFDIR 425 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
312 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR 426 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
313 export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR 427 export MY_INCLUDEDIR MY_DATADIR MY_SOURCEDIR
314} 428}
343 457
344configure_common() { 458configure_common() {
345 myconf="${myconf} $(use_with big-tables)" 459 myconf="${myconf} $(use_with big-tables)"
346 myconf="${myconf} --enable-local-infile" 460 myconf="${myconf} --enable-local-infile"
347 myconf="${myconf} --with-extra-charsets=all" 461 myconf="${myconf} --with-extra-charsets=all"
348 myconf="${myconf} --with-mysqld-user=mysql" 462 use prefix || myconf="${myconf} --with-mysqld-user=mysql"
349 myconf="${myconf} --with-server" 463 myconf="${myconf} --with-server"
350 myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock" 464 myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
351 myconf="${myconf} --without-libwrap" 465 myconf="${myconf} --without-libwrap"
352 466
353 if use static ; then 467 if use static ; then
354 myconf="${myconf} --with-mysqld-ldflags=-all-static" 468 myconf="${myconf} --with-mysqld-ldflags=-all-static"
355 myconf="${myconf} --with-client-ldflags=-all-static" 469 myconf="${myconf} --with-client-ldflags=-all-static"
361 if use debug ; then 475 if use debug ; then
362 myconf="${myconf} --with-debug=full" 476 myconf="${myconf} --with-debug=full"
363 else 477 else
364 myconf="${myconf} --without-debug" 478 myconf="${myconf} --without-debug"
365 mysql_version_is_at_least "4.1.3" \ 479 mysql_version_is_at_least "4.1.3" \
366 && use cluster \ 480 && ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) \
367 && myconf="${myconf} --without-ndb-debug" 481 && myconf="${myconf} --without-ndb-debug"
368 fi 482 fi
369 483
370 if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then 484 if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
371 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" 485 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
390 fi 504 fi
391 505
392} 506}
393 507
394configure_40_41_50() { 508configure_40_41_50() {
509 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr"
395 myconf="${myconf} $(use_with perl bench)" 510 myconf="${myconf} $(use_with perl bench)"
396 myconf="${myconf} --enable-assembler" 511 myconf="${myconf} --enable-assembler"
397 myconf="${myconf} --with-extra-tools" 512 myconf="${myconf} --with-extra-tools"
398 myconf="${myconf} --with-innodb" 513 myconf="${myconf} --with-innodb"
399 myconf="${myconf} --without-readline" 514 myconf="${myconf} --without-readline"
515 myconf="${myconf} $(use_with ssl openssl "${EPREFIX}/usr")"
400 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)"
401 517
402 # --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
403 # has been removed from configure 519 # has been removed from configure
520 # Apply to 4.x and 5.0.[0-3]
404 if use ssl ; then 521 if use ssl ; then
405 mysql_version_is_at_least "5.0.4" || myconf="${myconf} --with-vio" 522 mysql_version_is_at_least "5.0.4" || myconf="${myconf} --with-vio"
406 fi
407
408 if mysql_version_is_at_least "5.1.11" ; then
409 myconf="${myconf} $(use_with ssl)"
410 else
411 myconf="${myconf} $(use_with ssl openssl)"
412 fi 523 fi
413 524
414 if mysql_version_is_at_least "5.0.60" ; then 525 if mysql_version_is_at_least "5.0.60" ; then
415 if use berkdb ; then 526 if use berkdb ; then
416 elog "Berkeley DB support was disabled due to build failures" 527 elog "Berkeley DB support was disabled due to build failures"
432 myconf="${myconf} --without-berkeley-db" 543 myconf="${myconf} --without-berkeley-db"
433 fi 544 fi
434 545
435 if mysql_version_is_at_least "4.1.3" ; then 546 if mysql_version_is_at_least "4.1.3" ; then
436 myconf="${myconf} --with-geometry" 547 myconf="${myconf} --with-geometry"
548 if [[ "${PN}" != "mysql-cluster" ]] ; then
437 myconf="${myconf} $(use_with cluster ndbcluster)" 549 myconf="${myconf} $(use_with cluster ndbcluster)"
550 fi
438 fi 551 fi
439 552
440 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
441 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html 554 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html
442 myconf="${myconf} --with-archive-storage-engine" 555 myconf="${myconf} --with-archive-storage-engine"
473 586
474configure_51() { 587configure_51() {
475 # TODO: !!!! readd --without-readline 588 # TODO: !!!! readd --without-readline
476 # the failure depend upon config/ac-macros/readline.m4 checking into 589 # the failure depend upon config/ac-macros/readline.m4 checking into
477 # readline.h instead of history.h 590 # readline.h instead of history.h
478 myconf="${myconf} $(use_with ssl)" 591 myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
479 myconf="${myconf} --enable-assembler" 592 myconf="${myconf} --enable-assembler"
480 myconf="${myconf} --with-geometry" 593 myconf="${myconf} --with-geometry"
481 myconf="${myconf} --with-readline" 594 myconf="${myconf} --with-readline"
482 myconf="${myconf} --with-row-based-replication" 595 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
483 myconf="${myconf} --with-zlib=/usr/$(get_libdir)"
484 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"
485 use max-idx-128 && myconf="${myconf} --with-max-indexes=128" 602 #use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
603 if [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then
604 myconf="${myconf} $(use_enable community community-features)"
605 if use community; then
606 myconf="${myconf} $(use_enable profiling)"
607 else
608 myconf="${myconf} --disable-profiling"
609 fi
610 fi
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 )"
486 629
487 # 5.1 introduces a new way to manage storage engines (plugins) 630 # 5.1 introduces a new way to manage storage engines (plugins)
488 # like configuration=none 631 # like configuration=none
632 # This base set are required, and will always be statically built.
489 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
490 if use extraengine ; then 645 if use extraengine ; then
491 # 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
492 plugins="${plugins},archive,blackhole,example,federated,partition" 647 # not added yet: ibmdb2i
648 # Not supporting as examples: example,daemon_example,ftexample
649 plugins_sta="${plugins_sta} partition"
493 650
651 if [[ "${PN}" != "mariadb" ]] ; then
494 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"
495 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"
655 else
656 elog "MariaDB includes the FederatedX engine. Be sure to read"
657 elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine"
658 plugins_dyn="${plugins_sta} federatedx"
496 fi 659 fi
660 else
661 plugins_dis="${plugins_dis} partition federated"
662 fi
497 663
498 # Upstream specifically requests that InnoDB always be built. 664 # Upstream specifically requests that InnoDB always be built:
499 plugins="${plugins},innobase" 665 # - innobase, innodb_plugin
666 # Build falcon if available for 6.x series.
667 for i in innobase falcon ; do
668 [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
669 done
670 for i in innodb_plugin ; do
671 [ -e "${S}"/storage/${i} ] && plugins_dyn="${plugins_dyn} ${i}"
672 done
500 673
501 # like configuration=max-no-ndb 674 # like configuration=max-no-ndb
502 if use cluster ; then 675 if ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) ; then
503 plugins="${plugins},ndbcluster" 676 plugins_sta="${plugins_sta} ndbcluster partition"
677 plugins_dis="${plugins_dis//partition}"
504 myconf="${myconf} --with-ndb-binlog" 678 myconf="${myconf} --with-ndb-binlog"
679 else
680 plugins_dis="${plugins_dis} ndbcluster"
681 fi
682
683 if [[ "${PN}" == "mariadb" ]] ; then
684 # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not
685 # caught above.
686 # This is not optional, without it several upstream testcases fail.
687 # Also strongly recommended by upstream.
688 if [[ "${PV}" < "5.2.0" ]] ; then
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"
505 fi 694 fi
506 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
507 if mysql_version_is_at_least "5.2" ; then 705 if mysql_version_is_at_least "5.2" ; then
508 plugins="${plugins},falcon" 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
509 fi 713 fi
714 fi
510 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
511 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
512} 737}
513 738
514pbxt_src_configure() { 739pbxt_src_configure() {
515 mysql_init_vars 740 mysql_init_vars
516 741
517 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null 742 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
518 743
519 einfo "Reconfiguring dir '${PWD}'" 744 einfo "Reconfiguring dir '${PWD}'"
520 AT_GNUCONF_UPDATE="yes" eautoreconf 745 eautoreconf
521 746
522 local myconf="" 747 local myconf=""
523 myconf="${myconf} --with-mysql=${S} --libdir=${D}/${MY_LIBDIR}" 748 myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
524 use debug && myconf="${myconf} --with-debug=full" 749 use debug && myconf="${myconf} --with-debug=full"
525 # TODO: is it safe/needed to use econf here ?
526 ./configure ${myconf} || die "Problem configuring PBXT storage engine" 750 econf ${myconf} || die "Problem configuring PBXT storage engine"
527} 751}
528 752
529pbxt_src_compile() { 753pbxt_src_compile() {
754
530 # Be backwards compatible for now 755 # Be backwards compatible for now
531 if [[ $EAPI != 2 ]]; then 756 if [[ $EAPI != 2 ]]; then
532 pbxt_src_configure 757 pbxt_src_configure
533 fi 758 fi
534 # TODO: is it safe/needed to use emake here ? 759 # TODO: is it safe/needed to use emake here ?
538 # TODO: modify test suite for PBXT 763 # TODO: modify test suite for PBXT
539} 764}
540 765
541pbxt_src_install() { 766pbxt_src_install() {
542 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null 767 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
543 make install || die "Failed to install PBXT" 768 emake install DESTDIR="${D}" || die "Failed to install PBXT"
544 popd 769 popd
545} 770}
546 771
547# 772#
548# EBUILD FUNCTIONS 773# EBUILD FUNCTIONS
553# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv" 778# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
554# check for conflicting use flags 779# check for conflicting use flags
555# create new user and group for mysql 780# create new user and group for mysql
556# warn about deprecated features 781# warn about deprecated features
557mysql_pkg_setup() { 782mysql_pkg_setup() {
558 if hasq test ${FEATURES} ; then 783 if has test ${FEATURES} ; then
559 if ! use minimal ; then 784 if ! use minimal ; then
560 if [[ $UID -eq 0 ]]; then 785 if [[ $UID -eq 0 ]]; then
561 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."
562 fi 787 fi
563 fi 788 fi
564 fi 789 fi
565 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
566 # Check for USE flag problems in pkg_setup 800 # Check for USE flag problems in pkg_setup
567 if use static && use ssl ; then 801 if use static && use ssl ; then
568 eerror "MySQL does not support being built statically with SSL support enabled!"
569 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"
570 fi 812 fi
571 813
572 if ! mysql_version_is_at_least "5.0" \ 814 if ! mysql_version_is_at_least "5.0" \
573 && use raid \ 815 && use raid \
574 && use static ; then 816 && use static ; then
576 eerror "with RAID support enabled." 818 eerror "with RAID support enabled."
577 die "USE flags 'raid' and 'static' conflict!" 819 die "USE flags 'raid' and 'static' conflict!"
578 fi 820 fi
579 821
580 if mysql_version_is_at_least "4.1.3" \ 822 if mysql_version_is_at_least "4.1.3" \
581 && ( use cluster || use extraengine ) \ 823 && ( use cluster || use extraengine || use embedded ) \
582 && use minimal ; then 824 && use minimal ; then
583 eerror "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
584 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}"
585 fi 828 fi
586 829
587 # Bug #290570 fun. Upstream made us need a fairly new GCC4.
588 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
589 GCC_VER=$(gcc-version) 843 GCC_VER=$(gcc-version)
590 case ${GCC_VER} in 844 case ${CHOST}:${GCC_VER} in
591 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!" ;;
592 esac 851 esac
593 fi 852 fi
594 853
595 # This should come after all of the die statements 854 # This should come after all of the die statements
596 enewgroup mysql 60 || die "problem adding 'mysql' group" 855 enewgroup mysql 60 || die "problem adding 'mysql' group"
597 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" 856 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
598 857
599 mysql_check_version_range "4.0 to 5.0.99.99" \ 858 mysql_check_version_range "4.0 to 5.0.99.99" \
600 && use berkdb \ 859 && use berkdb \
601 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 860 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
861
862 if [ "${PN}" != "mysql-cluster" ] && use cluster; then
863 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
864 ewarn "5.1 series should NOT be put into production. In the near"
865 ewarn "future, it will be disabled from building."
866 ewarn ""
867 ewarn "If you need NDB support, you should instead move to the new"
868 ewarn "mysql-cluster package that represents that upstream NDB"
869 ewarn "development."
870 fi
602} 871}
603 872
604# @FUNCTION: mysql_src_unpack 873# @FUNCTION: mysql_src_unpack
605# @DESCRIPTION: 874# @DESCRIPTION:
606# Unpack the source code and call mysql_src_prepare for EAPI < 2. 875# Unpack the source code and call mysql_src_prepare for EAPI < 2.
608 # Initialize the proper variables first 877 # Initialize the proper variables first
609 mysql_init_vars 878 mysql_init_vars
610 879
611 unpack ${A} 880 unpack ${A}
612 # Grab the patches 881 # Grab the patches
613 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack 882 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
614 883
615 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}" 884 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
616 885
617 # Be backwards compatible for now 886 # Be backwards compatible for now
618 case ${EAPI:-0} in 887 case ${EAPI:-0} in
635 # Now link in right patches 904 # Now link in right patches
636 mysql_mv_patches 905 mysql_mv_patches
637 # And apply 906 # And apply
638 epatch 907 epatch
639 908
640 # Additional checks, remove bundled zlib 909 # last -fPIC fixup, per bug #305873
910 i="${S}"/storage/innodb_plugin/plug.in
911 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
912
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
641 rm -f "${S}/zlib/"*.[ch] 916 rm -f "${S}/zlib/"*.[ch]
642 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
643 rm -f "scripts/mysqlbug" 919 rm -f "scripts/mysqlbug"
644 920
645 # Make charsets install in the right place 921 # Make charsets install in the right place
646 find . -name 'Makefile.am' \ 922 find . -name 'Makefile.am' \
647 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \; 923 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
657 rm -f "scripts/mysqlbug" 933 rm -f "scripts/mysqlbug"
658 fi 934 fi
659 935
660 local rebuilddirlist d 936 local rebuilddirlist d
661 937
662 if mysql_version_is_at_least "5.1.26" && use xtradb ; then 938 if xtradb_patch_available && use xtradb ; then
663 einfo "Replacing InnoDB with Percona XtraDB" 939 einfo "Adding storage engine: Percona XtraDB (replacing InnoDB)"
664 pushd "${S}"/storage 940 pushd "${S}"/storage >/dev/null
665 i="innobase" 941 i="innobase"
666 o="${WORKDIR}/storage-${i}.mysql-upstream" 942 o="${WORKDIR}/storage-${i}.mysql-upstream"
667 # Have we been here already? 943 # Have we been here already?
668 [ -h "${i}" ] && rm -f "${i}" 944 [ -d "${o}" ] && rm -f "${i}"
669 # Or maybe we haven't 945 # Or maybe we haven't
670 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}" 946 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}"
671 ln -s "${WORKDIR}/${XTRADB_P}" "${i}" 947 cp -ral "${WORKDIR}/${XTRADB_P}" "${i}"
672 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
673 fi 958 fi
674 959
675 if mysql_version_is_at_least "5.1.12" ; then 960 if mysql_version_is_at_least "5.1.12" ; then
676 einfo "Updating innobase cmake"
677 rebuilddirlist="." 961 rebuilddirlist="."
962 # This does not seem to be needed presently. robbat2 2010/02/23
963 #einfo "Updating innobase cmake"
678 # TODO: check this with a cmake expert 964 ## TODO: check this with a cmake expert
679 cmake \ 965 #cmake \
680 -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) \ 966 # -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) \
681 -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) \ 967 # -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) \
682 "storage/innobase" 968 # "storage/innobase"
683 else 969 else
684 rebuilddirlist=". innobase" 970 rebuilddirlist=". innobase"
685 fi 971 fi
686 972
687 for d in ${rebuilddirlist} ; do 973 for d in ${rebuilddirlist} ; do
688 einfo "Reconfiguring dir '${d}'" 974 einfo "Reconfiguring dir '${d}'"
689 pushd "${d}" &>/dev/null 975 pushd "${d}" &>/dev/null
690 AT_GNUCONF_UPDATE="yes" eautoreconf 976 eautoreconf
691 popd &>/dev/null 977 popd &>/dev/null
692 done 978 done
693 979
694 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" \
695 && use berkdb ; then 981 && use berkdb ; then
696 einfo "Fixing up berkdb buildsystem" 982 einfo "Fixing up berkdb buildsystem"
697 [[ -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"
698 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" \
699 || die "Could not copy libtool.m4 to bdb/dist/" 985 || die "Could not copy libtool.m4 to bdb/dist/"
700 #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.
701 if [ -f '/usr/share/aclocal/ltsugar.m4' ]; then 987 if [ -f ${EPREFIX}'/usr/share/aclocal/ltsugar.m4' ]; then
702 cat "/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac" 988 cat "${EPREFIX}/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac"
703 cat "/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac" 989 cat "${EPREFIX}/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac"
704 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"
705 cat "/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac" 991 cat "${EPREFIX}/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac"
706 fi 992 fi
707 pushd "bdb/dist" &>/dev/null 993 pushd "bdb/dist" &>/dev/null
708 sh s_all \ 994 sh s_all \
709 || die "Failed bdb reconfigure" 995 || die "Failed bdb reconfigure"
710 popd &>/dev/null 996 popd &>/dev/null
734 1020
735 # Bug #114895, bug #110149 1021 # Bug #114895, bug #110149
736 filter-flags "-O" "-O[01]" 1022 filter-flags "-O" "-O[01]"
737 1023
738 # glib-2.3.2_pre fix, bug #16496 1024 # glib-2.3.2_pre fix, bug #16496
739 append-flags "-DHAVE_ERRNO_AS_DEFINE=1" 1025 append-cppflags "-DHAVE_ERRNO_AS_DEFINE=1"
740 1026
741 # 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
742 # fail badly during cluster startup. 1028 # fail badly during cluster startup.
743 if [[ $(gcc-major-version) -lt 4 ]]; then 1029 if [[ $(gcc-major-version) -lt 4 ]]; then
744 filter-flags "-fstack-protector-all" 1030 filter-flags "-fstack-protector-all"
751 export CXXFLAGS 1037 export CXXFLAGS
752 1038
753 # 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.
754 append-flags -fno-strict-aliasing 1040 append-flags -fno-strict-aliasing
755 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
756 econf \ 1051 econf \
757 --libexecdir="/usr/sbin" \ 1052 --libexecdir="${EPREFIX}"/usr/sbin \
758 --sysconfdir="${MY_SYSCONFDIR}" \ 1053 --sysconfdir=${MY_SYSCONFDIR} \
759 --localstatedir="${MY_LOCALSTATEDIR}" \ 1054 --localstatedir=${MY_LOCALSTATEDIR} \
760 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 1055 --sharedstatedir=${MY_SHAREDSTATEDIR} \
761 --libdir="${MY_LIBDIR}" \ 1056 --libdir=${MY_LIBDIR} \
762 --includedir="${MY_INCLUDEDIR}" \ 1057 --includedir=${MY_INCLUDEDIR} \
763 --with-low-memory \ 1058 --with-low-memory \
764 --with-client-ldflags=-lstdc++ \ 1059 --with-client-ldflags=-lstdc++ \
765 --enable-thread-safe-client \ 1060 --enable-thread-safe-client \
766 --with-comment="Gentoo Linux ${PF}" \ 1061 --with-comment="Gentoo Linux ${PF}" \
767 --without-docs \ 1062 --without-docs \
1063 --with-LIBDIR="$(get_libdir)" \
768 ${myconf} || die "econf failed" 1064 ${myconf} || die "econf failed"
769 1065
770 # TODO: Move this before autoreconf !!! 1066 # TODO: Move this before autoreconf !!!
771 find . -type f -name Makefile -print0 \ 1067 find . -type f -name Makefile -print0 \
772 | xargs -0 -n100 sed -i \ 1068 | xargs -0 -n100 sed -i \
773 -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)|'
774 1070
775 if [[ $EAPI == 2 ]]; then 1071 if [[ $EAPI == 2 ]] && [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
776 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_configure 1072 pbxt_patch_available && use pbxt && pbxt_src_configure
777 fi 1073 fi
778} 1074}
779 1075
780# @FUNCTION: mysql_src_compile 1076# @FUNCTION: mysql_src_compile
781# @DESCRIPTION: 1077# @DESCRIPTION:
782# Compile the mysql code. 1078# Compile the mysql code.
783mysql_src_compile() { 1079mysql_src_compile() {
784 # Be backwards compatible for now 1080 # Be backwards compatible for now
785 case ${EAPI:-0} in 1081 case ${EAPI:-0} in
786 2) : ;; 1082 2) : ;;
787 0 | 1) mysql_src_configure ;; 1083 0 | 1) mysql_src_configure ;;
788 esac 1084 esac
789 1085
790 emake || die "emake failed" 1086 emake || die "emake failed"
791 1087
792 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile 1088 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
1089 pbxt_patch_available && use pbxt && pbxt_src_compile
1090 fi
793} 1091}
794 1092
795# @FUNCTION: mysql_src_install 1093# @FUNCTION: mysql_src_install
796# @DESCRIPTION: 1094# @DESCRIPTION:
797# Install mysql. 1095# Install mysql.
798mysql_src_install() { 1096mysql_src_install() {
799 # Make sure the vars are correctly initialized 1097 # Make sure the vars are correctly initialized
800 mysql_init_vars 1098 mysql_init_vars
801 1099
802 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed" 1100 emake install \
1101 DESTDIR="${D}" \
1102 benchdir_root=${MY_SHAREDSTATEDIR} \
1103 testroot="${MY_SHAREDSTATEDIR}" \
1104 || die "emake install failed"
803 1105
804 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_install 1106 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
1107 pbxt_patch_available && use pbxt && pbxt_src_install
1108 fi
805 1109
806 # Convenience links 1110 # Convenience links
807 einfo "Making Convenience links for mysqlcheck multi-call binary" 1111 einfo "Making Convenience links for mysqlcheck multi-call binary"
808 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze" 1112 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
809 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair" 1113 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
810 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize" 1114 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
811 1115
812 # Various junk (my-*.cnf moved elsewhere) 1116 # Various junk (my-*.cnf moved elsewhere)
813 einfo "Removing duplicate /usr/share/mysql files" 1117 einfo "Removing duplicate /usr/share/mysql files"
814 rm -Rf "${D}/usr/share/info" 1118 rm -Rf "${ED}/usr/share/info"
815 for removeme in "mysql-log-rotate" mysql.server* \ 1119 for removeme in "mysql-log-rotate" mysql.server* \
816 binary-configure* my-*.cnf mi_test_all* 1120 binary-configure* my-*.cnf mi_test_all*
817 do 1121 do
818 rm -f "${D}"/usr/share/mysql/${removeme} 1122 rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme}
819 done 1123 done
820 1124
821 # Clean up stuff for a minimal build 1125 # Clean up stuff for a minimal build
822 if use minimal ; then 1126 if use minimal ; then
823 einfo "Remove all extra content for minimal build" 1127 einfo "Remove all extra content for minimal build"
824 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench} 1128 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
825 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}
826 rm -f "${D}/usr/sbin/mysqld" 1130 rm -f "${ED}/usr/sbin/mysqld"
827 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
828 fi 1132 fi
829 1133
1134 # Unless they explicitly specific USE=test, then do not install the
1135 # testsuite. It DOES have a use to be installed, esp. when you want to do a
1136 # validation of your database configuration after tuning it.
1137 if use !test ; then
1138 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
1139 fi
1140
830 # Configuration stuff 1141 # Configuration stuff
831 if mysql_version_is_at_least "4.1" ; then 1142 case ${MYSQL_PV_MAJOR} in
832 mysql_mycnf_version="4.1"
833 else
834 mysql_mycnf_version="4.0" 1143 3*|4.0) mysql_mycnf_version="4.0" ;;
835 fi 1144 4.[1-9]|5.0) mysql_mycnf_version="4.1" ;;
836 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})"
837 insinto "${MY_SYSCONFDIR}" 1148 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
838 doins scripts/mysqlaccess.conf 1149 doins scripts/mysqlaccess.conf
1150 mycnf_src="my.cnf-${mysql_mycnf_version}"
839 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ 1151 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
840 "${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}" \
841 > "${TMPDIR}/my.cnf.ok" 1156 > "${TMPDIR}/my.cnf.ok"
842 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"
843 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"
844 fi 1162 fi
845 newins "${TMPDIR}/my.cnf.ok" my.cnf 1163 newins "${TMPDIR}/my.cnf.ok" my.cnf
846 1164
847 # Minimal builds don't have the MySQL server 1165 # Minimal builds don't have the MySQL server
848 if ! use minimal ; then 1166 if ! use minimal ; then
849 einfo "Creating initial directories" 1167 einfo "Creating initial directories"
850 # Empty directories ... 1168 # Empty directories ...
851 diropts "-m0750" 1169 diropts "-m0750"
852 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then 1170 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
853 dodir "${MY_DATADIR}" 1171 dodir "${MY_DATADIR#${EPREFIX}}"
854 keepdir "${MY_DATADIR}" 1172 keepdir "${MY_DATADIR#${EPREFIX}}"
855 chown -R mysql:mysql "${D}/${MY_DATADIR}" 1173 chown -R mysql:mysql "${D}/${MY_DATADIR}"
856 fi 1174 fi
857 1175
858 diropts "-m0755" 1176 diropts "-m0755"
859 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do 1177 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
860 dodir "${folder}" 1178 dodir "${folder}"
861 keepdir "${folder}" 1179 keepdir "${folder}"
862 chown -R mysql:mysql "${D}/${folder}" 1180 chown -R mysql:mysql "${ED}/${folder}"
863 done 1181 done
864 fi 1182 fi
865 1183
866 # Docs 1184 # Docs
867 einfo "Installing docs" 1185 einfo "Installing docs"
868 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE 1186 for i in README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE ; do
1187 [[ -f "$i" ]] && dodoc "$i"
1188 done
869 doinfo "${S}"/Docs/mysql.info 1189 doinfo "${S}"/Docs/mysql.info
870 1190
871 # Minimal builds don't have the MySQL server 1191 # Minimal builds don't have the MySQL server
872 if ! use minimal ; then 1192 if ! use minimal ; then
873 einfo "Including support files and sample configurations" 1193 einfo "Including support files and sample configurations"
875 for script in \ 1195 for script in \
876 "${S}"/support-files/my-*.cnf \ 1196 "${S}"/support-files/my-*.cnf \
877 "${S}"/support-files/magic \ 1197 "${S}"/support-files/magic \
878 "${S}"/support-files/ndb-config-2-node.ini 1198 "${S}"/support-files/ndb-config-2-node.ini
879 do 1199 do
880 dodoc "${script}" 1200 [[ -f "$script" ]] && dodoc "${script}"
881 done 1201 done
882 1202
883 docinto "scripts" 1203 docinto "scripts"
884 for script in "${S}"/scripts/mysql* ; do 1204 for script in "${S}"/scripts/mysql* ; do
885 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}" 1205 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
886 done 1206 done
887 1207
888 fi 1208 fi
889 1209
890 mysql_lib_symlinks "${D}" 1210 mysql_lib_symlinks "${ED}"
891} 1211}
892 1212
893# @FUNCTION: mysql_pkg_preinst 1213# @FUNCTION: mysql_pkg_preinst
894# @DESCRIPTION: 1214# @DESCRIPTION:
895# Create the user and groups for mysql - die if that fails. 1215# Create the user and groups for mysql - die if that fails.
909mysql_pkg_postinst() { 1229mysql_pkg_postinst() {
910 # Make sure the vars are correctly initialized 1230 # Make sure the vars are correctly initialized
911 mysql_init_vars 1231 mysql_init_vars
912 1232
913 # Check FEATURES="collision-protect" before removing this 1233 # Check FEATURES="collision-protect" before removing this
914 [[ -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}"
915 1235
916 # Secure the logfiles 1236 # Secure the logfiles
917 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 1237 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
918 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 1238 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
919 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 1239 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
924 for script in \ 1244 for script in \
925 support-files/my-*.cnf \ 1245 support-files/my-*.cnf \
926 support-files/magic \ 1246 support-files/magic \
927 support-files/ndb-config-2-node.ini 1247 support-files/ndb-config-2-node.ini
928 do 1248 do
1249 [[ -f "${script}" ]] \
929 dodoc "${script}" 1250 && dodoc "${script}"
930 done 1251 done
931 1252
932 docinto "scripts" 1253 docinto "scripts"
933 for script in scripts/mysql* ; do 1254 for script in scripts/mysql* ; do
1255 [[ -f "${script}" ]] \
934 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}" 1256 && [[ "${script%.sh}" == "${script}" ]] \
1257 && dodoc "${script}"
935 done 1258 done
936 1259
937 einfo 1260 einfo
938 elog "You might want to run:" 1261 elog "You might want to run:"
939 elog "\"emerge --config =${CATEGORY}/${PF}\"" 1262 elog "\"emerge --config =${CATEGORY}/${PF}\""
940 elog "if this is a new install." 1263 elog "if this is a new install."
941 einfo 1264 einfo
942 fi
943 1265
944 if mysql_version_is_at_least "5.1.12" && use pbxt ; then 1266 einfo
945 # TODO: explain it better 1267 elog "If you are upgrading major versions, you should run the"
946 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" 1268 elog "mysql_upgrade tool."
947 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" 1269 einfo
948 elog "if, after that, you cannot start the MySQL server," 1270 fi
1271
1272 if pbxt_available && use pbxt ; then
1273 elog "Note: PBXT is now statically built when enabled."
1274 elog ""
1275 elog "If, you previously installed as a plugin and "
1276 elog "you cannot start the MySQL server,"
949 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" 1277 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
950 elog "use the MySQL upgrade script to restore the table" 1278 elog "use the MySQL upgrade script to restore the table"
951 elog "or execute the following SQL command:" 1279 elog "or execute the following SQL command:"
952 elog " CREATE TABLE IF NOT EXISTS plugin (" 1280 elog " CREATE TABLE IF NOT EXISTS plugin ("
953 elog " name char(64) binary DEFAULT '' NOT NULL," 1281 elog " name char(64) binary DEFAULT '' NOT NULL,"
959 mysql_check_version_range "4.0 to 5.0.99.99" \ 1287 mysql_check_version_range "4.0 to 5.0.99.99" \
960 && use berkdb \ 1288 && use berkdb \
961 && 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!"
962} 1290}
963 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
964# @FUNCTION: mysql_pkg_config 1312# @FUNCTION: mysql_pkg_config
965# @DESCRIPTION: 1313# @DESCRIPTION:
966# Configure mysql environment. 1314# Configure mysql environment.
967mysql_pkg_config() { 1315mysql_pkg_config() {
968 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
969 1320
970 # Make sure the vars are correctly initialized 1321 # Make sure the vars are correctly initialized
971 mysql_init_vars 1322 mysql_init_vars
972 1323
973 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 1324 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
975 if built_with_use ${CATEGORY}/${PN} minimal ; then 1326 if built_with_use ${CATEGORY}/${PN} minimal ; then
976 die "Minimal builds do NOT include the MySQL server" 1327 die "Minimal builds do NOT include the MySQL server"
977 fi 1328 fi
978 1329
979 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 1330 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
980 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%%/}"
981 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%%/}"
982 1335
983 if [[ -d "${old_MY_DATADIR_s}" ]]; then 1336 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
984 if [[ -d "${MY_DATADIR_s}" ]]; then 1337 if [[ -d "${MY_DATADIR_s}" ]]; then
985 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 1338 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
986 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}"
987 else 1340 else
988 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}"
1000 fi 1353 fi
1001 fi 1354 fi
1002 1355
1003 local pwd1="a" 1356 local pwd1="a"
1004 local pwd2="b" 1357 local pwd2="b"
1005 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
1006 1382
1007 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 1383 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1008 ewarn "You have already a MySQL database in place." 1384 ewarn "You have already a MySQL database in place."
1009 ewarn "(${ROOT}/${MY_DATADIR}/*)" 1385 ewarn "(${ROOT}/${MY_DATADIR}/*)"
1010 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."
1013 1389
1014 # Bug #213475 - MySQL _will_ object strenously if your machine is named 1390 # Bug #213475 - MySQL _will_ object strenously if your machine is named
1015 # localhost. Also causes weird failures. 1391 # localhost. Also causes weird failures.
1016 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" 1392 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1017 1393
1018 einfo "Creating the mysql database and setting proper" 1394 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1019 einfo "permissions on it ..."
1020 1395
1021 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."
1022 ewarn "Avoid [\"'\\_%] characters in the password" 1398 ewarn "Avoid [\"'\\_%] characters in the password"
1023 read -rsp " >" pwd1 ; echo 1399 read -rsp " >" pwd1 ; echo
1024 1400
1025 einfo "Retype the password" 1401 einfo "Retype the password"
1026 read -rsp " >" pwd2 ; echo 1402 read -rsp " >" pwd2 ; echo
1027 1403
1028 if [[ "x$pwd1" != "x$pwd2" ]] ; then 1404 if [[ "x$pwd1" != "x$pwd2" ]] ; then
1029 die "Passwords are not the same" 1405 die "Passwords are not the same"
1030 fi 1406 fi
1407 MYSQL_ROOT_PASSWORD="${pwd1}"
1408 unset pwd1 pwd2
1409 fi
1031 1410
1032 local options="" 1411 local options="--log-warnings=0"
1033 local sqltmp="$(emktemp)" 1412 local sqltmp="$(emktemp)"
1034 1413
1035 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 1414 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
1036 [[ -r "${help_tables}" ]] \ 1415 [[ -r "${help_tables}" ]] \
1037 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 1416 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
1038 || touch "${TMPDIR}/fill_help_tables.sql" 1417 || touch "${TMPDIR}/fill_help_tables.sql"
1039 help_tables="${TMPDIR}/fill_help_tables.sql" 1418 help_tables="${TMPDIR}/fill_help_tables.sql"
1040 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
1041 pushd "${TMPDIR}" &>/dev/null 1436 pushd "${TMPDIR}" &>/dev/null
1042 "${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
1043 if [ $? -ne 0 ]; then 1444 if [ $? -ne 0 ]; then
1044 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
1045 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"
1046 fi 1447 fi
1047 popd &>/dev/null 1448 popd &>/dev/null
1048 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 1449 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1049 || die "MySQL databases not installed" 1450 || die "MySQL databases not installed"
1050 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 1451 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1051 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 1452 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1052 1453
1053 if mysql_version_is_at_least "4.1.3" ; then 1454 if mysql_version_is_at_least "4.1.3" ; then
1054 options="--skip-ndbcluster"
1055
1056 # Filling timezones, see 1455 # Filling timezones, see
1057 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 1456 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1058 "${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
1059 1458
1060 if [[ -r "${help_tables}" ]] ; then 1459 if [[ -r "${help_tables}" ]] ; then
1061 cat "${help_tables}" >> "${sqltmp}" 1460 cat "${help_tables}" >> "${sqltmp}"
1062 fi 1461 fi
1063 fi 1462 fi
1064 1463
1464 einfo "Creating the mysql database and setting proper"
1465 einfo "permissions on it ..."
1466
1065 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 1467 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1066 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 1468 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1067 local mysqld="${ROOT}/usr/sbin/mysqld \ 1469 local mysqld="${EROOT}/usr/sbin/mysqld \
1068 ${options} \ 1470 ${options} \
1069 --user=mysql \ 1471 $(use prefix || echo --user=mysql) \
1070 --skip-grant-tables \ 1472 --log-warnings=0 \
1071 --basedir=${ROOT}/usr \ 1473 --basedir=${EROOT}/usr \
1072 --datadir=${ROOT}/${MY_DATADIR} \ 1474 --datadir=${ROOT}/${MY_DATADIR} \
1073 --skip-innodb \
1074 --skip-bdb \
1075 --skip-networking \
1076 --max_allowed_packet=8M \ 1475 --max_allowed_packet=8M \
1077 --net_buffer_length=16K \ 1476 --net_buffer_length=16K \
1477 --default-storage-engine=MyISAM \
1078 --socket=${socket} \ 1478 --socket=${socket} \
1079 --pid-file=${pidfile}" 1479 --pid-file=${pidfile}"
1480 #einfo "About to start mysqld: ${mysqld}"
1481 ebegin "Starting mysqld"
1482 einfo "Command ${mysqld}"
1080 ${mysqld} & 1483 ${mysqld} &
1484 rc=$?
1081 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 1485 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1082 maxtry=$((${maxtry}-1)) 1486 maxtry=$((${maxtry}-1))
1083 echo -n "." 1487 echo -n "."
1084 sleep 1 1488 sleep 1
1085 done 1489 done
1490 eend $rc
1086 1491
1492 if ! [[ -S "${socket}" ]]; then
1493 die "Completely failed to start up mysqld with: ${mysqld}"
1494 fi
1495
1496 ebegin "Setting root password"
1087 # 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
1088 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'"
1089 "${ROOT}/usr/bin/mysql" \ 1499 "${EROOT}/usr/bin/mysql" \
1090 --socket=${socket} \ 1500 --socket=${socket} \
1091 -hlocalhost \ 1501 -hlocalhost \
1092 -e "${sql}" 1502 -e "${sql}"
1503 eend $?
1093 1504
1094 einfo "Loading \"zoneinfo\", this step may require a few seconds ..." 1505 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
1095
1096 "${ROOT}/usr/bin/mysql" \ 1506 "${EROOT}/usr/bin/mysql" \
1097 --socket=${socket} \ 1507 --socket=${socket} \
1098 -hlocalhost \ 1508 -hlocalhost \
1099 -uroot \ 1509 -uroot \
1100 -p"${pwd1}" \ 1510 --password="${MYSQL_ROOT_PASSWORD}" \
1101 mysql < "${sqltmp}" 1511 mysql < "${sqltmp}"
1512 rc=$?
1513 eend $?
1514 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
1102 1515
1103 # Stop the server and cleanup 1516 # Stop the server and cleanup
1517 einfo "Stopping the server ..."
1104 kill $(< "${pidfile}" ) 1518 kill $(< "${pidfile}" )
1105 rm -f "${sqltmp}" 1519 rm -f "${sqltmp}"
1106 einfo "Stopping the server ..."
1107 wait %1 1520 wait %1
1108 einfo "Done" 1521 einfo "Done"
1109} 1522}
1110 1523
1111# @FUNCTION: mysql_pkg_postrm 1524# @FUNCTION: mysql_pkg_postrm
1112# @DESCRIPTION: 1525# @DESCRIPTION:
1113# Remove mysql symlinks. 1526# Remove mysql symlinks.
1114mysql_pkg_postrm() { 1527mysql_pkg_postrm() {
1115 : # mysql_lib_symlinks "${D}" 1528 : # mysql_lib_symlinks "${ED}"
1116} 1529}

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

  ViewVC Help
Powered by ViewVC 1.1.20