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

Diff of /eclass/mysql.eclass

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

Revision 1.112 Revision 1.120
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2009 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.eclass,v 1.112 2009/07/06 18:58:41 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.120 2009/12/09 18:46:53 robbat2 Exp $
4 4
5# @ECLASS: mysql.eclass
6# @MAINTAINER:
5# Author: Francesco Riosa (Retired) <vivo@gentoo.org> 7# Author: Francesco Riosa (Retired) <vivo@gentoo.org>
6# Maintainer: MySQL Team <mysql-bugs@gentoo.org> 8# Maintainers: MySQL Team <mysql-bugs@gentoo.org>
7# - Luca Longinotti <chtekk@gentoo.org> 9# - Luca Longinotti <chtekk@gentoo.org>
8# - Robin H. Johnson <robbat2@gentoo.org> 10# - Robin H. Johnson <robbat2@gentoo.org>
11# @BLURB: This eclass provides most of the functions for mysql ebuilds
12# @DESCRIPTION:
13# 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# scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
16# phase hooks.
9 17
10WANT_AUTOCONF="latest" 18WANT_AUTOCONF="latest"
11WANT_AUTOMAKE="latest" 19WANT_AUTOMAKE="latest"
12 20
13inherit eutils flag-o-matic gnuconfig autotools mysql_fx versionator 21inherit eutils flag-o-matic gnuconfig autotools mysql_fx versionator
22
23case "${EAPI:-0}" in
24 2)
25 EXPORT_FUNCTIONS pkg_setup \
26 src_unpack src_prepare \
27 src_configure src_compile \
28 src_install \
29 pkg_preinst pkg_postinst \
30 pkg_config pkg_postrm
31 IUSE_DEFAULT_ON='+'
32 ;;
33 0 | 1)
34 EXPORT_FUNCTIONS pkg_setup \
35 src_unpack \
36 src_compile \
37 src_install \
38 pkg_preinst pkg_postinst \
39 pkg_config pkg_postrm
40 ;;
41 *)
42 die "Unsupported EAPI: ${EAPI}" ;;
43esac
14 44
15# Shorten the path because the socket path length must be shorter than 107 chars 45# Shorten the path because the socket path length must be shorter than 107 chars
16# and we will run a mysql server during test phase 46# and we will run a mysql server during test phase
17S="${WORKDIR}/mysql" 47S="${WORKDIR}/mysql"
18 48
21 EGIT_PROJECT=mysql-extras 51 EGIT_PROJECT=mysql-extras
22 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git" 52 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git"
23 inherit git 53 inherit git
24fi 54fi
25 55
56# @ECLASS-VARIABLE: MYSQL_VERSION_ID
57# @DESCRIPTION:
26# MYSQL_VERSION_ID will be: 58# MYSQL_VERSION_ID will be:
27# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] 59# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
28# This is an important part, because many of the choices the MySQL ebuild will do 60# This is an important part, because many of the choices the MySQL ebuild will do
29# depend on this variable. 61# depend on this variable.
30# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803" 62# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
39 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}" 71 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
40done 72done
41# strip leading "0" (otherwise it's considered an octal number by BASH) 73# strip leading "0" (otherwise it's considered an octal number by BASH)
42MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} 74MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
43 75
76# @ECLASS-VARIABLE: MYSQL_COMMUNITY_FEATURES
77# @DESCRIPTION:
78# Specifiy if community features are available. Possible values are 1 (yes)
79# and 0 (no).
44# Community features are available in mysql-community 80# Community features are available in mysql-community
45# AND in the re-merged mysql-5.0.82 and newer 81# AND in the re-merged mysql-5.0.82 and newer
46if [ "${PN}" == "mysql-community" ]; then 82if [ "${PN}" == "mysql-community" ]; then
47 MYSQL_COMMUNITY_FEATURES=1 83 MYSQL_COMMUNITY_FEATURES=1
48elif [ "${PV#5.0}" != "${PV}" ] && mysql_version_is_at_least "5.0.82"; then 84elif [ "${PV#5.0}" != "${PV}" ] && mysql_version_is_at_least "5.0.82"; then
49 MYSQL_COMMUNITY_FEATURES=1 85 MYSQL_COMMUNITY_FEATURES=1
86elif [ "${PV#5.1}" != "${PV}" ] && mysql_version_is_at_least "5.1.28"; then
87 MYSQL_COMMUNITY_FEATURES=1
88elif [ "${PV#5.4}" != "${PV}" ]; then
89 MYSQL_COMMUNITY_FEATURES=1
50else 90else
51 MYSQL_COMMUNITY_FEATURES=0 91 MYSQL_COMMUNITY_FEATURES=0
52fi 92fi
93
94# @ECLASS-VARIABLE: XTRADB_VER
95# @DESCRIPTION:
96# Version of the XTRADB storage engine
97XTRADB_VER="${XTRADB_VER}"
98
99# @ECLASS-VARIABLE: PERCONA_VER
100# @DESCRIPTION:
101# Designation by PERCONA for a MySQL version to apply an XTRADB release
102PERCONA_VER="${PERCONA_VER}"
53 103
54# Be warned, *DEPEND are version-dependant 104# Be warned, *DEPEND are version-dependant
55# These are used for both runtime and compiletime 105# These are used for both runtime and compiletime
56DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d ) 106DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
57 userland_GNU? ( sys-process/procps ) 107 userland_GNU? ( sys-process/procps )
99SRC_URI="${SERVER_URI}" 149SRC_URI="${SERVER_URI}"
100 150
101[[ ${MY_EXTRAS_VER} != live ]] && SRC_URI="${SRC_URI} 151[[ ${MY_EXTRAS_VER} != live ]] && SRC_URI="${SRC_URI}
102 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 152 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
103 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" 153 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
154PBXT_SRC_URI="mirror://sourceforge/pbxt/pbxt-${PBXT_VERSION}.tar.gz"
104mysql_version_is_at_least "5.1.12" \ 155mysql_version_is_at_least "5.1.12" \
105&& [[ -n "${PBXT_VERSION}" ]] \ 156&& [[ -n "${PBXT_VERSION}" ]] \
106&& SRC_URI="${SRC_URI} pbxt? ( mirror://sourceforge/pbxt/pbxt-${PBXT_VERSION}.tar.gz )" 157&& SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URIPBXT_SRC_URI} )"
158
159# Get the percona tarball if XTRADB_VER and PERCONA_VER are both set
160XTRADB_SRC_URI="http://www.percona.com/${PN}/xtradb/${PERCONA_VER}/source/percona-xtradb-${XTRADB_VER}.tar.gz"
161mysql_version_is_at_least "5.1.26" \
162&& [[ -n ${XTRADB_VER} && -n ${PERCONA_VER} ]] \
163&& SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI} )"
107 164
108DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." 165DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
109HOMEPAGE="http://www.mysql.com/" 166HOMEPAGE="http://www.mysql.com/"
110LICENSE="GPL-2" 167LICENSE="GPL-2"
111SLOT="0" 168SLOT="0"
112IUSE="big-tables debug embedded minimal perl selinux ssl static" 169IUSE="big-tables debug embedded minimal ${IUSE_DEFAULT_ON}perl selinux ssl static"
113 170
114mysql_version_is_at_least "4.1" \ 171mysql_version_is_at_least "4.1" \
115&& IUSE="${IUSE} latin1" 172&& IUSE="${IUSE} latin1"
116 173
117mysql_version_is_at_least "4.1.3" \ 174mysql_version_is_at_least "4.1.3" \
127|| IUSE="${IUSE} berkdb" 184|| IUSE="${IUSE} berkdb"
128 185
129mysql_version_is_at_least "5.1.12" \ 186mysql_version_is_at_least "5.1.12" \
130&& IUSE="${IUSE} pbxt" 187&& IUSE="${IUSE} pbxt"
131 188
189mysql_version_is_at_least "5.1.26" \
190&& IUSE="${IUSE} xtradb"
191
132[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \ 192[ "${MYSQL_COMMUNITY_FEATURES}" == "1" ] \
133&& IUSE="${IUSE} community profiling" 193&& IUSE="${IUSE} ${IUSE_DEFAULT_ON}community profiling"
134
135case "${EAPI:-0}" in
136 2)
137 EXPORT_FUNCTIONS pkg_setup \
138 src_unpack src_prepare \
139 src_configure src_compile \
140 src_install \
141 pkg_preinst pkg_postinst \
142 pkg_config pkg_postrm
143 ;;
144 *)
145 EXPORT_FUNCTIONS pkg_setup \
146 src_unpack \
147 src_compile \
148 src_install \
149 pkg_preinst pkg_postinst \
150 pkg_config pkg_postrm
151 ;;
152esac
153 194
154# 195#
155# HELPER FUNCTIONS: 196# HELPER FUNCTIONS:
156# 197#
157 198
199# @FUNCTION: mysql_disable_test
200# @DESCRIPTION:
201# Helper function to disable specific tests.
158mysql_disable_test() { 202mysql_disable_test() {
159 local testname="${1}" ; shift 203 local testname="${1}" ; shift
160 local reason="${@}" 204 local reason="${@}"
161 local mysql_disable_file="${S}/mysql-test/t/disabled.def" 205 local mysql_disable_file="${S}/mysql-test/t/disabled.def"
162 echo ${testname} : ${reason} >> "${mysql_disable_file}" 206 echo ${testname} : ${reason} >> "${mysql_disable_file}"
163 ewarn "test '${testname}' disabled: '${reason}'" 207 ewarn "test '${testname}' disabled: '${reason}'"
164} 208}
165 209
210# @FUNCTION: mysql_init_vars
211# @DESCRIPTION:
166# void mysql_init_vars() 212# void mysql_init_vars()
167#
168# Initialize global variables 213# Initialize global variables
169# 2005-11-19 <vivo@gentoo.org> 214# 2005-11-19 <vivo@gentoo.org>
170
171mysql_init_vars() { 215mysql_init_vars() {
172 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"} 216 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"}
173 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"} 217 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
174 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"} 218 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"}
175 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"} 219 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
461} 505}
462 506
463# 507#
464# EBUILD FUNCTIONS 508# EBUILD FUNCTIONS
465# 509#
510# @FUNCTION: mysql_pkg_setup
511# @DESCRIPTION:
512# Perform some basic tests and tasks during pkg_setup phase:
513# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
514# check for conflicting use flags
515# create new user and group for mysql
516# warn about deprecated features
466mysql_pkg_setup() { 517mysql_pkg_setup() {
467 if hasq test ${FEATURES} ; then 518 if hasq test ${FEATURES} ; then
468 if ! use minimal ; then 519 if ! use minimal ; then
469 if [[ $UID -eq 0 ]]; then 520 if [[ $UID -eq 0 ]]; then
470 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." 521 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
500 mysql_check_version_range "4.0 to 5.0.99.99" \ 551 mysql_check_version_range "4.0 to 5.0.99.99" \
501 && use berkdb \ 552 && use berkdb \
502 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 553 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
503} 554}
504 555
556# @FUNCTION: mysql_src_unpack
557# @DESCRIPTION:
558# Unpack the source code and call mysql_src_prepare for EAPI < 2.
505mysql_src_unpack() { 559mysql_src_unpack() {
506 # Initialize the proper variables first 560 # Initialize the proper variables first
507 mysql_init_vars 561 mysql_init_vars
508 562
509 unpack ${A} 563 unpack ${A}
510 # Grab the patches 564 # Grab the patches
511 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack 565 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack
512 566
513 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}" 567 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
514 568
515 # Be backwards compatible for now 569 # Be backwards compatible for now
516 if [[ $EAPI != 2 ]]; then 570 case ${EAPI:-0} in
517 mysql_src_prepare 571 2) : ;;
518 fi 572 0 | 1) mysql_src_prepare ;;
573 esac
519} 574}
520 575
576# @FUNCTION: mysql_src_prepare
577# @DESCRIPTION:
578# Apply patches to the source code and remove unneeded bundled libs.
521mysql_src_prepare() { 579mysql_src_prepare() {
522 cd "${S}" 580 cd "${S}"
523 581
524 # Apply the patches for this MySQL version 582 # Apply the patches for this MySQL version
525 EPATCH_SUFFIX="patch" 583 EPATCH_SUFFIX="patch"
587 || die "Failed bdb reconfigure" 645 || die "Failed bdb reconfigure"
588 popd &>/dev/null 646 popd &>/dev/null
589 fi 647 fi
590} 648}
591 649
650# @FUNCTION: mysql_src_configure
651# @DESCRIPTION:
652# Configure mysql to build the code for Gentoo respecting the use flags.
592mysql_src_configure() { 653mysql_src_configure() {
593 # Make sure the vars are correctly initialized 654 # Make sure the vars are correctly initialized
594 mysql_init_vars 655 mysql_init_vars
595 656
596 # $myconf is modified by the configure_* functions 657 # $myconf is modified by the configure_* functions
622 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing" 683 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
623 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti" 684 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
624 mysql_version_is_at_least "5.0" \ 685 mysql_version_is_at_least "5.0" \
625 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" 686 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
626 export CXXFLAGS 687 export CXXFLAGS
688
689 # bug #283926, with GCC4.4, this is required to get correct behavior.
690 append-flags -fno-strict-aliasing
627 691
628 econf \ 692 econf \
629 --libexecdir="/usr/sbin" \ 693 --libexecdir="/usr/sbin" \
630 --sysconfdir="${MY_SYSCONFDIR}" \ 694 --sysconfdir="${MY_SYSCONFDIR}" \
631 --localstatedir="${MY_LOCALSTATEDIR}" \ 695 --localstatedir="${MY_LOCALSTATEDIR}" \
647 if [[ $EAPI == 2 ]]; then 711 if [[ $EAPI == 2 ]]; then
648 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_configure 712 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_configure
649 fi 713 fi
650} 714}
651 715
716# @FUNCTION: mysql_src_compile
717# @DESCRIPTION:
718# Compile the mysql code.
652mysql_src_compile() { 719mysql_src_compile() {
653 # Be backwards compatible for now 720 # Be backwards compatible for now
654 if [[ $EAPI != 2 ]]; then 721 case ${EAPI:-0} in
655 mysql_src_configure 722 2) : ;;
656 fi 723 0 | 1) mysql_src_configure ;;
724 esac
657 725
658 emake || die "emake failed" 726 emake || die "emake failed"
659 727
660 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile 728 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile
661} 729}
662 730
731# @FUNCTION: mysql_src_install
732# @DESCRIPTION:
733# Install mysql.
663mysql_src_install() { 734mysql_src_install() {
664 # Make sure the vars are correctly initialized 735 # Make sure the vars are correctly initialized
665 mysql_init_vars 736 mysql_init_vars
666 737
667 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed" 738 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed"
753 fi 824 fi
754 825
755 mysql_lib_symlinks "${D}" 826 mysql_lib_symlinks "${D}"
756} 827}
757 828
829# @FUNCTION: mysql_pkg_preinst
830# @DESCRIPTION:
831# Create the user and groups for mysql - die if that fails.
758mysql_pkg_preinst() { 832mysql_pkg_preinst() {
759 enewgroup mysql 60 || die "problem adding 'mysql' group" 833 enewgroup mysql 60 || die "problem adding 'mysql' group"
760 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" 834 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
761} 835}
762 836
837# @FUNCTION: mysql_pkg_postinst
838# @DESCRIPTION:
839# Run post-installation tasks:
840# create the dir for logfiles if non-existant
841# touch the logfiles and secure them
842# install scripts
843# issue required steps for optional features
844# issue deprecation warnings
763mysql_pkg_postinst() { 845mysql_pkg_postinst() {
764 # Make sure the vars are correctly initialized 846 # Make sure the vars are correctly initialized
765 mysql_init_vars 847 mysql_init_vars
766 848
767 # Check FEATURES="collision-protect" before removing this 849 # Check FEATURES="collision-protect" before removing this
813 mysql_check_version_range "4.0 to 5.0.99.99" \ 895 mysql_check_version_range "4.0 to 5.0.99.99" \
814 && use berkdb \ 896 && use berkdb \
815 && elog "Berkeley DB support is deprecated and will be removed in future versions!" 897 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
816} 898}
817 899
900# @FUNCTION: mysql_pkg_config
901# @DESCRIPTION:
902# Configure mysql environment.
818mysql_pkg_config() { 903mysql_pkg_config() {
819 local old_MY_DATADIR="${MY_DATADIR}" 904 local old_MY_DATADIR="${MY_DATADIR}"
820 905
821 # Make sure the vars are correctly initialized 906 # Make sure the vars are correctly initialized
822 mysql_init_vars 907 mysql_init_vars
845 if [[ -d "${MY_DATADIR_s}" ]]; then 930 if [[ -d "${MY_DATADIR_s}" ]]; then
846 ewarn "Attempting to use ${MY_DATADIR_s}" 931 ewarn "Attempting to use ${MY_DATADIR_s}"
847 else 932 else
848 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" 933 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
849 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" 934 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
850 fi 935 fi
851 fi 936 fi
852 fi 937 fi
853 938
854 local pwd1="a" 939 local pwd1="a"
855 local pwd2="b" 940 local pwd2="b"
957 einfo "Stopping the server ..." 1042 einfo "Stopping the server ..."
958 wait %1 1043 wait %1
959 einfo "Done" 1044 einfo "Done"
960} 1045}
961 1046
1047# @FUNCTION: mysql_pkg_postrm
1048# @DESCRIPTION:
1049# Remove mysql symlinks.
962mysql_pkg_postrm() { 1050mysql_pkg_postrm() {
963 : # mysql_lib_symlinks "${D}" 1051 : # mysql_lib_symlinks "${D}"
964} 1052}

Legend:
Removed from v.1.112  
changed lines
  Added in v.1.120

  ViewVC Help
Powered by ViewVC 1.1.20