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

Diff of /eclass/mysql.eclass

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

Revision 1.2 Revision 1.6
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 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.2 2006/01/04 20:25:14 vivo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.6 2006/01/14 19:00:32 vivo Exp $
4 4
5# Author: Francesco Riosa <vivo at gentoo.org> 5# Author: Francesco Riosa <vivo at gentoo.org>
6# Maintainer: Francesco Riosa <vivo at gentoo.org> 6# Maintainer: Francesco Riosa <vivo at gentoo.org>
7 7
8inherit eutils flag-o-matic gnuconfig mysql_fx 8inherit eutils flag-o-matic gnuconfig mysql_fx
16 16
17DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" 17DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
18HOMEPAGE="http://www.mysql.com/" 18HOMEPAGE="http://www.mysql.com/"
19NEWP="${PN}-${PV/_/-}" 19NEWP="${PN}-${PV/_/-}"
20SRC_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/${NEWP}.tar.gz 20SRC_URI="mirror://mysql/Downloads/MySQL-${PV%.*}/${NEWP}.tar.gz
21 mirror://gentoo/mysql-extras-20051220.tar.bz2" 21 mirror://gentoo/mysql-extras-20060114.tar.bz2"
22
23LICENSE="GPL-2" 22LICENSE="GPL-2"
24KEYWORDS="-*"
25IUSE="big-tables berkdb debug minimal perl selinux ssl static" 23IUSE="big-tables berkdb debug minimal perl selinux ssl static"
26RESTRICT="primaryuri" 24RESTRICT="primaryuri"
25DEPEND="app-admin/eselect-mysql"
27 26
28mysql_version_is_at_least "4.01.03.00" \ 27mysql_version_is_at_least "4.01.03.00" \
29&& IUSE="${IUSE} cluster utf8 extraengine" 28&& IUSE="${IUSE} cluster utf8 extraengine"
30 29
31mysql_version_is_at_least "5.00.18.00" \ 30mysql_version_is_at_least "5.00.18.00" \
60 die "USEs cluster, extraengine conflicts with \"minimal\"" 59 die "USEs cluster, extraengine conflicts with \"minimal\""
61 fi 60 fi
62 61
63 unpack ${A} || die 62 unpack ${A} || die
64 63
65 mv "${WORKDIR}/${NEWP}" "${S}" 64 mv -f "${WORKDIR}/${NEWP}" "${S}"
66 cd "${S}" 65 cd "${S}"
67 66
68 EPATCH_SUFFIX="patch" 67 EPATCH_SUFFIX="patch"
69 mkdir -p "${EPATCH_SOURCE}" || die "unable to create epatch directory" 68 mkdir -p "${EPATCH_SOURCE}" || die "unable to create epatch directory"
70 mysql_mv_patches 69 mysql_mv_patches
104 bdbdir='bdb/dist' 103 bdbdir='bdb/dist'
105 fi 104 fi
106 105
107 for d in ${rebuilddirlist}; do 106 for d in ${rebuilddirlist}; do
108 einfo "reconfiguring dir \"${d}\"" 107 einfo "reconfiguring dir \"${d}\""
109 pushd "${d}" 108 pushd "${d}" &>/dev/null
110 for buildstep in \ 109 for buildstep in \
111 'libtoolize --copy --force' \ 110 'libtoolize --copy --force' \
112 'aclocal --force' \ 111 'aclocal --force' \
113 'autoheader --force -Wnone' \ 112 'autoheader --force -Wnone' \
114 'autoconf --force -Wnone' \ 113 'autoconf --force -Wnone' \
116 'gnuconfig_update' 115 'gnuconfig_update'
117 do 116 do
118 einfo "performing ${buildstep}" 117 einfo "performing ${buildstep}"
119 ${buildstep} || die "failed ${buildstep/ */} dir \"${d}\"" 118 ${buildstep} || die "failed ${buildstep/ */} dir \"${d}\""
120 done 119 done
121 popd 120 popd &>/dev/null
122 done 121 done
123 122
124 if ! mysql_check_version_range "5.01.00.00 to 5.01.06.99" ; then 123 if ! useq bdbdir && ! mysql_check_version_range "5.01.00.00 to 5.01.06.99"
124 then
125 [[ -w "${bdbdir}/ltmain.sh" ]] && cp ltmain.sh "${bdbdir}/ltmain.sh" 125 [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh"
126 pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" 126 pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null
127 popd 127 popd &>/dev/null
128 fi 128 fi
129 129
130} 130}
131 131
132src_compile() { 132mysql_src_compile() {
133 133
134 mysql_init_vars 134 mysql_init_vars
135 local myconf 135 local myconf
136 136
137 if useq static ; then 137 if useq static ; then
331 binary-configure* my-*.cnf mi_test_all* 331 binary-configure* my-*.cnf mi_test_all*
332 do 332 do
333 rm -f ${D}/usr/share/mysql/${removeme} 333 rm -f ${D}/usr/share/mysql/${removeme}
334 done 334 done
335 335
336 # oops
337 mysql_check_version_range "5.00.16.00 to 5.00.18.99" \
338 && cp "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0.15" "${D}/usr/share/mysql${MY_SUFFIX}/"
339
340 # TODO change at Makefile-am level 336 # TODO change at Makefile-am level
341 for moveme in "mysql_fix_privilege_tables.sql" \ 337 for moveme in "mysql_fix_privilege_tables.sql" \
342 "fill_help_tables.sql" "ndb-config-2-node.ini" 338 "fill_help_tables.sql" "ndb-config-2-node.ini"
343 do 339 do
344 mv "${D}/usr/share/mysql/${moveme}" "${D}/usr/share/mysql${MY_SUFFIX}/" 2>/dev/null 340 mv -f "${D}/usr/share/mysql/${moveme}" "${D}/usr/share/mysql${MY_SUFFIX}/" 2>/dev/null
345 done 341 done
346 342
347 if [[ -n "${MY_SUFFIX}" ]] ; then 343 if [[ -n "${MY_SUFFIX}" ]] ; then
348 local notcatched=$(ls "${D}/usr/share/mysql"/*) 344 local notcatched=$(ls "${D}/usr/share/mysql"/*)
349 if [[ -n "${notcatched}" ]] ; then 345 if [[ -n "${notcatched}" ]] ; then
366 # config stuff 362 # config stuff
367 insinto "${MY_SYSCONFDIR}" 363 insinto "${MY_SYSCONFDIR}"
368 doins scripts/mysqlaccess.conf 364 doins scripts/mysqlaccess.conf
369 newins "${FILESDIR}/my.cnf-4.1" my.cnf 365 newins "${FILESDIR}/my.cnf-4.1" my.cnf
370 insinto "/etc/conf.d" 366 insinto "/etc/conf.d"
371 newins "${FILESDIR}/mysql-slot.conf.d-r1" "mysql" 367 newins "${FILESDIR}/mysql-slot.conf.d-r2" "mysql"
372 mysql_version_is_at_least "5.00.11.00" \ 368 mysql_version_is_at_least "5.00.11.00" \
373 && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager" 369 && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager"
374 370
375 local charset='utf8' 371 local charset='utf8'
376 ! useq utf8 && local charset='latin1' 372 ! useq utf8 && local charset='latin1'
380 "${D}/etc/mysql${MY_SUFFIX}/my.cnf" 376 "${D}/etc/mysql${MY_SUFFIX}/my.cnf"
381 377
382 # minimal builds don't have the server 378 # minimal builds don't have the server
383 if ! useq minimal; then 379 if ! useq minimal; then
384 exeinto /etc/init.d 380 exeinto /etc/init.d
385 newexe "${FILESDIR}/mysql-slot.rc6-r1" "mysql" 381 newexe "${FILESDIR}/mysql-slot.rc6-r2" "mysql"
382 [[ ${SLOT} -gt 0 ]] && dosym "/etc/init.d/mysql" "/etc/init.d/mysql${MY_SUFFIX}"
383
386 mysql_version_is_at_least "5.00.11.00" \ 384 mysql_version_is_at_least "5.00.11.00" \
387 && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager" 385 && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager"
388 insinto /etc/logrotate.d 386 insinto /etc/logrotate.d
389 # TODO 387 # TODO
390 newins "${FILESDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" 388 newins "${FILESDIR}/logrotate.mysql" "mysql${MY_SUFFIX}"
417 do 415 do
418 dodoc "${script}" 416 dodoc "${script}"
419 done 417 done
420 418
421 docinto "scripts" 419 docinto "scripts"
422 for script in \ 420 for script in scripts/mysql* ; do
423 $(ls scripts/mysql* | grep -v '.sh$') 421 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
424 do
425 dodoc "${script}"
426 done 422 done
427 fi 423 fi
424
425 # oops, temporary fix
426 mysql_check_version_range "5.00.16.00 to 5.00.18.99" \
427 && cp -f \
428 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \
429 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql"
428} 430}
429 431
430mysql_pkg_preinst() { 432mysql_pkg_preinst() {
431 433
432 enewgroup mysql 60 || die "problem adding group mysql" 434 enewgroup mysql 60 || die "problem adding group mysql"
446 #secure the logfiles... does this bother anybody? 448 #secure the logfiles... does this bother anybody?
447 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 449 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
448 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 450 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
449 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 451 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
450 452
453 # create a list of files, to be used
454 # by external utilities
455 # uncompressed because of the small size
456 local filelist="${ROOT}/var/lib/eselect/mysql/mysql${MY_SUFFIX}"
457 pushd "${D}/" &>/dev/null
458 mkdir -p "${ROOT}/var/lib/eselect/mysql/"
459 env -i find usr/bin/ usr/sbin/ usr/share/man \
460 -type f -name "*${MY_SUFFIX}*" \
461 -and -not -name "mysql_config${MY_SUFFIX}" \
462 > "${filelist}.filelist"
463 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}.filelist"
464 echo "${MY_LIBDIR#"/"}" >> "${filelist}.filelist"
465 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}.filelist"
466 popd &>/dev/null
467
451 if ! useq minimal; then 468 if ! useq minimal; then
469 if [[ ${SLOT} -gt 0 ]] ; then
470 if [[ -f "${ROOT}/usr/sbin/mysqld" ]] ; then
471 einfo "you may want to run unmerge any unslotted MySQL versions with "
472 einfo "emerge -C --pretend dev-db/mysql"
473 einfo "emerge -C =dev-db/mysql-X.Y.Z"
474 einfo "After the unmerge run \"eselect myqsl list\" followed by a "
475 einfo "\"eselect myqsl set 1\" to chose the default mysql server"
476 else
477 local tmpres="$( eselect mysql show )"
478 # "like grep -q unset"
479 if [[ "{$tmpres}" == "{$tmpres/unset/}" ]] ; then
480 eselect mysql set 1
481 else
482 einfo "The version of mysql emerged now stils is _NOT_ the default"
483 einfo "you may want to run \"eselect myqsl list\" followed by a "
484 einfo "\"eselect myqsl set 1\" to chose the default mysql server"
485 fi
486 fi
487 fi
488
452 # your friendly public service announcement... 489 # your friendly public service announcement...
453 einfo 490 einfo
454 einfo "You might want to run:" 491 einfo "You might want to run:"
455 einfo "\"emerge --config =${CATEGORY}/${PF}\"" 492 einfo "\"emerge --config =${CATEGORY}/${PF}\""
456 einfo "if this is a new install." 493 einfo "if this is a new install."
457 einfo 494 einfo
458 fi
459
460 einfo "InnoDB is not optional as of MySQL-4.0.24, at the request of upstream." 495 einfo "InnoDB is not optional as of MySQL-4.0.24, at the request of upstream."
496 fi
461} 497}
462 498
463mysql_pkg_config() { 499mysql_pkg_config() {
464 mysql_init_vars 500 mysql_init_vars
465 [[ -z "${DATADIR}" ]] && die "sorry, unable to find DATADIR" 501 [[ -z "${DATADIR}" ]] && die "sorry, unable to find DATADIR"
500 [[ -r "${help_tables}" ]] \ 536 [[ -r "${help_tables}" ]] \
501 && zcat "${help_tables}" > "${TMPDIR}/fill_help_tables.sql" \ 537 && zcat "${help_tables}" > "${TMPDIR}/fill_help_tables.sql" \
502 || touch "${TMPDIR}/fill_help_tables.sql" 538 || touch "${TMPDIR}/fill_help_tables.sql"
503 help_tables="${TMPDIR}/fill_help_tables.sql" 539 help_tables="${TMPDIR}/fill_help_tables.sql"
504 540
505 pushd "${TMPDIR}" 541 pushd "${TMPDIR}" &>/dev/null
506 ${ROOT}/usr/bin/mysql_install_db${MY_SUFFIX} | grep -B5 -A999 -i "ERROR" 542 ${ROOT}/usr/bin/mysql_install_db${MY_SUFFIX} | grep -B5 -A999 -i "ERROR"
507 popd 543 popd &>/dev/null
508 [[ -f ${ROOT}/${DATADIR}/mysql/user.frm ]] || die "MySQL databases not installed" 544 [[ -f ${ROOT}/${DATADIR}/mysql/user.frm ]] || die "MySQL databases not installed"
509 chown -R mysql:mysql ${ROOT}/${DATADIR} 2> /dev/null 545 chown -R mysql:mysql ${ROOT}/${DATADIR} 2> /dev/null
510 chmod 0750 ${ROOT}/${DATADIR} 2> /dev/null 546 chmod 0750 ${ROOT}/${DATADIR} 2> /dev/null
511 547
512 if mysql_version_is_at_least "4.01.03.00" ; then 548 if mysql_version_is_at_least "4.01.03.00" ; then
568 einfo "done" 604 einfo "done"
569} 605}
570 606
571mysql_pkg_postrm() { 607mysql_pkg_postrm() {
572 mysql_lib_symlinks 608 mysql_lib_symlinks
609 if [[ ${SLOT} -gt 0 ]] ; then
610 einfo "you may want to run \"eselect myqsl list\" followed by a "
611 einfo "\"eselect myqsl list\" to chose the default mysql server"
612 fi
573} 613}

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

  ViewVC Help
Powered by ViewVC 1.1.20