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

Diff of /eclass/mysql-v2.eclass

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

Revision 1.4 Revision 1.21
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.4 2011/07/21 05:57:22 jmbsvicetto Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.21 2012/11/01 23:57:50 robbat2 Exp $
4 4
5# @ECLASS: mysql-v2.eclass 5# @ECLASS: mysql-v2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Maintainers: 7# Maintainers:
8# - MySQL Team <mysql-bugs@gentoo.org> 8# - MySQL Team <mysql-bugs@gentoo.org>
13# The mysql-v2.eclass is the base eclass to build the mysql and 13# The mysql-v2.eclass is the base eclass to build the mysql and
14# alternative projects (mariadb) ebuilds. 14# alternative projects (mariadb) ebuilds.
15# This eclass uses the mysql-autotools and mysql-cmake eclasses for the 15# This eclass uses the mysql-autotools and mysql-cmake eclasses for the
16# specific bits related to the build system. 16# specific bits related to the build system.
17# It provides the src_unpack, src_prepare, src_configure, src_compile, 17# It provides the src_unpack, src_prepare, src_configure, src_compile,
18# scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm 18# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
19# phase hooks. 19# phase hooks.
20 20
21# @ECLASS-VARIABLE: BUILD 21# @ECLASS-VARIABLE: BUILD
22# @DESCRIPTION:
22# @DESCRIPTION: Build type of the mysql version 23# Build type of the mysql version
23# The default value is autotools
24: ${BUILD:=autotools} 24: ${BUILD:=autotools}
25 25
26case ${BUILD} in 26case ${BUILD} in
27 "cmake") 27 "cmake")
28 BUILD_INHERIT="mysql-cmake" 28 BUILD_INHERIT="mysql-cmake"
39esac 39esac
40 40
41MYSQL_EXTRAS="" 41MYSQL_EXTRAS=""
42 42
43# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER 43# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
44# @DESCRIPTION:
44# @DESCRIPTION: The version of the MYSQL_EXTRAS repo to use to build mysql 45# The version of the MYSQL_EXTRAS repo to use to build mysql
46# Use "none" to disable it's use
45[[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2" 47[[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2"
46 48
47inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs 49inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs
48 50
49# 51#
50# Supported EAPI versions and export functions 52# Supported EAPI versions and export functions
51# 53#
52 54
53case "${EAPI:-0}" in 55case "${EAPI:-0}" in
54 2|3|4) ;; 56 3|4|5) ;;
55 *) die "Unsupported EAPI: ${EAPI}" ;; 57 *) die "Unsupported EAPI: ${EAPI}" ;;
56esac 58esac
57 59
58EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm 60EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm
59 61
75# @DESCRIPTION: 77# @DESCRIPTION:
76# Upstream MySQL considers the first two parts of the version number to be the 78# Upstream MySQL considers the first two parts of the version number to be the
77# major version. Upgrades that change major version should always run 79# major version. Upgrades that change major version should always run
78# mysql_upgrade. 80# mysql_upgrade.
79MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" 81MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
80
81# Cluster is a special case...
82if [[ "${PN}" == "mysql-cluster" ]]; then
83 case $PV in
84 6.1*|7.0*|7.1*) MYSQL_PV_MAJOR=5.1 ;;
85 esac
86fi
87
88 82
89# @ECLASS-VARIABLE: MYSQL_VERSION_ID 83# @ECLASS-VARIABLE: MYSQL_VERSION_ID
90# @DESCRIPTION: 84# @DESCRIPTION:
91# MYSQL_VERSION_ID will be: 85# MYSQL_VERSION_ID will be:
92# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] 86# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
106MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} 100MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
107 101
108# This eclass should only be used with at least mysql-5.1.50 102# This eclass should only be used with at least mysql-5.1.50
109mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50" 103mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50"
110 104
111# @ECLASS-VARIABLE: MYSQL_COMMUNITY_FEATURES
112# @DESCRIPTION:
113# Specifiy if community features are available. Possible values are 1 (yes)
114# and 0 (no).
115# Community features are available in mysql-community
116# AND in the re-merged mysql-5.0.82 and newer
117if [ "${PN}" == "mysql-community" -o "${PN}" == "mariadb" ]; then
118 MYSQL_COMMUNITY_FEATURES=1
119elif [ "${MYSQL_PV_MAJOR}" == "5.1" ]; then
120 MYSQL_COMMUNITY_FEATURES=1
121elif mysql_version_is_at_least "5.4.0"; then
122 MYSQL_COMMUNITY_FEATURES=1
123else
124 MYSQL_COMMUNITY_FEATURES=0
125fi
126
127
128# @ECLASS-VARIABLE: XTRADB_VER 105# @ECLASS-VARIABLE: XTRADB_VER
129# @DEFAULT_UNSET 106# @DEFAULT_UNSET
130# @DESCRIPTION: 107# @DESCRIPTION:
131# Version of the XTRADB storage engine 108# Version of the XTRADB storage engine
132 109
137 114
138# Work out the default SERVER_URI correctly 115# Work out the default SERVER_URI correctly
139if [ -z "${SERVER_URI}" ]; then 116if [ -z "${SERVER_URI}" ]; then
140 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}" 117 [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
141 if [ "${PN}" == "mariadb" ]; then 118 if [ "${PN}" == "mariadb" ]; then
142 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})" 119 MARIA_FULL_PV="$(replace_version_separator 3 '-' ${MY_PV})"
143 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}" 120 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
144 SERVER_URI=" 121 SERVER_URI="
145 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 122 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
146 http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 123 http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
147 http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 124 http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
148 http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz 125 http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz
149 http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 126 http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
150 http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz 127 http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
151 " 128 "
152 # The community and cluster builds are on the mirrors
153 elif [[ "${MYSQL_COMMUNITY_FEATURES}" == "1" || ${PN} == "mysql-cluster" ]] ; then
154 if [[ "${PN}" == "mysql-cluster" ]] ; then
155 URI_DIR="MySQL-Cluster"
156 URI_FILE="mysql-cluster-gpl"
157 else 129 else
158 URI_DIR="MySQL" 130 URI_DIR="MySQL"
159 URI_FILE="mysql" 131 URI_FILE="mysql"
160 fi
161 URI_A="${URI_FILE}-${MY_PV}.tar.gz" 132 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
162 MIRROR_PV=$(get_version_component_range 1-2 ${PV}) 133 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
163 # Recently upstream switched to an archive site, and not on mirrors 134 # Recently upstream switched to an archive site, and not on mirrors
164 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A} 135 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
165 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}" 136 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
166 # The (old) enterprise source is on the primary site only
167 elif [ "${PN}" == "mysql" ]; then
168 SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz"
169 fi 137 fi
170fi 138fi
171 139
172# Define correct SRC_URIs 140# Define correct SRC_URIs
173SRC_URI="${SERVER_URI}" 141SRC_URI="${SERVER_URI}"
174 142
175# Gentoo patches to MySQL 143# Gentoo patches to MySQL
176[[ ${MY_EXTRAS_VER} != live ]] \ 144[[ ${MY_EXTRAS_VER} != live ]] && [[ ${MY_EXTRAS_VER} != none ]] \
177&& SRC_URI="${SRC_URI} 145&& SRC_URI="${SRC_URI}
178 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 146 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
179 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 147 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
180 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 148 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
181 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" 149 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
183DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." 151DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
184HOMEPAGE="http://www.mysql.com/" 152HOMEPAGE="http://www.mysql.com/"
185if [[ "${PN}" == "mariadb" ]]; then 153if [[ "${PN}" == "mariadb" ]]; then
186 HOMEPAGE="http://mariadb.org/" 154 HOMEPAGE="http://mariadb.org/"
187 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged." 155 DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
188fi
189if [[ "${PN}" == "mysql-community" ]]; then
190 DESCRIPTION="${DESCRIPTION} (obsolete, move to dev-db/mysql)"
191fi 156fi
192LICENSE="GPL-2" 157LICENSE="GPL-2"
193SLOT="0" 158SLOT="0"
194 159
195case "${BUILD}" in 160case "${BUILD}" in
202esac 167esac
203 168
204IUSE="${IUSE} latin1" 169IUSE="${IUSE} latin1"
205 170
206IUSE="${IUSE} extraengine" 171IUSE="${IUSE} extraengine"
207if [[ ${PN} != "mysql-cluster" ]] ; then
208 IUSE="${IUSE} cluster" 172IUSE="${IUSE} cluster"
209fi
210 173
211IUSE="${IUSE} max-idx-128" 174IUSE="${IUSE} max-idx-128"
212IUSE="${IUSE} berkdb" 175IUSE="${IUSE} berkdb"
213
214[[ ${MYSQL_COMMUNITY_FEATURES} == 1 ]] \
215&& IUSE="${IUSE} +community profiling" 176IUSE="${IUSE} +community profiling"
216 177
217[[ ${PN} == "mariadb" ]] \ 178[[ ${PN} == "mariadb" ]] \
179&& mysql_check_version_range "5.1.38 to 5.3.99" \
218&& IUSE="${IUSE} libevent" 180&& IUSE="${IUSE} libevent"
219 181
220[[ ${PN} == "mariadb" ]] \ 182[[ ${PN} == "mariadb" ]] \
221&& mysql_version_is_at_least "5.2" \ 183&& mysql_version_is_at_least "5.2" \
222&& IUSE="${IUSE} oqgraph" 184&& IUSE="${IUSE} oqgraph"
223 185
224[[ ${PN} == "mariadb" ]] \ 186[[ ${PN} == "mariadb" ]] \
225&& mysql_version_is_at_least "5.2.5" \ 187&& mysql_version_is_at_least "5.2.5" \
226&& IUSE="${IUSE} sphinx" 188&& IUSE="${IUSE} sphinx"
227 189
190if mysql_version_is_at_least "5.5"; then
191 REQUIRED_USE="tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )"
192 IUSE="${IUSE} jemalloc tcmalloc"
193fi
194
195mysql_version_is_at_least "5.5.7" \
196&& IUSE="${IUSE} systemtap"
228 197
229# 198#
230# DEPENDENCIES: 199# DEPENDENCIES:
231# 200#
232 201
233# Be warned, *DEPEND are version-dependant 202# Be warned, *DEPEND are version-dependant
234# These are used for both runtime and compiletime 203# These are used for both runtime and compiletime
235DEPEND=" 204DEPEND="
236 ssl? ( >=dev-libs/openssl-0.9.6d ) 205 ssl? ( >=dev-libs/openssl-0.9.6d )
237 userland_GNU? ( sys-process/procps ) 206 kernel_linux? ( sys-process/procps )
238 >=sys-apps/sed-4 207 >=sys-apps/sed-4
239 >=sys-apps/texinfo-4.7-r1 208 >=sys-apps/texinfo-4.7-r1
240 >=sys-libs/readline-4.1 209 >=sys-libs/readline-4.1
241 >=sys-libs/zlib-1.2.3 210 >=sys-libs/zlib-1.2.3
242" 211"
243 212
244[[ ${PN} == mariadb ]] \ 213[[ ${PN} == mariadb ]] \
214&& mysql_check_version_range "5.1.38 to 5.3.99" \
245&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" 215&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
246 216
247# Having different flavours at the same time is not a good idea 217# Having different flavours at the same time is not a good idea
248for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do 218for i in "mysql" "mariadb" ; do
249 [[ ${i} == ${PN} ]] || 219 [[ ${i} == ${PN} ]] ||
250 DEPEND="${DEPEND} !dev-db/${i}" 220 DEPEND="${DEPEND} !dev-db/${i}"
251done 221done
252 222
223# prefix: first need to implement something for #196294
253RDEPEND="${DEPEND} 224RDEPEND="${DEPEND}
254 !minimal? ( dev-db/mysql-init-scripts ) 225 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
255 selinux? ( sec-policy/selinux-mysql ) 226 selinux? ( sec-policy/selinux-mysql )
256" 227"
257 228
229DEPEND="${DEPEND}
230 virtual/yacc
231"
232
258DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )" 233DEPEND="${DEPEND} static? ( sys-libs/ncurses[static-libs] )"
259 234
260# compile-time-only 235# compile-time-only
261DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 236DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
262 237
263# compile-time-only 238# compile-time-only
270 245
271[[ "${PN}" == "mariadb" ]] \ 246[[ "${PN}" == "mariadb" ]] \
272&& mysql_version_is_at_least "5.2.5" \ 247&& mysql_version_is_at_least "5.2.5" \
273&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" 248&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
274 249
250mysql_version_is_at_least "5.5.7" \
251&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )" \
252&& DEPEND="${DEPEND} kernel_linux? ( dev-libs/libaio )"
253
254mysql_version_is_at_least "5.5" \
255&& DEPEND="${DEPEND} jemalloc? ( dev-libs/jemalloc )"
256
257mysql_version_is_at_least "5.5" \
258&& DEPEND="${DEPEND} tcmalloc? ( dev-util/google-perftools )"
259
275# dev-perl/DBD-mysql is needed by some scripts installed by MySQL 260# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
276PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 261PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
277 262
278# For other stuff to bring us in 263# For other stuff to bring us in
279PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" 264PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
280
281 265
282# 266#
283# External patches 267# External patches
284# 268#
285 269
312 296
313 PBXT_P="pbxt-${PBXT_VERSION}" 297 PBXT_P="pbxt-${PBXT_VERSION}"
314 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" 298 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz"
315 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" 299 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
316 300
301fi
302
317 # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins 303# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
318 # vs. built outside the dir 304# vs. built outside the dir
319 if pbxt_available; then 305if pbxt_available; then
320 306
321 IUSE="${IUSE} pbxt" 307 IUSE="${IUSE} pbxt"
322 PBXT_NEWSTYLE=1 308 PBXT_NEWSTYLE=1
323 fi
324fi 309fi
325 310
326if xtradb_patch_available; then 311if xtradb_patch_available; then
327 XTRADB_P="percona-xtradb-${XTRADB_VER}" 312 XTRADB_P="percona-xtradb-${XTRADB_VER}"
328 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" 313 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz"
373# warn about deprecated features 358# warn about deprecated features
374mysql-v2_pkg_setup() { 359mysql-v2_pkg_setup() {
375 360
376 if has test ${FEATURES} ; then 361 if has test ${FEATURES} ; then
377 if ! use minimal ; then 362 if ! use minimal ; then
378 if [[ $UID -eq 0 ]]; then 363 if ! has userpriv ${FEATURES} ; then
379 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." 364 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
380 fi 365 fi
381 fi 366 fi
382 fi 367 fi
383 368
411 396
412 # This should come after all of the die statements 397 # This should come after all of the die statements
413 enewgroup mysql 60 || die "problem adding 'mysql' group" 398 enewgroup mysql 60 || die "problem adding 'mysql' group"
414 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" 399 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
415 400
416 if [ "${PN}" != "mysql-cluster" ] && use cluster; then 401 if use cluster; then
417 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and" 402 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
418 ewarn "5.1 series should NOT be put into production. In the near" 403 ewarn "5.1 series should NOT be put into production. In the near"
419 ewarn "future, it will be disabled from building." 404 ewarn "future, it will be disabled from building."
420 ewarn ""
421 ewarn "If you need NDB support, you should instead move to the new"
422 ewarn "mysql-cluster package that represents that upstream NDB"
423 ewarn "development."
424 fi 405 fi
425} 406}
426 407
427# @FUNCTION: mysql-v2_src_unpack 408# @FUNCTION: mysql-v2_src_unpack
428# @DESCRIPTION: 409# @DESCRIPTION:
487 468
488 # Make sure the vars are correctly initialized 469 # Make sure the vars are correctly initialized
489 mysql_init_vars 470 mysql_init_vars
490 471
491 # Check FEATURES="collision-protect" before removing this 472 # Check FEATURES="collision-protect" before removing this
492 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 473 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
493 474
494 # Secure the logfiles 475 # Secure the logfiles
495 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 476 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
496 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 477 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
497 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 478 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
526 elog "mysql_upgrade tool." 507 elog "mysql_upgrade tool."
527 einfo 508 einfo
528 fi 509 fi
529 510
530 if pbxt_available && use pbxt ; then 511 if pbxt_available && use pbxt ; then
531 # TODO: explain it better 512 elog "Note: PBXT is now statically built when enabled."
532 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" 513 elog ""
533 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" 514 elog "If, you previously installed as a plugin and "
534 elog "if, after that, you cannot start the MySQL server," 515 elog "you cannot start the MySQL server,"
535 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" 516 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
536 elog "use the MySQL upgrade script to restore the table" 517 elog "use the MySQL upgrade script to restore the table"
537 elog "or execute the following SQL command:" 518 elog "or execute the following SQL command:"
538 elog " CREATE TABLE IF NOT EXISTS plugin (" 519 elog " CREATE TABLE IF NOT EXISTS plugin ("
539 elog " name char(64) binary DEFAULT '' NOT NULL," 520 elog " name char(64) binary DEFAULT '' NOT NULL,"
545 mysql_check_version_range "4.0 to 5.0.99.99" \ 526 mysql_check_version_range "4.0 to 5.0.99.99" \
546 && use berkdb \ 527 && use berkdb \
547 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 528 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
548} 529}
549 530
531# @FUNCTION: mysql-v2_getopt
532# @DESCRIPTION:
533# Use my_print_defaults to extract specific config options
534mysql-v2_getopt() {
535 local mypd="${EROOT}"/usr/bin/my_print_defaults
536 section="$1"
537 flag="--${2}="
538 "${mypd}" $section | sed -n "/^${flag}/p"
539}
540
541# @FUNCTION: mysql-v2_getoptval
542# @DESCRIPTION:
543# Use my_print_defaults to extract specific config options
544mysql-v2_getoptval() {
545 local mypd="${EROOT}"/usr/bin/my_print_defaults
546 section="$1"
547 flag="--${2}="
548 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
549}
550
550# @FUNCTION: mysql-v2_pkg_config 551# @FUNCTION: mysql-v2_pkg_config
551# @DESCRIPTION: 552# @DESCRIPTION:
552# Configure mysql environment. 553# Configure mysql environment.
553mysql-v2_pkg_config() { 554mysql-v2_pkg_config() {
554 555
555 local old_MY_DATADIR="${MY_DATADIR}" 556 local old_MY_DATADIR="${MY_DATADIR}"
557 local old_HOME="${HOME}"
558 # my_print_defaults needs to read stuff in $HOME/.my.cnf
559 export HOME=/root
556 560
557 # Make sure the vars are correctly initialized 561 # Make sure the vars are correctly initialized
558 mysql_init_vars 562 mysql_init_vars
559 563
560 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 564 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
562 if built_with_use ${CATEGORY}/${PN} minimal ; then 566 if built_with_use ${CATEGORY}/${PN} minimal ; then
563 die "Minimal builds do NOT include the MySQL server" 567 die "Minimal builds do NOT include the MySQL server"
564 fi 568 fi
565 569
566 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 570 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
567 local MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${MY_DATADIR})" 571 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
572 MY_DATADIR_s="${MY_DATADIR_s%%/}"
568 local old_MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${old_MY_DATADIR})" 573 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
574 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
569 575
570 if [[ -d "${old_MY_DATADIR_s}" ]]; then 576 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
571 if [[ -d "${MY_DATADIR_s}" ]]; then 577 if [[ -d "${MY_DATADIR_s}" ]]; then
572 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 578 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
573 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" 579 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
574 else 580 else
575 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" 581 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
589 595
590 local pwd1="a" 596 local pwd1="a"
591 local pwd2="b" 597 local pwd2="b"
592 local maxtry=15 598 local maxtry=15
593 599
594 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then 600 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
595 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" 601 MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)"
602 fi
603 MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)"
604 # These are dir+prefix
605 MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)"
606 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
607 MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)"
608 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
609
610 if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then
611 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
612 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
613 fi
614 if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then
615 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
616 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
617 fi
618 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
619 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
620 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
596 fi 621 fi
597 622
598 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 623 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
599 ewarn "You have already a MySQL database in place." 624 ewarn "You have already a MySQL database in place."
600 ewarn "(${ROOT}/${MY_DATADIR}/*)" 625 ewarn "(${ROOT}/${MY_DATADIR}/*)"
621 fi 646 fi
622 MYSQL_ROOT_PASSWORD="${pwd1}" 647 MYSQL_ROOT_PASSWORD="${pwd1}"
623 unset pwd1 pwd2 648 unset pwd1 pwd2
624 fi 649 fi
625 650
626 local options="" 651 local options="--log-warnings=0"
627 local sqltmp="$(emktemp)" 652 local sqltmp="$(emktemp)"
628 653
629 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 654 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
630 [[ -r "${help_tables}" ]] \ 655 [[ -r "${help_tables}" ]] \
631 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 656 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
632 || touch "${TMPDIR}/fill_help_tables.sql" 657 || touch "${TMPDIR}/fill_help_tables.sql"
633 help_tables="${TMPDIR}/fill_help_tables.sql" 658 help_tables="${TMPDIR}/fill_help_tables.sql"
659
660 # Figure out which options we need to disable to do the setup
661 helpfile="${TMPDIR}/mysqld-help"
662 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
663 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
664 federated innodb ssl log-bin relay-log slow-query-log external-locking \
665 ndbcluster log-slave-updates \
666 ; do
667 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
668 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
669 done
670 # But some options changed names
671 egrep -sq external-locking "${helpfile}" && \
672 options="${options/skip-locking/skip-external-locking}"
673
674 use prefix || options="${options} --user=mysql"
634 675
635 pushd "${TMPDIR}" &>/dev/null 676 pushd "${TMPDIR}" &>/dev/null
636 "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 677 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
678 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
679 [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db
680 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}"
681 einfo "Command: $cmd"
682 eval $cmd \
683 >"${TMPDIR}"/mysql_install_db.log 2>&1
637 if [ $? -ne 0 ]; then 684 if [ $? -ne 0 ]; then
638 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 685 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
639 die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" 686 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
640 fi 687 fi
641 popd &>/dev/null 688 popd &>/dev/null
642 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 689 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
643 || die "MySQL databases not installed" 690 || die "MySQL databases not installed"
644 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 691 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
645 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 692 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
646 693
647 # Figure out which options we need to disable to do the setup
648 helpfile="${TMPDIR}/mysqld-help"
649 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
650 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
651 federated innodb ssl log-bin relay-log slow-query-log external-locking \
652 ndbcluster \
653 ; do
654 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
655 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
656 done
657 # But some options changed names
658 egrep -sq external-locking "${helpfile}" && \
659 options="${options/skip-locking/skip-external-locking}"
660
661 # Filling timezones, see 694 # Filling timezones, see
662 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 695 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
663 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null 696 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
664 697
665 if [[ -r "${help_tables}" ]] ; then 698 if [[ -r "${help_tables}" ]] ; then
666 cat "${help_tables}" >> "${sqltmp}" 699 cat "${help_tables}" >> "${sqltmp}"
667 fi 700 fi
668 701
669 einfo "Creating the mysql database and setting proper" 702 einfo "Creating the mysql database and setting proper"
670 einfo "permissions on it ..." 703 einfo "permissions on it ..."
671 704
672 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 705 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
673 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 706 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
674 local mysqld="${ROOT}/usr/sbin/mysqld \ 707 local mysqld="${EROOT}/usr/sbin/mysqld \
675 ${options} \ 708 ${options} \
676 --user=mysql \ 709 --user=mysql \
710 --log-warnings=0 \
677 --basedir=${ROOT}/usr \ 711 --basedir=${EROOT}/usr \
678 --datadir=${ROOT}/${MY_DATADIR} \ 712 --datadir=${ROOT}/${MY_DATADIR} \
679 --max_allowed_packet=8M \ 713 --max_allowed_packet=8M \
680 --net_buffer_length=16K \ 714 --net_buffer_length=16K \
681 --default-storage-engine=MyISAM \ 715 --default-storage-engine=MyISAM \
682 --socket=${socket} \ 716 --socket=${socket} \
683 --pid-file=${pidfile}" 717 --pid-file=${pidfile}"
684 #einfo "About to start mysqld: ${mysqld}" 718 #einfo "About to start mysqld: ${mysqld}"
685 ebegin "Starting mysqld" 719 ebegin "Starting mysqld"
720 einfo "Command ${mysqld}"
686 ${mysqld} & 721 ${mysqld} &
687 rc=$? 722 rc=$?
688 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 723 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
689 maxtry=$((${maxtry}-1)) 724 maxtry=$((${maxtry}-1))
690 echo -n "." 725 echo -n "."
697 fi 732 fi
698 733
699 ebegin "Setting root password" 734 ebegin "Setting root password"
700 # Do this from memory, as we don't want clear text passwords in temp files 735 # Do this from memory, as we don't want clear text passwords in temp files
701 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" 736 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
702 "${ROOT}/usr/bin/mysql" \ 737 "${EROOT}/usr/bin/mysql" \
703 --socket=${socket} \ 738 --socket=${socket} \
704 -hlocalhost \ 739 -hlocalhost \
705 -e "${sql}" 740 -e "${sql}"
706 eend $? 741 eend $?
707 742
708 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 743 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
709 "${ROOT}/usr/bin/mysql" \ 744 "${EROOT}/usr/bin/mysql" \
710 --socket=${socket} \ 745 --socket=${socket} \
711 -hlocalhost \ 746 -hlocalhost \
712 -uroot \ 747 -uroot \
713 -p"${MYSQL_ROOT_PASSWORD}" \ 748 --password="${MYSQL_ROOT_PASSWORD}" \
714 mysql < "${sqltmp}" 749 mysql < "${sqltmp}"
715 rc=$? 750 rc=$?
716 eend $? 751 eend $?
717 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!" 752 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
718 753
727# @FUNCTION: mysql-v2_pkg_postrm 762# @FUNCTION: mysql-v2_pkg_postrm
728# @DESCRIPTION: 763# @DESCRIPTION:
729# Remove mysql symlinks. 764# Remove mysql symlinks.
730mysql-v2_pkg_postrm() { 765mysql-v2_pkg_postrm() {
731 766
732 : # mysql_lib_symlinks "${D}" 767 : # mysql_lib_symlinks "${ED}"
733} 768}

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

  ViewVC Help
Powered by ViewVC 1.1.20