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

Diff of /eclass/mysql.eclass

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

Revision 1.155 Revision 1.183
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.155 2010/11/02 20:27:41 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/mysql.eclass,v 1.183 2015/05/24 04:35:49 vapier 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 \
124PERCONA_VER="${PERCONA_VER}" 126PERCONA_VER="${PERCONA_VER}"
125 127
126# Be warned, *DEPEND are version-dependant 128# Be warned, *DEPEND are version-dependant
127# These are used for both runtime and compiletime 129# These are used for both runtime and compiletime
128DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d ) 130DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
129 userland_GNU? ( sys-process/procps ) 131 kernel_linux? ( sys-process/procps )
130 >=sys-apps/sed-4 132 >=sys-apps/sed-4
131 >=sys-apps/texinfo-4.7-r1 133 >=sys-apps/texinfo-4.7-r1
132 >=sys-libs/readline-4.1 134 >=sys-libs/readline-4.1
133 >=sys-libs/zlib-1.2.3" 135 >=sys-libs/zlib-1.2.3"
134 136
139for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do 141for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do
140 [[ "${i}" == ${PN} ]] || 142 [[ "${i}" == ${PN} ]] ||
141 DEPEND="${DEPEND} !dev-db/${i}" 143 DEPEND="${DEPEND} !dev-db/${i}"
142done 144done
143 145
146# prefix: first need to implement something for #196294
144RDEPEND="${DEPEND} 147RDEPEND="${DEPEND}
145 !minimal? ( dev-db/mysql-init-scripts ) 148 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
146 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
147 157
148# compile-time-only 158# compile-time-only
149mysql_version_is_at_least "5.1" \ 159mysql_version_is_at_least "5.1" \
150|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )" 160|| DEPEND="${DEPEND} berkdb? ( sys-apps/ed )"
151 161
152# compile-time-only 162# compile-time-only
153mysql_version_is_at_least "5.1.12" \ 163mysql_version_is_at_least "5.1.12" \
154&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3" 164&& DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
165
166[[ "${PN}" == "mariadb" ]] \
167&& mysql_version_is_at_least "5.2" \
168&& DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )"
169#SphinxSE is included but is not available in 5.2.4 due to a missing plug.in file
170# sphinx? ( app-misc/sphinx )"
155 171
156# 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
157PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" 173PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
158 174
159# For other stuff to bring us in 175# For other stuff to bring us in
238[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \ 254[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \
239&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling" 255&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling"
240 256
241[[ "${PN}" == "mariadb" ]] \ 257[[ "${PN}" == "mariadb" ]] \
242&& IUSE="${IUSE} libevent" 258&& IUSE="${IUSE} libevent"
259
260[[ "${PN}" == "mariadb" ]] \
261&& mysql_version_is_at_least "5.2" \
262&& IUSE="${IUSE} oqgraph"
263#SphinxSE is included but is not available in 5.2.4 due to a missing plug.in file
264#&& IUSE="${IUSE} oqgraph sphinx"
243 265
244# MariaDB has integrated PBXT 266# MariaDB has integrated PBXT
245# PBXT_VERSION means that we have a PBXT patch for this PV 267# PBXT_VERSION means that we have a PBXT patch for this PV
246# PBXT was only introduced after 5.1.12 268# PBXT was only introduced after 5.1.12
247pbxt_patch_available() { 269pbxt_patch_available() {
341# @DESCRIPTION: 363# @DESCRIPTION:
342# void mysql_init_vars() 364# void mysql_init_vars()
343# Initialize global variables 365# Initialize global variables
344# 2005-11-19 <vivo@gentoo.org> 366# 2005-11-19 <vivo@gentoo.org>
345mysql_init_vars() { 367mysql_init_vars() {
346 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"} 368 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
347 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"} 369 MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
348 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"} 370 MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
349 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"} 371 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
350 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"} 372 MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
351 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"} 373 MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
352 374
353 if [[ -z "${MY_DATADIR}" ]] ; then 375 if [[ -z "${MY_DATADIR}" ]] ; then
354 MY_DATADIR="" 376 MY_DATADIR=""
355 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then 377 if [[ -f ${MY_SYSCONFDIR}/my.cnf ]] ; then
356 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ 378 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
357 | sed -ne '/datadir/s|^--datadir=||p' \ 379 | sed -ne '/datadir/s|^--datadir=||p' \
358 | tail -n1` 380 | tail -n1`
359 if [[ -z "${MY_DATADIR}" ]] ; then 381 if [[ -z "${MY_DATADIR}" ]] ; then
360 MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ 382 MY_DATADIR=`grep ^datadir ${MY_SYSCONFDIR}/my.cnf \
361 | sed -e 's/.*=\s*//' \ 383 | sed -e 's/.*=\s*//' \
362 | tail -n1` 384 | tail -n1`
363 fi 385 fi
364 fi 386 fi
365 if [[ -z "${MY_DATADIR}" ]] ; then 387 if [[ -z "${MY_DATADIR}" ]] ; then
435 457
436configure_common() { 458configure_common() {
437 myconf="${myconf} $(use_with big-tables)" 459 myconf="${myconf} $(use_with big-tables)"
438 myconf="${myconf} --enable-local-infile" 460 myconf="${myconf} --enable-local-infile"
439 myconf="${myconf} --with-extra-charsets=all" 461 myconf="${myconf} --with-extra-charsets=all"
440 myconf="${myconf} --with-mysqld-user=mysql" 462 use prefix || myconf="${myconf} --with-mysqld-user=mysql"
441 myconf="${myconf} --with-server" 463 myconf="${myconf} --with-server"
442 myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock" 464 myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
443 myconf="${myconf} --without-libwrap" 465 myconf="${myconf} --without-libwrap"
444 466
445 if use static ; then 467 if use static ; then
446 myconf="${myconf} --with-mysqld-ldflags=-all-static" 468 myconf="${myconf} --with-mysqld-ldflags=-all-static"
447 myconf="${myconf} --with-client-ldflags=-all-static" 469 myconf="${myconf} --with-client-ldflags=-all-static"
482 fi 504 fi
483 505
484} 506}
485 507
486configure_40_41_50() { 508configure_40_41_50() {
509 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr"
487 myconf="${myconf} $(use_with perl bench)" 510 myconf="${myconf} $(use_with perl bench)"
488 myconf="${myconf} --enable-assembler" 511 myconf="${myconf} --enable-assembler"
489 myconf="${myconf} --with-extra-tools" 512 myconf="${myconf} --with-extra-tools"
490 myconf="${myconf} --with-innodb" 513 myconf="${myconf} --with-innodb"
491 myconf="${myconf} --without-readline" 514 myconf="${myconf} --without-readline"
492 myconf="${myconf} $(use_with ssl openssl)" 515 myconf="${myconf} $(use_with ssl openssl "${EPREFIX}/usr")"
493 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)"
494 517
495 # --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
496 # has been removed from configure 519 # has been removed from configure
497 # Apply to 4.x and 5.0.[0-3] 520 # Apply to 4.x and 5.0.[0-3]
563 586
564configure_51() { 587configure_51() {
565 # TODO: !!!! readd --without-readline 588 # TODO: !!!! readd --without-readline
566 # the failure depend upon config/ac-macros/readline.m4 checking into 589 # the failure depend upon config/ac-macros/readline.m4 checking into
567 # readline.h instead of history.h 590 # readline.h instead of history.h
568 myconf="${myconf} $(use_with ssl ssl /usr)" 591 myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
569 myconf="${myconf} --enable-assembler" 592 myconf="${myconf} --enable-assembler"
570 myconf="${myconf} --with-geometry" 593 myconf="${myconf} --with-geometry"
571 myconf="${myconf} --with-readline" 594 myconf="${myconf} --with-readline"
572 myconf="${myconf} --with-zlib-dir=/usr/" 595 myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
573 myconf="${myconf} --without-pstack" 596 myconf="${myconf} --without-pstack"
574 myconf="${myconf} --with-plugindir=/usr/$(get_libdir)/mysql/plugin" 597 myconf="${myconf} --with-plugindir=${EPREFIX}/usr/$(get_libdir)/mysql/plugin"
575 598
576 # This is an explict die here, because if we just forcibly disable it, then the 599 # This is an explict die here, because if we just forcibly disable it, then the
577 # user's data is not accessible. 600 # user's data is not accessible.
578 use max-idx-128 && die "Bug #336027: upstream has a corruption issue with max-idx-128 presently" 601 use max-idx-128 && die "Bug #336027: upstream has a corruption issue with max-idx-128 presently"
579 #use max-idx-128 && myconf="${myconf} --with-max-indexes=128" 602 #use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
597 \) \ 620 \) \
598 -print0 \ 621 -print0 \
599 | xargs -0 sed -r -n \ 622 | xargs -0 sed -r -n \
600 -e '/^MYSQL_STORAGE_ENGINE/{ 623 -e '/^MYSQL_STORAGE_ENGINE/{
601 s~MYSQL_STORAGE_ENGINE\([[:space:]]*\[?([-_a-z0-9]+)\]?.*,~\1 ~g ; 624 s~MYSQL_STORAGE_ENGINE\([[:space:]]*\[?([-_a-z0-9]+)\]?.*,~\1 ~g ;
602 s~^([^ ]+).*~\1~gp; 625 s~^([^ ]+).*~\1~gp;
603 }' \ 626 }' \
604 | tr -s '\n' ' ' 627 | tr -s '\n' ' '
605 )" 628 )"
606 629
607 # 5.1 introduces a new way to manage storage engines (plugins) 630 # 5.1 introduces a new way to manage storage engines (plugins)
620 fi 643 fi
621 # Now the extras 644 # Now the extras
622 if use extraengine ; then 645 if use extraengine ; then
623 # 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
624 # not added yet: ibmdb2i 647 # not added yet: ibmdb2i
625 # Not supporting as examples: example,daemon_example,ftexample 648 # Not supporting as examples: example,daemon_example,ftexample
626 plugins_sta="${plugins_sta} partition" 649 plugins_sta="${plugins_sta} partition"
627 plugins_dyn="${plugins_sta} federated"
628 650
629 if [[ "${PN}" != "mariadb" ]] ; then 651 if [[ "${PN}" != "mariadb" ]] ; then
630 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"
631 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"
632 else 655 else
633 elog "MariaDB includes the FederatedX engine. Be sure to read" 656 elog "MariaDB includes the FederatedX engine. Be sure to read"
634 elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine" 657 elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine"
658 plugins_dyn="${plugins_sta} federatedx"
635 fi 659 fi
636 else 660 else
637 plugins_dis="${plugins_dis} partition federated" 661 plugins_dis="${plugins_dis} partition federated"
638 fi 662 fi
639 663
657 fi 681 fi
658 682
659 if [[ "${PN}" == "mariadb" ]] ; then 683 if [[ "${PN}" == "mariadb" ]] ; then
660 # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not 684 # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not
661 # caught above. 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"
662 plugins_sta="${plugins_sta} maria" 690 plugins_sta="${plugins_sta} maria"
691 else
692 myconf="${myconf} --with-aria-tmp-tables"
693 plugins_sta="${plugins_sta} aria"
694 fi
663 695
664 [ -e "${S}"/storage/innobase ] || [ -e "${S}"/storage/xtradb ] || 696 [ -e "${S}"/storage/innobase ] || [ -e "${S}"/storage/xtradb ] ||
665 die "The ${P} package doesn't provide innobase nor xtradb" 697 die "The ${P} package doesn't provide innobase nor xtradb"
666 698
667 for i in innobase xtradb ; do 699 for i in innobase xtradb ; do
668 [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}" 700 [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
669 done 701 done
670 702
671 myconf="${myconf} $(use_with libevent)" 703 myconf="${myconf} $(use_with libevent)"
672 # This is not optional, without it several upstream testcases fail. 704
673 # Also strongly recommended by upstream. 705 if mysql_version_is_at_least "5.2" ; then
674 myconf="${myconf} --with-maria-tmp-tables" 706 #This should include sphinx, but the 5.2.4 archive forgot the plug.in file
707 #for i in oqgraph sphinx ; do
708 for i in oqgraph ; do
709 use ${i} \
710 && plugins_dyn="${plugins_dyn} ${i}" \
711 || plugins_dis="${plugins_dis} ${i}"
712 done
713 fi
675 fi 714 fi
676 715
677 if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then 716 if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then
678 use pbxt \ 717 use pbxt \
679 && plugins_dyn="${plugins_dyn} pbxt" \ 718 && plugins_sta="${plugins_sta} pbxt" \
680 || plugins_dis="${plugins_dis} pbxt" 719 || plugins_dis="${plugins_dis} pbxt"
681 fi 720 fi
682 721
683 use static && \ 722 use static && \
684 plugins_sta="${plugins_sta} ${plugins_dyn}" && \ 723 plugins_sta="${plugins_sta} ${plugins_dyn}" && \
704 743
705 einfo "Reconfiguring dir '${PWD}'" 744 einfo "Reconfiguring dir '${PWD}'"
706 eautoreconf 745 eautoreconf
707 746
708 local myconf="" 747 local myconf=""
709 myconf="${myconf} --with-mysql=${S} --libdir=/usr/$(get_libdir)" 748 myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
710 use debug && myconf="${myconf} --with-debug=full" 749 use debug && myconf="${myconf} --with-debug=full"
711 econf ${myconf} || die "Problem configuring PBXT storage engine" 750 econf ${myconf} || die "Problem configuring PBXT storage engine"
712} 751}
713 752
714pbxt_src_compile() { 753pbxt_src_compile() {
739# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv" 778# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
740# check for conflicting use flags 779# check for conflicting use flags
741# create new user and group for mysql 780# create new user and group for mysql
742# warn about deprecated features 781# warn about deprecated features
743mysql_pkg_setup() { 782mysql_pkg_setup() {
744 if hasq test ${FEATURES} ; then 783 if has test ${FEATURES} ; then
745 if ! use minimal ; then 784 if ! use minimal ; then
746 if [[ $UID -eq 0 ]]; then 785 if [[ $UID -eq 0 ]]; then
747 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."
748 fi 787 fi
749 fi 788 fi
750 fi 789 fi
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
751 799
752 # Check for USE flag problems in pkg_setup 800 # Check for USE flag problems in pkg_setup
753 if use static && use ssl ; then 801 if use static && use ssl ; then
754 M="MySQL does not support being built statically with SSL support enabled!" 802 M="MySQL does not support being built statically with SSL support enabled!"
755 eerror "${M}" 803 eerror "${M}"
756 die "${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"
757 fi 812 fi
758 813
759 if ! mysql_version_is_at_least "5.0" \ 814 if ! mysql_version_is_at_least "5.0" \
760 && use raid \ 815 && use raid \
761 && use static ; then 816 && use static ; then
784 # Bug #290570, 284946, 307251 839 # Bug #290570, 284946, 307251
785 # Upstream changes made us need a fairly new GCC4. 840 # Upstream changes made us need a fairly new GCC4.
786 # But only for 5.0.8[3-6]! 841 # But only for 5.0.8[3-6]!
787 if mysql_version_is_at_least "5.0.83" && ! mysql_version_is_at_least 5.0.87 ; then 842 if mysql_version_is_at_least "5.0.83" && ! mysql_version_is_at_least 5.0.87 ; then
788 GCC_VER=$(gcc-version) 843 GCC_VER=$(gcc-version)
789 case ${GCC_VER} in 844 case ${CHOST}:${GCC_VER} in
845 *-darwin*:4.*) : ;; # bug #310615
790 2*|3*|4.0|4.1|4.2) 846 *:2*|*:3*|*:4.0|*:4.1|*:4.2)
791 eerror "Some releases of MySQL required a very new GCC, and then" 847 eerror "Some releases of MySQL required a very new GCC, and then"
792 eerror "later release relaxed that requirement again. Either pick a" 848 eerror "later release relaxed that requirement again. Either pick a"
793 eerror "MySQL >=5.0.87, or use a newer GCC." 849 eerror "MySQL >=5.0.87, or use a newer GCC."
794 die "Active GCC too old!" ;; 850 die "Active GCC too old!" ;;
795 esac 851 esac
821 # Initialize the proper variables first 877 # Initialize the proper variables first
822 mysql_init_vars 878 mysql_init_vars
823 879
824 unpack ${A} 880 unpack ${A}
825 # Grab the patches 881 # Grab the patches
826 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack 882 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
827 883
828 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}" 884 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
829 885
830 # Be backwards compatible for now 886 # Be backwards compatible for now
831 case ${EAPI:-0} in 887 case ${EAPI:-0} in
890 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}" 946 [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}"
891 cp -ral "${WORKDIR}/${XTRADB_P}" "${i}" 947 cp -ral "${WORKDIR}/${XTRADB_P}" "${i}"
892 popd >/dev/null 948 popd >/dev/null
893 fi 949 fi
894 950
895 if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]] && use pbxt ; then 951 if pbxt_patch_available && [[ "${PBXT_NEWSTYLE}" == "1" ]] && use pbxt ; then
896 einfo "Adding storage engine: PBXT" 952 einfo "Adding storage engine: PBXT"
897 pushd "${S}"/storage >/dev/null 953 pushd "${S}"/storage >/dev/null
898 i='pbxt' 954 i='pbxt'
899 [ -d "${i}" ] && rm -rf "${i}" 955 [ -d "${i}" ] && rm -rf "${i}"
900 cp -ral "${WORKDIR}/${PBXT_P}" "${i}" 956 cp -ral "${WORKDIR}/${PBXT_P}" "${i}"
923 979
924 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" \
925 && use berkdb ; then 981 && use berkdb ; then
926 einfo "Fixing up berkdb buildsystem" 982 einfo "Fixing up berkdb buildsystem"
927 [[ -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"
928 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" \
929 || die "Could not copy libtool.m4 to bdb/dist/" 985 || die "Could not copy libtool.m4 to bdb/dist/"
930 #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.
931 if [ -f '/usr/share/aclocal/ltsugar.m4' ]; then 987 if [ -f ${EPREFIX}'/usr/share/aclocal/ltsugar.m4' ]; then
932 cat "/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac" 988 cat "${EPREFIX}/usr/share/aclocal/ltsugar.m4" >> "bdb/dist/aclocal/libtool.ac"
933 cat "/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac" 989 cat "${EPREFIX}/usr/share/aclocal/ltversion.m4" >> "bdb/dist/aclocal/libtool.ac"
934 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"
935 cat "/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac" 991 cat "${EPREFIX}/usr/share/aclocal/ltoptions.m4" >> "bdb/dist/aclocal/libtool.ac"
936 fi 992 fi
937 pushd "bdb/dist" &>/dev/null 993 pushd "bdb/dist" &>/dev/null
938 sh s_all \ 994 sh s_all \
939 || die "Failed bdb reconfigure" 995 || die "Failed bdb reconfigure"
940 popd &>/dev/null 996 popd &>/dev/null
964 1020
965 # Bug #114895, bug #110149 1021 # Bug #114895, bug #110149
966 filter-flags "-O" "-O[01]" 1022 filter-flags "-O" "-O[01]"
967 1023
968 # glib-2.3.2_pre fix, bug #16496 1024 # glib-2.3.2_pre fix, bug #16496
969 append-flags "-DHAVE_ERRNO_AS_DEFINE=1" 1025 append-cppflags "-DHAVE_ERRNO_AS_DEFINE=1"
970 1026
971 # 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
972 # fail badly during cluster startup. 1028 # fail badly during cluster startup.
973 if [[ $(gcc-major-version) -lt 4 ]]; then 1029 if [[ $(gcc-major-version) -lt 4 ]]; then
974 filter-flags "-fstack-protector-all" 1030 filter-flags "-fstack-protector-all"
980 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" 1036 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
981 export CXXFLAGS 1037 export CXXFLAGS
982 1038
983 # 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.
984 append-flags -fno-strict-aliasing 1040 append-flags -fno-strict-aliasing
985 1041
986 # bug #335185, #335995, with >= GCC4.3.3 on x86 only, omit-frame-pointer 1042 # bug #335185, #335995, with >= GCC4.3.3 on x86 only, omit-frame-pointer
987 # causes a mis-compile. 1043 # causes a mis-compile.
988 # Upstream bugs: 1044 # Upstream bugs:
989 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38562 1045 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38562
990 # http://bugs.mysql.com/bug.php?id=45205 1046 # http://bugs.mysql.com/bug.php?id=45205
991 use x86 && version_is_at_least "4.3.3" "$(gcc-fullversion)" && \ 1047 use x86 && version_is_at_least "4.3.3" "$(gcc-fullversion)" && \
992 append-flags -fno-omit-frame-pointer && \ 1048 append-flags -fno-omit-frame-pointer && \
993 filter-flags -fomit-frame-pointer 1049 filter-flags -fomit-frame-pointer
994 1050
995 econf \ 1051 econf \
996 --libexecdir="/usr/sbin" \ 1052 --libexecdir="${EPREFIX}"/usr/sbin \
997 --sysconfdir="${MY_SYSCONFDIR}" \ 1053 --sysconfdir=${MY_SYSCONFDIR} \
998 --localstatedir="${MY_LOCALSTATEDIR}" \ 1054 --localstatedir=${MY_LOCALSTATEDIR} \
999 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 1055 --sharedstatedir=${MY_SHAREDSTATEDIR} \
1000 --libdir="${MY_LIBDIR}" \ 1056 --libdir=${MY_LIBDIR} \
1001 --includedir="${MY_INCLUDEDIR}" \ 1057 --includedir=${MY_INCLUDEDIR} \
1002 --with-low-memory \ 1058 --with-low-memory \
1003 --with-client-ldflags=-lstdc++ \ 1059 --with-client-ldflags=-lstdc++ \
1004 --enable-thread-safe-client \ 1060 --enable-thread-safe-client \
1005 --with-comment="Gentoo Linux ${PF}" \ 1061 --with-comment="Gentoo Linux ${PF}" \
1006 --without-docs \ 1062 --without-docs \
1063 --with-LIBDIR="$(get_libdir)" \
1007 ${myconf} || die "econf failed" 1064 ${myconf} || die "econf failed"
1008 1065
1009 # TODO: Move this before autoreconf !!! 1066 # TODO: Move this before autoreconf !!!
1010 find . -type f -name Makefile -print0 \ 1067 find . -type f -name Makefile -print0 \
1011 | xargs -0 -n100 sed -i \ 1068 | xargs -0 -n100 sed -i \
1040 # Make sure the vars are correctly initialized 1097 # Make sure the vars are correctly initialized
1041 mysql_init_vars 1098 mysql_init_vars
1042 1099
1043 emake install \ 1100 emake install \
1044 DESTDIR="${D}" \ 1101 DESTDIR="${D}" \
1045 benchdir_root="${MY_SHAREDSTATEDIR}" \ 1102 benchdir_root=${MY_SHAREDSTATEDIR} \
1046 testroot="${MY_SHAREDSTATEDIR}" \ 1103 testroot="${MY_SHAREDSTATEDIR}" \
1047 || die "emake install failed" 1104 || die "emake install failed"
1048 1105
1049 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then 1106 if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
1050 pbxt_patch_available && use pbxt && pbxt_src_install 1107 pbxt_patch_available && use pbxt && pbxt_src_install
1056 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair" 1113 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
1057 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize" 1114 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
1058 1115
1059 # Various junk (my-*.cnf moved elsewhere) 1116 # Various junk (my-*.cnf moved elsewhere)
1060 einfo "Removing duplicate /usr/share/mysql files" 1117 einfo "Removing duplicate /usr/share/mysql files"
1061 rm -Rf "${D}/usr/share/info" 1118 rm -Rf "${ED}/usr/share/info"
1062 for removeme in "mysql-log-rotate" mysql.server* \ 1119 for removeme in "mysql-log-rotate" mysql.server* \
1063 binary-configure* my-*.cnf mi_test_all* 1120 binary-configure* my-*.cnf mi_test_all*
1064 do 1121 do
1065 rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme} 1122 rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme}
1066 done 1123 done
1067 1124
1068 # Clean up stuff for a minimal build 1125 # Clean up stuff for a minimal build
1069 if use minimal ; then 1126 if use minimal ; then
1070 einfo "Remove all extra content for minimal build" 1127 einfo "Remove all extra content for minimal build"
1071 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench} 1128 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
1072 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}
1073 rm -f "${D}/usr/sbin/mysqld" 1130 rm -f "${ED}/usr/sbin/mysqld"
1074 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
1075 fi 1132 fi
1076 1133
1077 # Unless they explicitly specific USE=test, then do not install the 1134 # Unless they explicitly specific USE=test, then do not install the
1078 # testsuite. It DOES have a use to be installed, esp. when you want to do a 1135 # testsuite. It DOES have a use to be installed, esp. when you want to do a
1086 3*|4.0) mysql_mycnf_version="4.0" ;; 1143 3*|4.0) mysql_mycnf_version="4.0" ;;
1087 4.[1-9]|5.0) mysql_mycnf_version="4.1" ;; 1144 4.[1-9]|5.0) mysql_mycnf_version="4.1" ;;
1088 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;; 1145 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
1089 esac 1146 esac
1090 einfo "Building default my.cnf (${mysql_mycnf_version})" 1147 einfo "Building default my.cnf (${mysql_mycnf_version})"
1091 insinto "${MY_SYSCONFDIR}" 1148 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
1092 doins scripts/mysqlaccess.conf 1149 doins scripts/mysqlaccess.conf
1093 mycnf_src="my.cnf-${mysql_mycnf_version}" 1150 mycnf_src="my.cnf-${mysql_mycnf_version}"
1094 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ 1151 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
1152 -e "s!/tmp!${EPREFIX}/tmp!" \
1153 -e "s!/usr!${EPREFIX}/usr!" \
1154 -e "s!= /var!= ${EPREFIX}/var!" \
1095 "${FILESDIR}/${mycnf_src}" \ 1155 "${FILESDIR}/${mycnf_src}" \
1096 > "${TMPDIR}/my.cnf.ok" 1156 > "${TMPDIR}/my.cnf.ok"
1157 use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
1097 if use latin1 ; then 1158 if use latin1 ; then
1098 sed -i \ 1159 sed -i \
1099 -e "/character-set/s|utf8|latin1|g" \ 1160 -e "/character-set/s|utf8|latin1|g" \
1100 "${TMPDIR}/my.cnf.ok" 1161 "${TMPDIR}/my.cnf.ok"
1101 fi 1162 fi
1105 if ! use minimal ; then 1166 if ! use minimal ; then
1106 einfo "Creating initial directories" 1167 einfo "Creating initial directories"
1107 # Empty directories ... 1168 # Empty directories ...
1108 diropts "-m0750" 1169 diropts "-m0750"
1109 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then 1170 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
1110 dodir "${MY_DATADIR}" 1171 dodir "${MY_DATADIR#${EPREFIX}}"
1111 keepdir "${MY_DATADIR}" 1172 keepdir "${MY_DATADIR#${EPREFIX}}"
1112 chown -R mysql:mysql "${D}/${MY_DATADIR}" 1173 chown -R mysql:mysql "${D}/${MY_DATADIR}"
1113 fi 1174 fi
1114 1175
1115 diropts "-m0755" 1176 diropts "-m0755"
1116 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do 1177 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
1117 dodir "${folder}" 1178 dodir "${folder}"
1118 keepdir "${folder}" 1179 keepdir "${folder}"
1119 chown -R mysql:mysql "${D}/${folder}" 1180 chown -R mysql:mysql "${ED}/${folder}"
1120 done 1181 done
1121 fi 1182 fi
1122 1183
1123 # Docs 1184 # Docs
1124 einfo "Installing docs" 1185 einfo "Installing docs"
1125 dodoc README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE 1186 for i in README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE ; do
1187 [[ -f "$i" ]] && dodoc "$i"
1188 done
1126 doinfo "${S}"/Docs/mysql.info 1189 doinfo "${S}"/Docs/mysql.info
1127 1190
1128 # Minimal builds don't have the MySQL server 1191 # Minimal builds don't have the MySQL server
1129 if ! use minimal ; then 1192 if ! use minimal ; then
1130 einfo "Including support files and sample configurations" 1193 einfo "Including support files and sample configurations"
1142 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}" 1205 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
1143 done 1206 done
1144 1207
1145 fi 1208 fi
1146 1209
1147 mysql_lib_symlinks "${D}" 1210 mysql_lib_symlinks "${ED}"
1148} 1211}
1149 1212
1150# @FUNCTION: mysql_pkg_preinst 1213# @FUNCTION: mysql_pkg_preinst
1151# @DESCRIPTION: 1214# @DESCRIPTION:
1152# Create the user and groups for mysql - die if that fails. 1215# Create the user and groups for mysql - die if that fails.
1166mysql_pkg_postinst() { 1229mysql_pkg_postinst() {
1167 # Make sure the vars are correctly initialized 1230 # Make sure the vars are correctly initialized
1168 mysql_init_vars 1231 mysql_init_vars
1169 1232
1170 # Check FEATURES="collision-protect" before removing this 1233 # Check FEATURES="collision-protect" before removing this
1171 [[ -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}"
1172 1235
1173 # Secure the logfiles 1236 # Secure the logfiles
1174 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 1237 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
1175 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 1238 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
1176 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 1239 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
1205 elog "mysql_upgrade tool." 1268 elog "mysql_upgrade tool."
1206 einfo 1269 einfo
1207 fi 1270 fi
1208 1271
1209 if pbxt_available && use pbxt ; then 1272 if pbxt_available && use pbxt ; then
1210 # TODO: explain it better 1273 elog "Note: PBXT is now statically built when enabled."
1211 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';" 1274 elog ""
1212 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;" 1275 elog "If, you previously installed as a plugin and "
1213 elog "if, after that, you cannot start the MySQL server," 1276 elog "you cannot start the MySQL server,"
1214 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then" 1277 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
1215 elog "use the MySQL upgrade script to restore the table" 1278 elog "use the MySQL upgrade script to restore the table"
1216 elog "or execute the following SQL command:" 1279 elog "or execute the following SQL command:"
1217 elog " CREATE TABLE IF NOT EXISTS plugin (" 1280 elog " CREATE TABLE IF NOT EXISTS plugin ("
1218 elog " name char(64) binary DEFAULT '' NOT NULL," 1281 elog " name char(64) binary DEFAULT '' NOT NULL,"
1224 mysql_check_version_range "4.0 to 5.0.99.99" \ 1287 mysql_check_version_range "4.0 to 5.0.99.99" \
1225 && use berkdb \ 1288 && use berkdb \
1226 && 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!"
1227} 1290}
1228 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
1229# @FUNCTION: mysql_pkg_config 1312# @FUNCTION: mysql_pkg_config
1230# @DESCRIPTION: 1313# @DESCRIPTION:
1231# Configure mysql environment. 1314# Configure mysql environment.
1232mysql_pkg_config() { 1315mysql_pkg_config() {
1233 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
1234 1320
1235 # Make sure the vars are correctly initialized 1321 # Make sure the vars are correctly initialized
1236 mysql_init_vars 1322 mysql_init_vars
1237 1323
1238 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" 1324 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
1240 if built_with_use ${CATEGORY}/${PN} minimal ; then 1326 if built_with_use ${CATEGORY}/${PN} minimal ; then
1241 die "Minimal builds do NOT include the MySQL server" 1327 die "Minimal builds do NOT include the MySQL server"
1242 fi 1328 fi
1243 1329
1244 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then 1330 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
1245 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%%/}"
1246 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%%/}"
1247 1335
1248 if [[ -d "${old_MY_DATADIR_s}" ]]; then 1336 if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
1249 if [[ -d "${MY_DATADIR_s}" ]]; then 1337 if [[ -d "${MY_DATADIR_s}" ]]; then
1250 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" 1338 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
1251 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}"
1252 else 1340 else
1253 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}"
1265 fi 1353 fi
1266 fi 1354 fi
1267 1355
1268 local pwd1="a" 1356 local pwd1="a"
1269 local pwd2="b" 1357 local pwd2="b"
1270 local MYSQL_ROOT_PASSWORD=''
1271 local maxtry=15 1358 local maxtry=15
1272 1359
1273 if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then 1360 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1274 MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" 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
1275 fi 1381 fi
1276 1382
1277 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then 1383 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1278 ewarn "You have already a MySQL database in place." 1384 ewarn "You have already a MySQL database in place."
1279 ewarn "(${ROOT}/${MY_DATADIR}/*)" 1385 ewarn "(${ROOT}/${MY_DATADIR}/*)"
1285 # localhost. Also causes weird failures. 1391 # localhost. Also causes weird failures.
1286 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" 1392 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1287 1393
1288 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then 1394 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1289 1395
1290 einfo "Please provide a password for the mysql 'root' user now," 1396 einfo "Please provide a password for the mysql 'root' user now, in the"
1291 einfo "or in the MYSQL_ROOT_PASSWORD env var." 1397 einfo "MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file."
1292 ewarn "Avoid [\"'\\_%] characters in the password" 1398 ewarn "Avoid [\"'\\_%] characters in the password"
1293 read -rsp " >" pwd1 ; echo 1399 read -rsp " >" pwd1 ; echo
1294 1400
1295 einfo "Retype the password" 1401 einfo "Retype the password"
1296 read -rsp " >" pwd2 ; echo 1402 read -rsp " >" pwd2 ; echo
1300 fi 1406 fi
1301 MYSQL_ROOT_PASSWORD="${pwd1}" 1407 MYSQL_ROOT_PASSWORD="${pwd1}"
1302 unset pwd1 pwd2 1408 unset pwd1 pwd2
1303 fi 1409 fi
1304 1410
1305 local options="" 1411 local options="--log-warnings=0"
1306 local sqltmp="$(emktemp)" 1412 local sqltmp="$(emktemp)"
1307 1413
1308 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" 1414 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
1309 [[ -r "${help_tables}" ]] \ 1415 [[ -r "${help_tables}" ]] \
1310 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ 1416 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
1311 || touch "${TMPDIR}/fill_help_tables.sql" 1417 || touch "${TMPDIR}/fill_help_tables.sql"
1312 help_tables="${TMPDIR}/fill_help_tables.sql" 1418 help_tables="${TMPDIR}/fill_help_tables.sql"
1313 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
1314 pushd "${TMPDIR}" &>/dev/null 1436 pushd "${TMPDIR}" &>/dev/null
1315 "${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
1316 if [ $? -ne 0 ]; then 1444 if [ $? -ne 0 ]; then
1317 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
1318 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"
1319 fi 1447 fi
1320 popd &>/dev/null 1448 popd &>/dev/null
1321 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ 1449 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1322 || die "MySQL databases not installed" 1450 || die "MySQL databases not installed"
1323 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null 1451 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1324 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null 1452 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1325 1453
1326 # Figure out which options we need to disable to do the setup
1327 helpfile="${TMPDIR}/mysqld-help"
1328 ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
1329 for opt in grant-tables host-cache name-resolve networking slave-start bdb \
1330 federated innodb ssl log-bin relay-log slow-query-log external-locking \
1331 ndbcluster \
1332 ; do
1333 optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
1334 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1335 done
1336 # But some options changed names
1337 egrep -sq external-locking "${helpfile}" && \
1338 options="${options/skip-locking/skip-external-locking}"
1339
1340 if mysql_version_is_at_least "4.1.3" ; then 1454 if mysql_version_is_at_least "4.1.3" ; then
1341 # Filling timezones, see 1455 # Filling timezones, see
1342 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html 1456 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1343 "${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
1344 1458
1345 if [[ -r "${help_tables}" ]] ; then 1459 if [[ -r "${help_tables}" ]] ; then
1346 cat "${help_tables}" >> "${sqltmp}" 1460 cat "${help_tables}" >> "${sqltmp}"
1347 fi 1461 fi
1348 fi 1462 fi
1349 1463
1350 einfo "Creating the mysql database and setting proper" 1464 einfo "Creating the mysql database and setting proper permissions on it ..."
1351 einfo "permissions on it ..."
1352 1465
1353 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" 1466 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1354 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" 1467 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1355 local mysqld="${ROOT}/usr/sbin/mysqld \ 1468 local mysqld="${EROOT}/usr/sbin/mysqld \
1356 ${options} \ 1469 ${options} \
1357 --user=mysql \ 1470 $(use prefix || echo --user=mysql) \
1471 --log-warnings=0 \
1358 --basedir=${ROOT}/usr \ 1472 --basedir=${EROOT}/usr \
1359 --datadir=${ROOT}/${MY_DATADIR} \ 1473 --datadir=${ROOT}/${MY_DATADIR} \
1360 --max_allowed_packet=8M \ 1474 --max_allowed_packet=8M \
1361 --net_buffer_length=16K \ 1475 --net_buffer_length=16K \
1362 --default-storage-engine=MyISAM \ 1476 --default-storage-engine=MyISAM \
1363 --socket=${socket} \ 1477 --socket=${socket} \
1364 --pid-file=${pidfile}" 1478 --pid-file=${pidfile}"
1365 #einfo "About to start mysqld: ${mysqld}" 1479 #einfo "About to start mysqld: ${mysqld}"
1366 ebegin "Starting mysqld" 1480 ebegin "Starting mysqld"
1481 einfo "Command ${mysqld}"
1367 ${mysqld} & 1482 ${mysqld} &
1368 rc=$? 1483 rc=$?
1369 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do 1484 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1370 maxtry=$((${maxtry}-1)) 1485 maxtry=$((${maxtry}-1))
1371 echo -n "." 1486 echo -n "."
1378 fi 1493 fi
1379 1494
1380 ebegin "Setting root password" 1495 ebegin "Setting root password"
1381 # Do this from memory, as we don't want clear text passwords in temp files 1496 # Do this from memory, as we don't want clear text passwords in temp files
1382 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" 1497 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
1383 "${ROOT}/usr/bin/mysql" \ 1498 "${EROOT}/usr/bin/mysql" \
1384 --socket=${socket} \ 1499 --socket=${socket} \
1385 -hlocalhost \ 1500 -hlocalhost \
1386 -e "${sql}" 1501 -e "${sql}"
1387 eend $? 1502 eend $?
1388 1503
1389 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." 1504 ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1390 "${ROOT}/usr/bin/mysql" \ 1505 "${EROOT}/usr/bin/mysql" \
1391 --socket=${socket} \ 1506 --socket=${socket} \
1392 -hlocalhost \ 1507 -hlocalhost \
1393 -uroot \ 1508 -uroot \
1394 -p"${MYSQL_ROOT_PASSWORD}" \ 1509 --password="${MYSQL_ROOT_PASSWORD}" \
1395 mysql < "${sqltmp}" 1510 mysql < "${sqltmp}"
1396 rc=$? 1511 rc=$?
1397 eend $? 1512 eend $?
1398 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!" 1513 [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
1399 1514
1407 1522
1408# @FUNCTION: mysql_pkg_postrm 1523# @FUNCTION: mysql_pkg_postrm
1409# @DESCRIPTION: 1524# @DESCRIPTION:
1410# Remove mysql symlinks. 1525# Remove mysql symlinks.
1411mysql_pkg_postrm() { 1526mysql_pkg_postrm() {
1412 : # mysql_lib_symlinks "${D}" 1527 : # mysql_lib_symlinks "${ED}"
1413} 1528}

Legend:
Removed from v.1.155  
changed lines
  Added in v.1.183

  ViewVC Help
Powered by ViewVC 1.1.20