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

Diff of /eclass/mysql.eclass

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

Revision 1.17 Revision 1.25
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.17 2006/02/09 13:15:43 vivo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.25 2006/03/16 20:39:00 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 autotools mysql_fx
9 9
10#major, minor only in the slot 10#major, minor only in the slot
11SLOT=$(( ${MYSQL_VERSION_ID} / 10000 )) 11SLOT=$(( ${MYSQL_VERSION_ID} / 10000 ))
12 12
13# shorten the path because the socket path length must be shorter than 107 chars 13# shorten the path because the socket path length must be shorter than 107 chars
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="${P/_/-}" 19NEWP="${P/_/-}"
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-20060115.tar.bz2" 21 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
22LICENSE="GPL-2" 22LICENSE="GPL-2"
23IUSE="big-tables berkdb debug minimal perl selinux srvdir ssl static" 23IUSE="big-tables berkdb debug embedded minimal perl selinux srvdir ssl static"
24RESTRICT="primaryuri confcache" 24RESTRICT="primaryuri confcache"
25DEPEND="app-admin/eselect-mysql"
26 25
27mysql_version_is_at_least "4.01.03.00" \ 26mysql_version_is_at_least "4.01.03.00" \
28&& IUSE="${IUSE} cluster extraengine" 27&& IUSE="${IUSE} cluster extraengine"
29 28
29mysql_version_is_at_least "5.00.00.00" \
30|| IUSE="${IUSE} raid"
31
30mysql_version_is_at_least "5.00.18.00" \ 32mysql_version_is_at_least "5.00.18.00" \
31&& IUSE="${IUSE} max-idx-128" 33&& IUSE="${IUSE} max-idx-128"
32 34
33mysql_version_is_at_least "5.01.00.00" \ 35mysql_version_is_at_least "5.01.00.00" \
34&& IUSE="${IUSE} innodb" 36&& IUSE="${IUSE} innodb"
35 37
36EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_config mysql_pkg_prerm pkg_postrm 38EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_prerm pkg_postrm
37 39
38# void mysql_init_vars() 40# void mysql_init_vars()
39# 41#
40# initialize global variables 42# initialize global variables
41# 2005-11-19 <vivo at gentoo.org> 43# 2005-11-19 <vivo at gentoo.org>
131 # additional check, remove bundled zlib 133 # additional check, remove bundled zlib
132 rm -f "${S}/zlib/"*.[ch] 134 rm -f "${S}/zlib/"*.[ch]
133 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in" 135 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
134 rm -f scripts/mysqlbug 136 rm -f scripts/mysqlbug
135 137
136 # Multilib issue with zlib detection
137 mysql_version_is_at_least "5.00.15.00" \
138 && sed -i -e "s:zlib_dir/lib:zlib_dir/$(get_libdir):g" \
139 "${S}/config/ac-macros/zlib.m4"
140
141 # Make charsets install in the right place 138 # Make charsets install in the right place
142 find . -name 'Makefile.am' \ 139 find . -name 'Makefile.am' \
143 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \; 140 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
144 141
145 # Manage mysqlmanager 142 # Manage mysqlmanager
163 fi 160 fi
164 161
165 for d in ${rebuilddirlist}; do 162 for d in ${rebuilddirlist}; do
166 einfo "reconfiguring dir \"${d}\"" 163 einfo "reconfiguring dir \"${d}\""
167 pushd "${d}" &>/dev/null 164 pushd "${d}" &>/dev/null
168 for buildstep in \ 165 AT_GNUCONF_UPDATE="yes" eautoreconf
169 'libtoolize --copy --force' \
170 'aclocal --force' \
171 'autoheader --force -Wnone' \
172 'autoconf --force -Wnone' \
173 'automake --force --force-missing -Wnone' \
174 'gnuconfig_update'
175 do
176 einfo "performing ${buildstep}"
177 ${buildstep} || die "failed ${buildstep/ */} dir \"${d}\""
178 done
179 popd &>/dev/null 166 popd &>/dev/null
180 done 167 done
181 168
169 #TODO berkdb in 5.1 need to be worked on
182 if useq berkdb && ! mysql_check_version_range "5.01.00.00 to 5.01.06.99" 170 if useq berkdb && ! mysql_check_version_range "5.01.00.00 to 5.01.08.99"
183 then 171 then
184 [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh" 172 [[ -w "${bdbdir}/ltmain.sh" ]] && cp -f ltmain.sh "${bdbdir}/ltmain.sh"
185 pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null 173 pushd "${bdbdir}" && sh s_all || die "failed bdb reconfigure" &>/dev/null
186 popd &>/dev/null 174 popd &>/dev/null
187 fi 175 fi
245 233
246 if useq static ; then 234 if useq static ; then
247 myconf="${myconf} --without-raid" 235 myconf="${myconf} --without-raid"
248 ewarn "disabling raid support, has problem with static" 236 ewarn "disabling raid support, has problem with static"
249 else 237 else
238 if mysql_version_is_at_least "5.00.00.00" ; then
250 myconf="${myconf} --with-raid" 239 myconf="${myconf} --without-raid"
240 else
241 myconf="${myconf} `use_with raid`"
242 fi
251 fi 243 fi
252 244
253 if ! mysql_version_is_at_least "5.00.00.00" ; then 245 if ! mysql_version_is_at_least "5.00.00.00" ; then
254 if mysql_version_is_at_least "4.01.00.00" ; then 246 if mysql_version_is_at_least "4.01.00.00" ; then
255 myconf="${myconf} --with-charset=utf8" 247 myconf="${myconf} --with-charset=utf8"
277 || mysql_check_version_range "5.01.00.00 to 5.01.06.99" 269 || mysql_check_version_range "5.01.00.00 to 5.01.06.99"
278 then 270 then
279 ewarn "bdb berkeley-db disabled due to arch or version" 271 ewarn "bdb berkeley-db disabled due to arch or version"
280 myconf="${myconf} --without-berkeley-db" 272 myconf="${myconf} --without-berkeley-db"
281 else 273 else
274 #TODO berkdb in 5.1 need to be worked on
282 useq berkdb \ 275 useq berkdb && \
276 ! mysql_check_version_range "5.01.00.00 to 5.01.08.99" \
283 && myconf="${myconf} --with-berkeley-db=./bdb" \ 277 && myconf="${myconf} --with-berkeley-db=./bdb" \
284 || myconf="${myconf} --without-berkeley-db" 278 || myconf="${myconf} --without-berkeley-db"
285 fi 279 fi
286 280
287 if mysql_version_is_at_least "4.01.03.00" ; then 281 if mysql_version_is_at_least "4.01.03.00" ; then
289 myconf="${myconf} --with-geometry" 283 myconf="${myconf} --with-geometry"
290 myconf="${myconf} $(use_with cluster ndbcluster)" 284 myconf="${myconf} $(use_with cluster ndbcluster)"
291 fi 285 fi
292 286
293 mysql_version_is_at_least "4.01.11.00" && myconf="${myconf} `use_with big-tables`" 287 mysql_version_is_at_least "4.01.11.00" && myconf="${myconf} `use_with big-tables`"
288
289 mysql_version_is_at_least "5.01.06.00" && myconf="${myconf} --with-ndb-binlog"
290
291 if useq embedded ; then
292 #REMIND, need the privilege control enabled ?
293 myconf="${myconf} --without-embedded-privilege-control"
294 myconf="${myconf} --with-embedded-server"
295 else
296 myconf="${myconf} --without-embedded-privilege-control"
297 myconf="${myconf} --without-embedded-server"
298 fi
294 else 299 else
295 for i in ${minimal_exclude_list}; do 300 for i in ${minimal_exclude_list}; do
296 myconf="${myconf} --without-${i}" 301 myconf="${myconf} --without-${i}"
297 done 302 done
298 myconf="${myconf} --without-berkeley-db" 303 myconf="${myconf} --without-berkeley-db"
329 && useq "max-idx-128" \ 334 && useq "max-idx-128" \
330 && myconf="${myconf} --with-max-indexes=128" 335 && myconf="${myconf} --with-max-indexes=128"
331 336
332 if mysql_version_is_at_least "5.01.05.00" ; then 337 if mysql_version_is_at_least "5.01.05.00" ; then
333 myconf="${myconf} --with-row-based-replication" 338 myconf="${myconf} --with-row-based-replication"
339 fi
340
341 #TODO rechek again later, had problem with assembler enabled
342 # and some combination of use-flags with 5.1
343 if mysql_check_version_range "5.01.00.00 to 5.01.08.99" ; then
344 myconf="${myconf} --disable-assembler"
345 else
346 myconf="${myconf} --enable-assembler"
334 fi 347 fi
335 348
336 #Bug #114895,Bug #110149 349 #Bug #114895,Bug #110149
337 filter-flags "-O" "-O[01]" 350 filter-flags "-O" "-O[01]"
338 #glibc-2.3.2_pre fix; bug #16496 351 #glibc-2.3.2_pre fix; bug #16496
351 --localstatedir="${MY_LOCALSTATEDIR}" \ 364 --localstatedir="${MY_LOCALSTATEDIR}" \
352 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 365 --sharedstatedir="${MY_SHAREDSTATEDIR}" \
353 --libdir="${MY_LIBDIR}" \ 366 --libdir="${MY_LIBDIR}" \
354 --includedir="${MY_INCLUDEDIR}" \ 367 --includedir="${MY_INCLUDEDIR}" \
355 --with-low-memory \ 368 --with-low-memory \
356 --enable-assembler \
357 --enable-local-infile \ 369 --enable-local-infile \
358 --with-mysqld-user=mysql \ 370 --with-mysqld-user=mysql \
359 --with-client-ldflags=-lstdc++ \ 371 --with-client-ldflags=-lstdc++ \
360 --enable-thread-safe-client \ 372 --enable-thread-safe-client \
361 --with-comment="Gentoo Linux ${PF}" \ 373 --with-comment="Gentoo Linux ${PF}" \
362 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \ 374 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \
363 --with-zlib-dir=/usr \
364 --with-lib-ccflags="-fPIC" \ 375 --with-lib-ccflags="-fPIC" \
365 --without-readline \ 376 --without-readline \
366 --without-docs \ 377 --without-docs \
367 ${myconf} || die "bad ./configure" 378 ${myconf} || die "bad ./configure"
368 379
369 # TODO Move this before autoreconf !!! 380 # TODO Move this before autoreconf !!!
370 find . -name 'Makefile' \ 381 find . -type f -name Makefile -print0 \
371 -exec sed --in-place \ 382 | xargs -0 -n100 sed -i \
372 -e 's|^pkglibdir\s*=\s*$(libdir)/mysql|pkglibdir = $(libdir)|' \ 383 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
373 -e 's|^pkgincludedir\s*=\s*$(includedir)/mysql|pkgincludedir = $(includedir)|' \
374 {} \;
375 384
376 emake || die "compile problem" 385 emake || die "compile problem"
377} 386}
378 387
379mysql_src_install() { 388mysql_src_install() {
431 "${FILESDIR}/my.cnf-4.1-r1" \ 440 "${FILESDIR}/my.cnf-4.1-r1" \
432 > "${TMPDIR}/my.cnf.ok" 441 > "${TMPDIR}/my.cnf.ok"
433 newins "${TMPDIR}/my.cnf.ok" my.cnf 442 newins "${TMPDIR}/my.cnf.ok" my.cnf
434 443
435 insinto "/etc/conf.d" 444 insinto "/etc/conf.d"
436 newins "${FILESDIR}/mysql-slot.conf.d-r1" "mysql" 445 newins "${FILESDIR}/mysql.conf.d-r1" "mysql"
437 mysql_version_is_at_least "5.00.11.00" \ 446 mysql_version_is_at_least "5.00.11.00" \
438 && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager" 447 && newins "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager"
439 448
440 # minimal builds don't have the server 449 # minimal builds don't have the server
441 if ! useq minimal; then 450 if ! useq minimal; then
442 exeinto /etc/init.d 451 exeinto /etc/init.d
443 newexe "${FILESDIR}/mysql-slot.rc6-r3" "mysql" 452 newexe "${FILESDIR}/mysql.rc6-r3" "mysql"
444 453
445 mysql_version_is_at_least "5.00.11.00" \ 454 mysql_version_is_at_least "5.00.11.00" \
446 && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager" 455 && newexe "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager"
447 insinto /etc/logrotate.d 456 insinto /etc/logrotate.d
448 sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \ 457 sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \
449 "${FILESDIR}/logrotate-slot.mysql" \ 458 "${FILESDIR}/logrotate-slot.mysql" \
450 > "${TMPDIR}/logrotate.mysql" 459 > "${TMPDIR}/logrotate.mysql"
451 newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" 460 newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}"
489 mysql_check_version_range "5.00.16.00 to 5.00.18.99" \ 498 mysql_check_version_range "5.00.16.00 to 5.00.18.99" \
490 && cp -f \ 499 && cp -f \
491 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \ 500 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \
492 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql" 501 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql"
493 502
503 if [[ ${SLOT} -gt 0 ]] ; then
494 # MOVED HERE DUE TO BUG #121445 504 # MOVED HERE DUE TO BUG #121445
495 # create a list of files, to be used 505 # create a list of files, to be used
496 # by external utilities 506 # by external utilities
497 mkdir -p "${D}/var/lib/eselect/mysql/" 507 mkdir -p "${D}/var/lib/eselect/mysql/"
498 local filelist="${D}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist" 508 local filelist="${D}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist"
499 pushd "${D}/" &>/dev/null 509 pushd "${D}/" &>/dev/null
500 env -i find usr/bin/ usr/sbin/ usr/share/man \ 510 find usr/bin/ usr/sbin/ \
501 -type f -name "*${MY_SUFFIX}*" \ 511 -type f -name "*${MY_SUFFIX}*" \
502 -and -not -name "mysql_config${MY_SUFFIX}" \ 512 -and -not -name "mysql_config${MY_SUFFIX}" \
503 > "${filelist}" 513 > "${filelist}"
514 find usr/share/man \
515 -type f -name "*${MY_SUFFIX}*" \
516 | sed -e 's/$/.gz/' \
517 >> "${filelist}"
504 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}" 518 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}"
505 echo "${MY_LIBDIR#"/"}" >> "${filelist}" 519 echo "${MY_LIBDIR#"/"}" >> "${filelist}"
506 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}" 520 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}"
507 popd &>/dev/null 521 popd &>/dev/null
508 522 fi
523
524 # It's safer portage wis doing this in instal, but we can't
525 # if it's a slotted install
526 [[ ${SLOT} -eq 0 ]] && ROOT="${D}" mysql_lib_symlinks
509} 527}
510 528
511mysql_pkg_preinst() { 529mysql_pkg_preinst() {
512
513 ## create a list of files, to be used
514 ## by external utilities
515 ## will be used in pkg_postinst
516 #local filelist="${TMPDIR}/FILELIST"
517 #pushd "${D}/" &>/dev/null
518 # mkdir -p "${ROOT}/var/lib/eselect/mysql/"
519 # env -i find usr/bin/ usr/sbin/ usr/share/man \
520 # -type f -name "*${MY_SUFFIX}*" \
521 # -and -not -name "mysql_config${MY_SUFFIX}" \
522 # > "${filelist}"
523 # echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}"
524 # echo "${MY_LIBDIR#"/"}" >> "${filelist}"
525 # echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}"
526 #popd &>/dev/null
527 530
528 enewgroup mysql 60 || die "problem adding group mysql" 531 enewgroup mysql 60 || die "problem adding group mysql"
529 enewuser mysql 60 -1 /dev/null mysql \ 532 enewuser mysql 60 -1 /dev/null mysql \
530 || die "problem adding user mysql" 533 || die "problem adding user mysql"
531} 534}
532 535
533mysql_pkg_postinst() { 536mysql_pkg_postinst() {
534 537
535 mysql_init_vars 538 mysql_init_vars
536 mysql_lib_symlinks 539 # slotted, manage lib symlinks on the real file-system
540 # to cope with other version installed
541 [[ ${SLOT} -ne 0 ]] && mysql_lib_symlinks
537 542
538 # mind at FEATURES=collision-protect before to remove this 543 # mind at FEATURES=collision-protect before to remove this
539 [ -d "${ROOT}/var/log/mysql" ] \ 544 [ -d "${ROOT}/var/log/mysql" ] \
540 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 545 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
541 546
542 #secure the logfiles... does this bother anybody? 547 #secure the logfiles... does this bother anybody?
543 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 548 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
544 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 549 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
545 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 550 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
546 551
547 ## list of files, to be used
548 ## by external utilities
549 #mkdir -p "${ROOT}/var/lib/eselect/mysql/"
550 #cp "${TMPDIR}/FILELIST" "${ROOT}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist"
551
552 if ! useq minimal; then 552 if ! useq minimal; then
553 if [[ ${SLOT} -gt 0 ]] ; then 553 if [[ ${SLOT} -gt 0 ]] ; then
554 #if [[ -f "${ROOT}/usr/sbin/mysqld" ]] ; then
555 einfo "you may want to read:" 554 einfo "you may want to read:"
556 einfo "http://www.gentoo.org/doc/en/mysql-upgrade-slotted.xml" 555 einfo "http://www.gentoo.org/doc/en/mysql-upgrade-slotted.xml"
557 #else
558 # local tmpres="$( eselect mysql show )"
559 # # "like grep -q unset"
560 # if [[ "{$tmpres}" == "{$tmpres/unset/}" ]] ; then
561 # eselect mysql set 1
562 # else
563 # einfo "The version of mysql emerged now stils is _NOT_ the default"
564 einfo "you may want to run \"eselect myqsl list\" followed by a " 556 einfo "you may want to run \"eselect mysql list\" followed by a "
565 einfo "\"eselect myqsl set 1\" to chose the default mysql server" 557 einfo "\"eselect mysql set 1\" to choose the default mysql server"
566 # fi
567 #fi
568 fi 558 fi
569 559
570 # your friendly public service announcement... 560 # your friendly public service announcement...
571 einfo 561 einfo
572 einfo "You might want to run:" 562 einfo "You might want to run:"
573 einfo "\"emerge --config =${CATEGORY}/${PF}\"" 563 einfo "\"emerge --config =${CATEGORY}/${PF}\""
574 einfo "if this is a new install." 564 einfo "if this is a new install."
575 einfo 565 einfo
566 mysql_version_is_at_least "5.01.00.00" \
576 einfo "InnoDB is not optional as of MySQL-4.0.24, at the request of upstream." 567 || einfo "InnoDB is not optional as of MySQL-4.0.24, at the request of upstream."
577 fi 568 fi
578} 569}
579 570
580mysql_pkg_config() { 571mysql_pkg_config() {
581 mysql_init_vars 572 mysql_init_vars
684 wait %1 675 wait %1
685 einfo "done" 676 einfo "done"
686} 677}
687 678
688mysql_pkg_prerm() { 679mysql_pkg_prerm() {
680 if [[ ${SLOT} -gt 0 ]] ; then
689 # external program 681 # external program
690 eselect mysql slot_remove "${SLOT}" 682 eselect mysql slot_remove "${SLOT}"
683 fi
691} 684}
692 685
693mysql_pkg_postrm() { 686mysql_pkg_postrm() {
694 mysql_lib_symlinks 687 mysql_lib_symlinks
695 if [[ ${SLOT} -gt 0 ]] ; then 688 if [[ ${SLOT} -gt 0 ]] ; then
696 einfo "you may want to run \"eselect myqsl list\" followed by a " 689 einfo "you may want to run \"eselect mysql list\" followed by a "
697 einfo "\"eselect myqsl list\" to chose the default mysql server" 690 einfo "\"eselect mysql list\" to choose the default mysql server"
698 fi 691 fi
699} 692}

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20