| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.4 2011/07/21 05:57:22 jmbsvicetto Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.12 2012/01/06 21:32:48 jmbsvicetto 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> |
| … | |
… | |
| 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 | # scr_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 | |
| 26 | case ${BUILD} in |
26 | case ${BUILD} in |
| 27 | "cmake") |
27 | "cmake") |
| 28 | BUILD_INHERIT="mysql-cmake" |
28 | BUILD_INHERIT="mysql-cmake" |
| … | |
… | |
| 39 | esac |
39 | esac |
| 40 | |
40 | |
| 41 | MYSQL_EXTRAS="" |
41 | MYSQL_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 | |
| 47 | inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs |
49 | inherit 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 | |
| 53 | case "${EAPI:-0}" in |
55 | case "${EAPI:-0}" in |
| 54 | 2|3|4) ;; |
56 | 3|4) ;; |
| 55 | *) die "Unsupported EAPI: ${EAPI}" ;; |
57 | *) die "Unsupported EAPI: ${EAPI}" ;; |
| 56 | esac |
58 | esac |
| 57 | |
59 | |
| 58 | EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
60 | EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
| 59 | |
61 | |
| … | |
… | |
| 171 | |
173 | |
| 172 | # Define correct SRC_URIs |
174 | # Define correct SRC_URIs |
| 173 | SRC_URI="${SERVER_URI}" |
175 | SRC_URI="${SERVER_URI}" |
| 174 | |
176 | |
| 175 | # Gentoo patches to MySQL |
177 | # Gentoo patches to MySQL |
| 176 | [[ ${MY_EXTRAS_VER} != live ]] \ |
178 | [[ ${MY_EXTRAS_VER} != live ]] && [[ ${MY_EXTRAS_VER} != none ]] \ |
| 177 | && SRC_URI="${SRC_URI} |
179 | && SRC_URI="${SRC_URI} |
| 178 | mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
180 | mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
| 179 | http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
181 | 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 |
182 | 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" |
183 | http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" |
| … | |
… | |
| 223 | |
225 | |
| 224 | [[ ${PN} == "mariadb" ]] \ |
226 | [[ ${PN} == "mariadb" ]] \ |
| 225 | && mysql_version_is_at_least "5.2.5" \ |
227 | && mysql_version_is_at_least "5.2.5" \ |
| 226 | && IUSE="${IUSE} sphinx" |
228 | && IUSE="${IUSE} sphinx" |
| 227 | |
229 | |
|
|
230 | mysql_version_is_at_least "5.5.7" \ |
|
|
231 | && IUSE="${IUSE} systemtap" |
| 228 | |
232 | |
| 229 | # |
233 | # |
| 230 | # DEPENDENCIES: |
234 | # DEPENDENCIES: |
| 231 | # |
235 | # |
| 232 | |
236 | |
| 233 | # Be warned, *DEPEND are version-dependant |
237 | # Be warned, *DEPEND are version-dependant |
| 234 | # These are used for both runtime and compiletime |
238 | # These are used for both runtime and compiletime |
| 235 | DEPEND=" |
239 | DEPEND=" |
| 236 | ssl? ( >=dev-libs/openssl-0.9.6d ) |
240 | ssl? ( >=dev-libs/openssl-0.9.6d ) |
| 237 | userland_GNU? ( sys-process/procps ) |
241 | kernel_linux? ( sys-process/procps ) |
| 238 | >=sys-apps/sed-4 |
242 | >=sys-apps/sed-4 |
| 239 | >=sys-apps/texinfo-4.7-r1 |
243 | >=sys-apps/texinfo-4.7-r1 |
| 240 | >=sys-libs/readline-4.1 |
244 | >=sys-libs/readline-4.1 |
| 241 | >=sys-libs/zlib-1.2.3 |
245 | >=sys-libs/zlib-1.2.3 |
| 242 | " |
246 | " |
| … | |
… | |
| 248 | for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do |
252 | for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do |
| 249 | [[ ${i} == ${PN} ]] || |
253 | [[ ${i} == ${PN} ]] || |
| 250 | DEPEND="${DEPEND} !dev-db/${i}" |
254 | DEPEND="${DEPEND} !dev-db/${i}" |
| 251 | done |
255 | done |
| 252 | |
256 | |
|
|
257 | # prefix: first need to implement something for #196294 |
| 253 | RDEPEND="${DEPEND} |
258 | RDEPEND="${DEPEND} |
| 254 | !minimal? ( dev-db/mysql-init-scripts ) |
259 | !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) ) |
| 255 | selinux? ( sec-policy/selinux-mysql ) |
260 | selinux? ( sec-policy/selinux-mysql ) |
|
|
261 | " |
|
|
262 | |
|
|
263 | DEPEND="${DEPEND} |
|
|
264 | virtual/yacc |
| 256 | " |
265 | " |
| 257 | |
266 | |
| 258 | DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )" |
267 | DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )" |
| 259 | |
268 | |
| 260 | # compile-time-only |
269 | # compile-time-only |
| … | |
… | |
| 269 | && DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )" |
278 | && DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )" |
| 270 | |
279 | |
| 271 | [[ "${PN}" == "mariadb" ]] \ |
280 | [[ "${PN}" == "mariadb" ]] \ |
| 272 | && mysql_version_is_at_least "5.2.5" \ |
281 | && mysql_version_is_at_least "5.2.5" \ |
| 273 | && DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" |
282 | && DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )" |
|
|
283 | |
|
|
284 | mysql_version_is_at_least "5.5.7" \ |
|
|
285 | && DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )" |
| 274 | |
286 | |
| 275 | # dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
287 | # dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
| 276 | PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
288 | PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
| 277 | |
289 | |
| 278 | # For other stuff to bring us in |
290 | # For other stuff to bring us in |
| … | |
… | |
| 373 | # warn about deprecated features |
385 | # warn about deprecated features |
| 374 | mysql-v2_pkg_setup() { |
386 | mysql-v2_pkg_setup() { |
| 375 | |
387 | |
| 376 | if has test ${FEATURES} ; then |
388 | if has test ${FEATURES} ; then |
| 377 | if ! use minimal ; then |
389 | if ! use minimal ; then |
| 378 | if [[ $UID -eq 0 ]]; then |
390 | if ! has userpriv ${FEATURES} ; then |
| 379 | eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
391 | eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
| 380 | fi |
392 | fi |
| 381 | fi |
393 | fi |
| 382 | fi |
394 | fi |
| 383 | |
395 | |
| … | |
… | |
| 487 | |
499 | |
| 488 | # Make sure the vars are correctly initialized |
500 | # Make sure the vars are correctly initialized |
| 489 | mysql_init_vars |
501 | mysql_init_vars |
| 490 | |
502 | |
| 491 | # Check FEATURES="collision-protect" before removing this |
503 | # Check FEATURES="collision-protect" before removing this |
| 492 | [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
504 | [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
| 493 | |
505 | |
| 494 | # Secure the logfiles |
506 | # Secure the logfiles |
| 495 | touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} |
507 | touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} |
| 496 | chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* |
508 | chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* |
| 497 | chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* |
509 | chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* |
| … | |
… | |
| 589 | |
601 | |
| 590 | local pwd1="a" |
602 | local pwd1="a" |
| 591 | local pwd2="b" |
603 | local pwd2="b" |
| 592 | local maxtry=15 |
604 | local maxtry=15 |
| 593 | |
605 | |
| 594 | if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then |
606 | if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then |
| 595 | MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" |
607 | MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")" |
| 596 | fi |
608 | fi |
| 597 | |
609 | |
| 598 | if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
610 | if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
| 599 | ewarn "You have already a MySQL database in place." |
611 | ewarn "You have already a MySQL database in place." |
| 600 | ewarn "(${ROOT}/${MY_DATADIR}/*)" |
612 | ewarn "(${ROOT}/${MY_DATADIR}/*)" |
| … | |
… | |
| 631 | && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
643 | && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
| 632 | || touch "${TMPDIR}/fill_help_tables.sql" |
644 | || touch "${TMPDIR}/fill_help_tables.sql" |
| 633 | help_tables="${TMPDIR}/fill_help_tables.sql" |
645 | help_tables="${TMPDIR}/fill_help_tables.sql" |
| 634 | |
646 | |
| 635 | pushd "${TMPDIR}" &>/dev/null |
647 | pushd "${TMPDIR}" &>/dev/null |
| 636 | "${ROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 |
648 | "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1 |
| 637 | if [ $? -ne 0 ]; then |
649 | if [ $? -ne 0 ]; then |
| 638 | grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
650 | grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
| 639 | die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
651 | die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
| 640 | fi |
652 | fi |
| 641 | popd &>/dev/null |
653 | popd &>/dev/null |
| 642 | [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
654 | [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
| 643 | || die "MySQL databases not installed" |
655 | || die "MySQL databases not installed" |
| 644 | chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
656 | chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
| 645 | chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
657 | chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
| 646 | |
658 | |
| 647 | # Figure out which options we need to disable to do the setup |
659 | # Figure out which options we need to disable to do the setup |
| 648 | helpfile="${TMPDIR}/mysqld-help" |
660 | helpfile="${TMPDIR}/mysqld-help" |
| 649 | ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
661 | ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
| 650 | for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
662 | for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
| 651 | federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
663 | federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
| 652 | ndbcluster \ |
664 | ndbcluster \ |
| 653 | ; do |
665 | ; do |
| 654 | optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
666 | optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
| … | |
… | |
| 658 | egrep -sq external-locking "${helpfile}" && \ |
670 | egrep -sq external-locking "${helpfile}" && \ |
| 659 | options="${options/skip-locking/skip-external-locking}" |
671 | options="${options/skip-locking/skip-external-locking}" |
| 660 | |
672 | |
| 661 | # Filling timezones, see |
673 | # Filling timezones, see |
| 662 | # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
674 | # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
| 663 | "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
675 | "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
| 664 | |
676 | |
| 665 | if [[ -r "${help_tables}" ]] ; then |
677 | if [[ -r "${help_tables}" ]] ; then |
| 666 | cat "${help_tables}" >> "${sqltmp}" |
678 | cat "${help_tables}" >> "${sqltmp}" |
| 667 | fi |
679 | fi |
| 668 | |
680 | |
| 669 | einfo "Creating the mysql database and setting proper" |
681 | einfo "Creating the mysql database and setting proper" |
| 670 | einfo "permissions on it ..." |
682 | einfo "permissions on it ..." |
| 671 | |
683 | |
| 672 | local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
684 | local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
| 673 | local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
685 | local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
| 674 | local mysqld="${ROOT}/usr/sbin/mysqld \ |
686 | local mysqld="${EROOT}/usr/sbin/mysqld \ |
| 675 | ${options} \ |
687 | ${options} \ |
| 676 | --user=mysql \ |
688 | --user=mysql \ |
| 677 | --basedir=${ROOT}/usr \ |
689 | --basedir=${EROOT}/usr \ |
| 678 | --datadir=${ROOT}/${MY_DATADIR} \ |
690 | --datadir=${ROOT}/${MY_DATADIR} \ |
| 679 | --max_allowed_packet=8M \ |
691 | --max_allowed_packet=8M \ |
| 680 | --net_buffer_length=16K \ |
692 | --net_buffer_length=16K \ |
| 681 | --default-storage-engine=MyISAM \ |
693 | --default-storage-engine=MyISAM \ |
| 682 | --socket=${socket} \ |
694 | --socket=${socket} \ |
| … | |
… | |
| 697 | fi |
709 | fi |
| 698 | |
710 | |
| 699 | ebegin "Setting root password" |
711 | ebegin "Setting root password" |
| 700 | # Do this from memory, as we don't want clear text passwords in temp files |
712 | # Do this from memory, as we don't want clear text passwords in temp files |
| 701 | local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
713 | local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
| 702 | "${ROOT}/usr/bin/mysql" \ |
714 | "${EROOT}/usr/bin/mysql" \ |
| 703 | --socket=${socket} \ |
715 | --socket=${socket} \ |
| 704 | -hlocalhost \ |
716 | -hlocalhost \ |
| 705 | -e "${sql}" |
717 | -e "${sql}" |
| 706 | eend $? |
718 | eend $? |
| 707 | |
719 | |
| 708 | ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." |
720 | ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." |
| 709 | "${ROOT}/usr/bin/mysql" \ |
721 | "${EROOT}/usr/bin/mysql" \ |
| 710 | --socket=${socket} \ |
722 | --socket=${socket} \ |
| 711 | -hlocalhost \ |
723 | -hlocalhost \ |
| 712 | -uroot \ |
724 | -uroot \ |
| 713 | -p"${MYSQL_ROOT_PASSWORD}" \ |
725 | -p"${MYSQL_ROOT_PASSWORD}" \ |
| 714 | mysql < "${sqltmp}" |
726 | mysql < "${sqltmp}" |
| … | |
… | |
| 727 | # @FUNCTION: mysql-v2_pkg_postrm |
739 | # @FUNCTION: mysql-v2_pkg_postrm |
| 728 | # @DESCRIPTION: |
740 | # @DESCRIPTION: |
| 729 | # Remove mysql symlinks. |
741 | # Remove mysql symlinks. |
| 730 | mysql-v2_pkg_postrm() { |
742 | mysql-v2_pkg_postrm() { |
| 731 | |
743 | |
| 732 | : # mysql_lib_symlinks "${D}" |
744 | : # mysql_lib_symlinks "${ED}" |
| 733 | } |
745 | } |