/[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.6 Revision 1.20
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.6 2011/08/21 16:14:56 jmbsvicetto Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.20 2012/11/01 20:22:57 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" ]] \
218&& IUSE="${IUSE} libevent" 179&& IUSE="${IUSE} libevent"
219 180
220[[ ${PN} == "mariadb" ]] \ 181[[ ${PN} == "mariadb" ]] \
223 184
224[[ ${PN} == "mariadb" ]] \ 185[[ ${PN} == "mariadb" ]] \
225&& mysql_version_is_at_least "5.2.5" \ 186&& mysql_version_is_at_least "5.2.5" \
226&& IUSE="${IUSE} sphinx" 187&& IUSE="${IUSE} sphinx"
227 188
189mysql_version_is_at_least "5.5.7" \
190&& IUSE="${IUSE} systemtap"
228 191
229# 192#
230# DEPENDENCIES: 193# DEPENDENCIES:
231# 194#
232 195
233# Be warned, *DEPEND are version-dependant 196# Be warned, *DEPEND are version-dependant
234# These are used for both runtime and compiletime 197# These are used for both runtime and compiletime
235DEPEND=" 198DEPEND="
236 ssl? ( >=dev-libs/openssl-0.9.6d ) 199 ssl? ( >=dev-libs/openssl-0.9.6d )
237 userland_GNU? ( sys-process/procps ) 200 kernel_linux? ( sys-process/procps )
238 >=sys-apps/sed-4 201 >=sys-apps/sed-4
239 >=sys-apps/texinfo-4.7-r1 202 >=sys-apps/texinfo-4.7-r1
240 >=sys-libs/readline-4.1 203 >=sys-libs/readline-4.1
241 >=sys-libs/zlib-1.2.3 204 >=sys-libs/zlib-1.2.3
242" 205"
243 206
244[[ ${PN} == mariadb ]] \ 207[[ ${PN} == mariadb ]] \
245&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" 208&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
246 209
247# Having different flavours at the same time is not a good idea 210# Having different flavours at the same time is not a good idea
248for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do 211for i in "mysql" "mariadb" ; do
249 [[ ${i} == ${PN} ]] || 212 [[ ${i} == ${PN} ]] ||
250 DEPEND="${DEPEND} !dev-db/${i}" 213 DEPEND="${DEPEND} !dev-db/${i}"
251done 214done
252 215
216# prefix: first need to implement something for #196294
253RDEPEND="${DEPEND} 217RDEPEND="${DEPEND}
254 !minimal? ( dev-db/mysql-init-scripts ) 218 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
255 selinux? ( sec-policy/selinux-mysql ) 219 selinux? ( sec-policy/selinux-mysql )
256" 220"
257 221
258DEPEND="${DEPEND} 222DEPEND="${DEPEND}
259 virtual/yacc 223 virtual/yacc
260" 224"
261 225
262DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )" 226DEPEND="${DEPEND} static? ( sys-libs/ncurses[static-libs] )"
263 227
264# compile-time-only 228# compile-time-only
265DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 229DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
266 230
267# compile-time-only 231# compile-time-only
274 238
275[[ "${PN}" == "mariadb" ]] \ 239[[ "${PN}" == "mariadb" ]] \
276&& mysql_version_is_at_least "5.2.5" \ 240&& mysql_version_is_at_least "5.2.5" \
277&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" 241&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
278 242
243mysql_version_is_at_least "5.5.7" \
244&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )"
245
279# dev-perl/DBD-mysql is needed by some scripts installed by MySQL 246# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
280PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 247PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
281 248
282# For other stuff to bring us in 249# For other stuff to bring us in
283PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" 250PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
284
285 251
286# 252#
287# External patches 253# External patches
288# 254#
289 255
316 282
317 PBXT_P="pbxt-${PBXT_VERSION}" 283 PBXT_P="pbxt-${PBXT_VERSION}"
318 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" 284 PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz"
319 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" 285 SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
320 286
287fi
288
321 # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins 289# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
322 # vs. built outside the dir 290# vs. built outside the dir
323 if pbxt_available; then 291if pbxt_available; then
324 292
325 IUSE="${IUSE} pbxt" 293 IUSE="${IUSE} pbxt"
326 PBXT_NEWSTYLE=1 294 PBXT_NEWSTYLE=1
327 fi
328fi 295fi
329 296
330if xtradb_patch_available; then 297if xtradb_patch_available; then
331 XTRADB_P="percona-xtradb-${XTRADB_VER}" 298 XTRADB_P="percona-xtradb-${XTRADB_VER}"
332 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" 299 XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz"
377# warn about deprecated features 344# warn about deprecated features
378mysql-v2_pkg_setup() { 345mysql-v2_pkg_setup() {
379 346
380 if has test ${FEATURES} ; then 347 if has test ${FEATURES} ; then
381 if ! use minimal ; then 348 if ! use minimal ; then
382 if [[ $UID -eq 0 ]]; then 349 if ! has userpriv ${FEATURES} ; then
383 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." 350 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
384 fi 351 fi
385 fi 352 fi
386 fi 353 fi
387 354
415 382
416 # This should come after all of the die statements 383 # This should come after all of the die statements
417 enewgroup mysql 60 || die "problem adding 'mysql' group" 384 enewgroup mysql 60 || die "problem adding 'mysql' group"
418 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" 385 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
419 386
420 if [ "${PN}" != "mysql-cluster" ] && use cluster; then 387 if use cluster; then
421 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and" 388 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
422 ewarn "5.1 series should NOT be put into production. In the near" 389 ewarn "5.1 series should NOT be put into production. In the near"
423 ewarn "future, it will be disabled from building." 390 ewarn "future, it will be disabled from building."
424 ewarn ""
425 ewarn "If you need NDB support, you should instead move to the new"
426 ewarn "mysql-cluster package that represents that upstream NDB"
427 ewarn "development."
428 fi 391 fi
429} 392}
430 393
431# @FUNCTION: mysql-v2_src_unpack 394# @FUNCTION: mysql-v2_src_unpack
432# @DESCRIPTION: 395# @DESCRIPTION:
491 454
492 # Make sure the vars are correctly initialized 455 # Make sure the vars are correctly initialized
493 mysql_init_vars 456 mysql_init_vars
494 457
495 # Check FEATURES="collision-protect" before removing this 458 # Check FEATURES="collision-protect" before removing this
496 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 459 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
497 460
498 # Secure the logfiles 461 # Secure the logfiles
499 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 462 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
500 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 463 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
501 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 464 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
549 mysql_check_version_range "4.0 to 5.0.99.99" \ 512 mysql_check_version_range "4.0 to 5.0.99.99" \
550 && use berkdb \ 513 && use berkdb \
551 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 514 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
552} 515}
553 516
517# @FUNCTION: mysql-v2_getopt
518# @DESCRIPTION:
519# Use my_print_defaults to extract specific config options
520mysql-v2_getopt() {
521 local mypd="${EROOT}"/usr/bin/my_print_defaults
522 section="$1"
523 flag="--${2}="
524 "${mypd}" $section | sed -n "/^${flag}/p"
525}
526
527# @FUNCTION: mysql-v2_getoptval
528# @DESCRIPTION:
529# Use my_print_defaults to extract specific config options
530mysql-v2_getoptval() {
531 local mypd="${EROOT}"/usr/bin/my_print_defaults
532 section="$1"
533 flag="--${2}="
534 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
535}
536
554# @FUNCTION: mysql-v2_pkg_config 537# @FUNCTION: mysql-v2_pkg_config
555# @DESCRIPTION: 538# @DESCRIPTION:
556# Configure mysql environment. 539# Configure mysql environment.
557mysql-v2_pkg_config() { 540mysql-v2_pkg_config() {
558 541
559 local old_MY_DATADIR="${MY_DATADIR}" 542 local old_MY_DATADIR="${MY_DATADIR}"
543 local old_HOME="${HOME}"
544 # my_print_defaults needs to read stuff in $HOME/.my.cnf
545 export HOME=/root
560 546
561 # Make sure the vars are correctly initialized 547 # Make sure the vars are correctly initialized
562 mysql_init_vars 548 mysql_init_vars
563 549
564 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 550 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
566 if built_with_use ${CATEGORY}/${PN} minimal ; then 552 if built_with_use ${CATEGORY}/${PN} minimal ; then
567 die "Minimal builds do NOT include the MySQL server" 553 die "Minimal builds do NOT include the MySQL server"
568 fi 554 fi
569 555
570 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 556 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
571 local MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${MY_DATADIR})" 557 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
558 MY_DATADIR_s="${MY_DATADIR_s%%/}"
572 local old_MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${old_MY_DATADIR})" 559 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
560 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
573 561
574 if [[ -d "${old_MY_DATADIR_s}" ]]; then 562 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
575 if [[ -d "${MY_DATADIR_s}" ]]; then 563 if [[ -d "${MY_DATADIR_s}" ]]; then
576 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 564 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
577 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" 565 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
578 else 566 else
579 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" 567 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
593 581
594 local pwd1="a" 582 local pwd1="a"
595 local pwd2="b" 583 local pwd2="b"
596 local maxtry=15 584 local maxtry=15
597 585
598 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then 586 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
599 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" 587 MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)"
588 fi
589 MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)"
590 # These are dir+prefix
591 MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)"
592 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
593 MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)"
594 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
595
596 if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then
597 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
598 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
599 fi
600 if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then
601 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
602 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
603 fi
604 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
605 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
606 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
600 fi 607 fi
601 608
602 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 609 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
603 ewarn "You have already a MySQL database in place." 610 ewarn "You have already a MySQL database in place."
604 ewarn "(${ROOT}/${MY_DATADIR}/*)" 611 ewarn "(${ROOT}/${MY_DATADIR}/*)"
625 fi 632 fi
626 MYSQL_ROOT_PASSWORD="${pwd1}" 633 MYSQL_ROOT_PASSWORD="${pwd1}"
627 unset pwd1 pwd2 634 unset pwd1 pwd2
628 fi 635 fi
629 636
630 local options="" 637 local options="--log-warnings=0"
631 local sqltmp="$(emktemp)" 638 local sqltmp="$(emktemp)"
632 639
633 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 640 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
634 [[ -r "${help_tables}" ]] \ 641 [[ -r "${help_tables}" ]] \
635 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 642 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
636 || touch "${TMPDIR}/fill_help_tables.sql" 643 || touch "${TMPDIR}/fill_help_tables.sql"
637 help_tables="${TMPDIR}/fill_help_tables.sql" 644 help_tables="${TMPDIR}/fill_help_tables.sql"
645
646 # Figure out which options we need to disable to do the setup
647 helpfile="${TMPDIR}/mysqld-help"
648 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
649 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
650 federated innodb ssl log-bin relay-log slow-query-log external-locking \
651 ndbcluster log-slave-updates \
652 ; do
653 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
654 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
655 done
656 # But some options changed names
657 egrep -sq external-locking "${helpfile}" && \
658 options="${options/skip-locking/skip-external-locking}"
659
660 use prefix || options="${options} --user=mysql"
638 661
639 pushd "${TMPDIR}" &>/dev/null 662 pushd "${TMPDIR}" &>/dev/null
640 "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 663 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
664 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
665 [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db
666 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}"
667 einfo "Command: $cmd"
668 eval $cmd \
669 >"${TMPDIR}"/mysql_install_db.log 2>&1
641 if [ $? -ne 0 ]; then 670 if [ $? -ne 0 ]; then
642 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 671 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
643 die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" 672 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
644 fi 673 fi
645 popd &>/dev/null 674 popd &>/dev/null
646 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 675 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
647 || die "MySQL databases not installed" 676 || die "MySQL databases not installed"
648 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 677 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
649 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 678 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
650 679
651 # Figure out which options we need to disable to do the setup
652 helpfile="${TMPDIR}/mysqld-help"
653 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
654 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
655 federated innodb ssl log-bin relay-log slow-query-log external-locking \
656 ndbcluster \
657 ; do
658 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
659 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
660 done
661 # But some options changed names
662 egrep -sq external-locking "${helpfile}" && \
663 options="${options/skip-locking/skip-external-locking}"
664
665 # Filling timezones, see 680 # Filling timezones, see
666 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 681 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
667 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null 682 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
668 683
669 if [[ -r "${help_tables}" ]] ; then 684 if [[ -r "${help_tables}" ]] ; then
670 cat "${help_tables}" >> "${sqltmp}" 685 cat "${help_tables}" >> "${sqltmp}"
671 fi 686 fi
672 687
673 einfo "Creating the mysql database and setting proper" 688 einfo "Creating the mysql database and setting proper"
674 einfo "permissions on it ..." 689 einfo "permissions on it ..."
675 690
676 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 691 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
677 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 692 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
678 local mysqld="${ROOT}/usr/sbin/mysqld \ 693 local mysqld="${EROOT}/usr/sbin/mysqld \
679 ${options} \ 694 ${options} \
680 --user=mysql \ 695 --user=mysql \
696 --log-warnings=0 \
681 --basedir=${ROOT}/usr \ 697 --basedir=${EROOT}/usr \
682 --datadir=${ROOT}/${MY_DATADIR} \ 698 --datadir=${ROOT}/${MY_DATADIR} \
683 --max_allowed_packet=8M \ 699 --max_allowed_packet=8M \
684 --net_buffer_length=16K \ 700 --net_buffer_length=16K \
685 --default-storage-engine=MyISAM \ 701 --default-storage-engine=MyISAM \
686 --socket=${socket} \ 702 --socket=${socket} \
687 --pid-file=${pidfile}" 703 --pid-file=${pidfile}"
688 #einfo "About to start mysqld: ${mysqld}" 704 #einfo "About to start mysqld: ${mysqld}"
689 ebegin "Starting mysqld" 705 ebegin "Starting mysqld"
706 einfo "Command ${mysqld}"
690 ${mysqld} & 707 ${mysqld} &
691 rc=$? 708 rc=$?
692 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 709 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
693 maxtry=$((${maxtry}-1)) 710 maxtry=$((${maxtry}-1))
694 echo -n "." 711 echo -n "."
701 fi 718 fi
702 719
703 ebegin "Setting root password" 720 ebegin "Setting root password"
704 # Do this from memory, as we don't want clear text passwords in temp files 721 # Do this from memory, as we don't want clear text passwords in temp files
705 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" 722 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
706 "${ROOT}/usr/bin/mysql" \ 723 "${EROOT}/usr/bin/mysql" \
707 --socket=${socket} \ 724 --socket=${socket} \
708 -hlocalhost \ 725 -hlocalhost \
709 -e "${sql}" 726 -e "${sql}"
710 eend $? 727 eend $?
711 728
712 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 729 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
713 "${ROOT}/usr/bin/mysql" \ 730 "${EROOT}/usr/bin/mysql" \
714 --socket=${socket} \ 731 --socket=${socket} \
715 -hlocalhost \ 732 -hlocalhost \
716 -uroot \ 733 -uroot \
717 -p"${MYSQL_ROOT_PASSWORD}" \ 734 --password="${MYSQL_ROOT_PASSWORD}" \
718 mysql < "${sqltmp}" 735 mysql < "${sqltmp}"
719 rc=$? 736 rc=$?
720 eend $? 737 eend $?
721 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!" 738 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
722 739
731# @FUNCTION: mysql-v2_pkg_postrm 748# @FUNCTION: mysql-v2_pkg_postrm
732# @DESCRIPTION: 749# @DESCRIPTION:
733# Remove mysql symlinks. 750# Remove mysql symlinks.
734mysql-v2_pkg_postrm() { 751mysql-v2_pkg_postrm() {
735 752
736 : # mysql_lib_symlinks "${D}" 753 : # mysql_lib_symlinks "${ED}"
737} 754}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20