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

Diff of /eclass/mysql.eclass

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

Revision 1.19 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.19 2006/02/18 10:54:23 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
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`"
294 288
295 mysql_version_is_at_least "5.01.06.00" && myconf="${myconf} --with-ndb-binlog" 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
296 else 299 else
297 for i in ${minimal_exclude_list}; do 300 for i in ${minimal_exclude_list}; do
298 myconf="${myconf} --without-${i}" 301 myconf="${myconf} --without-${i}"
299 done 302 done
300 myconf="${myconf} --without-berkeley-db" 303 myconf="${myconf} --without-berkeley-db"
331 && useq "max-idx-128" \ 334 && useq "max-idx-128" \
332 && myconf="${myconf} --with-max-indexes=128" 335 && myconf="${myconf} --with-max-indexes=128"
333 336
334 if mysql_version_is_at_least "5.01.05.00" ; then 337 if mysql_version_is_at_least "5.01.05.00" ; then
335 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"
336 fi 347 fi
337 348
338 #Bug #114895,Bug #110149 349 #Bug #114895,Bug #110149
339 filter-flags "-O" "-O[01]" 350 filter-flags "-O" "-O[01]"
340 #glibc-2.3.2_pre fix; bug #16496 351 #glibc-2.3.2_pre fix; bug #16496
353 --localstatedir="${MY_LOCALSTATEDIR}" \ 364 --localstatedir="${MY_LOCALSTATEDIR}" \
354 --sharedstatedir="${MY_SHAREDSTATEDIR}" \ 365 --sharedstatedir="${MY_SHAREDSTATEDIR}" \
355 --libdir="${MY_LIBDIR}" \ 366 --libdir="${MY_LIBDIR}" \
356 --includedir="${MY_INCLUDEDIR}" \ 367 --includedir="${MY_INCLUDEDIR}" \
357 --with-low-memory \ 368 --with-low-memory \
358 --enable-assembler \
359 --enable-local-infile \ 369 --enable-local-infile \
360 --with-mysqld-user=mysql \ 370 --with-mysqld-user=mysql \
361 --with-client-ldflags=-lstdc++ \ 371 --with-client-ldflags=-lstdc++ \
362 --enable-thread-safe-client \ 372 --enable-thread-safe-client \
363 --with-comment="Gentoo Linux ${PF}" \ 373 --with-comment="Gentoo Linux ${PF}" \
364 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \ 374 --with-unix-socket-path="/var/run/mysqld/mysqld.sock" \
365 --with-zlib-dir=/usr \
366 --with-lib-ccflags="-fPIC" \ 375 --with-lib-ccflags="-fPIC" \
367 --without-readline \ 376 --without-readline \
368 --without-docs \ 377 --without-docs \
369 ${myconf} || die "bad ./configure" 378 ${myconf} || die "bad ./configure"
370 379
371 # TODO Move this before autoreconf !!! 380 # TODO Move this before autoreconf !!!
372 find . -name 'Makefile' \ 381 find . -type f -name Makefile -print0 \
373 -exec sed --in-place \ 382 | xargs -0 -n100 sed -i \
374 -e 's|^pkglibdir\s*=\s*$(libdir)/mysql|pkglibdir = $(libdir)|' \ 383 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
375 -e 's|^pkgincludedir\s*=\s*$(includedir)/mysql|pkgincludedir = $(includedir)|' \
376 {} \;
377 384
378 emake || die "compile problem" 385 emake || die "compile problem"
379} 386}
380 387
381mysql_src_install() { 388mysql_src_install() {
433 "${FILESDIR}/my.cnf-4.1-r1" \ 440 "${FILESDIR}/my.cnf-4.1-r1" \
434 > "${TMPDIR}/my.cnf.ok" 441 > "${TMPDIR}/my.cnf.ok"
435 newins "${TMPDIR}/my.cnf.ok" my.cnf 442 newins "${TMPDIR}/my.cnf.ok" my.cnf
436 443
437 insinto "/etc/conf.d" 444 insinto "/etc/conf.d"
438 newins "${FILESDIR}/mysql-slot.conf.d-r1" "mysql" 445 newins "${FILESDIR}/mysql.conf.d-r1" "mysql"
439 mysql_version_is_at_least "5.00.11.00" \ 446 mysql_version_is_at_least "5.00.11.00" \
440 && newins "${FILESDIR}/mysqlmanager-slot.conf.d" "mysqlmanager" 447 && newins "${FILESDIR}/mysqlmanager.conf.d" "mysqlmanager"
441 448
442 # minimal builds don't have the server 449 # minimal builds don't have the server
443 if ! useq minimal; then 450 if ! useq minimal; then
444 exeinto /etc/init.d 451 exeinto /etc/init.d
445 newexe "${FILESDIR}/mysql-slot.rc6-r3" "mysql" 452 newexe "${FILESDIR}/mysql.rc6-r3" "mysql"
446 453
447 mysql_version_is_at_least "5.00.11.00" \ 454 mysql_version_is_at_least "5.00.11.00" \
448 && newexe "${FILESDIR}/mysqlmanager-slot.rc6" "mysqlmanager" 455 && newexe "${FILESDIR}/mysqlmanager.rc6" "mysqlmanager"
449 insinto /etc/logrotate.d 456 insinto /etc/logrotate.d
450 sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \ 457 sed -e "s!___MY_SUFFIX___!${MY_SUFFIX}!g" \
451 "${FILESDIR}/logrotate-slot.mysql" \ 458 "${FILESDIR}/logrotate-slot.mysql" \
452 > "${TMPDIR}/logrotate.mysql" 459 > "${TMPDIR}/logrotate.mysql"
453 newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}" 460 newins "${TMPDIR}/logrotate.mysql" "mysql${MY_SUFFIX}"
491 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" \
492 && cp -f \ 499 && cp -f \
493 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \ 500 "${WORKDIR}/mysql-extras/fill_help_tables.sql-5.0" \
494 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql" 501 "${D}/usr/share/mysql${MY_SUFFIX}/fill_help_tables.sql"
495 502
503 if [[ ${SLOT} -gt 0 ]] ; then
496 # MOVED HERE DUE TO BUG #121445 504 # MOVED HERE DUE TO BUG #121445
497 # create a list of files, to be used 505 # create a list of files, to be used
498 # by external utilities 506 # by external utilities
499 mkdir -p "${D}/var/lib/eselect/mysql/" 507 mkdir -p "${D}/var/lib/eselect/mysql/"
500 local filelist="${D}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist" 508 local filelist="${D}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist"
501 pushd "${D}/" &>/dev/null 509 pushd "${D}/" &>/dev/null
502 env -i find usr/bin/ usr/sbin/ usr/share/man \ 510 find usr/bin/ usr/sbin/ \
503 -type f -name "*${MY_SUFFIX}*" \ 511 -type f -name "*${MY_SUFFIX}*" \
504 -and -not -name "mysql_config${MY_SUFFIX}" \ 512 -and -not -name "mysql_config${MY_SUFFIX}" \
505 > "${filelist}" 513 > "${filelist}"
514 find usr/share/man \
515 -type f -name "*${MY_SUFFIX}*" \
516 | sed -e 's/$/.gz/' \
517 >> "${filelist}"
506 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}" 518 echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}"
507 echo "${MY_LIBDIR#"/"}" >> "${filelist}" 519 echo "${MY_LIBDIR#"/"}" >> "${filelist}"
508 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}" 520 echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}"
509 popd &>/dev/null 521 popd &>/dev/null
510 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
511} 527}
512 528
513mysql_pkg_preinst() { 529mysql_pkg_preinst() {
514
515 ## create a list of files, to be used
516 ## by external utilities
517 ## will be used in pkg_postinst
518 #local filelist="${TMPDIR}/FILELIST"
519 #pushd "${D}/" &>/dev/null
520 # mkdir -p "${ROOT}/var/lib/eselect/mysql/"
521 # env -i find usr/bin/ usr/sbin/ usr/share/man \
522 # -type f -name "*${MY_SUFFIX}*" \
523 # -and -not -name "mysql_config${MY_SUFFIX}" \
524 # > "${filelist}"
525 # echo "${MY_SYSCONFDIR#"/"}" >> "${filelist}"
526 # echo "${MY_LIBDIR#"/"}" >> "${filelist}"
527 # echo "${MY_SHAREDSTATEDIR#"/"}" >> "${filelist}"
528 #popd &>/dev/null
529 530
530 enewgroup mysql 60 || die "problem adding group mysql" 531 enewgroup mysql 60 || die "problem adding group mysql"
531 enewuser mysql 60 -1 /dev/null mysql \ 532 enewuser mysql 60 -1 /dev/null mysql \
532 || die "problem adding user mysql" 533 || die "problem adding user mysql"
533} 534}
534 535
535mysql_pkg_postinst() { 536mysql_pkg_postinst() {
536 537
537 mysql_init_vars 538 mysql_init_vars
538 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
539 542
540 # mind at FEATURES=collision-protect before to remove this 543 # mind at FEATURES=collision-protect before to remove this
541 [ -d "${ROOT}/var/log/mysql" ] \ 544 [ -d "${ROOT}/var/log/mysql" ] \
542 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" 545 || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
543 546
544 #secure the logfiles... does this bother anybody? 547 #secure the logfiles... does this bother anybody?
545 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} 548 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
546 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* 549 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
547 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* 550 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
548 551
549 ## list of files, to be used
550 ## by external utilities
551 #mkdir -p "${ROOT}/var/lib/eselect/mysql/"
552 #cp "${TMPDIR}/FILELIST" "${ROOT}/var/lib/eselect/mysql/mysql${MY_SUFFIX}.filelist"
553
554 if ! useq minimal; then 552 if ! useq minimal; then
555 if [[ ${SLOT} -gt 0 ]] ; then 553 if [[ ${SLOT} -gt 0 ]] ; then
556 #if [[ -f "${ROOT}/usr/sbin/mysqld" ]] ; then
557 einfo "you may want to read:" 554 einfo "you may want to read:"
558 einfo "http://www.gentoo.org/doc/en/mysql-upgrade-slotted.xml" 555 einfo "http://www.gentoo.org/doc/en/mysql-upgrade-slotted.xml"
559 #else
560 # local tmpres="$( eselect mysql show )"
561 # # "like grep -q unset"
562 # if [[ "{$tmpres}" == "{$tmpres/unset/}" ]] ; then
563 # eselect mysql set 1
564 # else
565 # einfo "The version of mysql emerged now stils is _NOT_ the default"
566 einfo "you may want to run \"eselect mysql list\" followed by a " 556 einfo "you may want to run \"eselect mysql list\" followed by a "
567 einfo "\"eselect mysql set 1\" to choose the default mysql server" 557 einfo "\"eselect mysql set 1\" to choose the default mysql server"
568 # fi
569 #fi
570 fi 558 fi
571 559
572 # your friendly public service announcement... 560 # your friendly public service announcement...
573 einfo 561 einfo
574 einfo "You might want to run:" 562 einfo "You might want to run:"
575 einfo "\"emerge --config =${CATEGORY}/${PF}\"" 563 einfo "\"emerge --config =${CATEGORY}/${PF}\""
576 einfo "if this is a new install." 564 einfo "if this is a new install."
577 einfo 565 einfo
566 mysql_version_is_at_least "5.01.00.00" \
578 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."
579 fi 568 fi
580} 569}
581 570
582mysql_pkg_config() { 571mysql_pkg_config() {
583 mysql_init_vars 572 mysql_init_vars
686 wait %1 675 wait %1
687 einfo "done" 676 einfo "done"
688} 677}
689 678
690mysql_pkg_prerm() { 679mysql_pkg_prerm() {
680 if [[ ${SLOT} -gt 0 ]] ; then
691 # external program 681 # external program
692 eselect mysql slot_remove "${SLOT}" 682 eselect mysql slot_remove "${SLOT}"
683 fi
693} 684}
694 685
695mysql_pkg_postrm() { 686mysql_pkg_postrm() {
696 mysql_lib_symlinks 687 mysql_lib_symlinks
697 if [[ ${SLOT} -gt 0 ]] ; then 688 if [[ ${SLOT} -gt 0 ]] ; then

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

  ViewVC Help
Powered by ViewVC 1.1.20