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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.71 - (show annotations) (download)
Tue Mar 6 15:55:55 2007 UTC (7 years, 6 months ago) by chtekk
Branch: MAIN
Changes since 1.70: +6 -5 lines
Fix libtool bug in the right place.

1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.70 2007/01/12 23:33:19 chtekk Exp $
4
5 # Author: Francesco Riosa (Retired) <vivo@gentoo.org>
6 # Maintainer: Luca Longinotti <chtekk@gentoo.org>
7
8 # Both MYSQL_VERSION_ID and MYSQL_PATCHSET_REV must be set in the ebuild too!
9 # Note that MYSQL_VERSION_ID must be empty!
10
11 WANT_AUTOCONF="latest"
12 WANT_AUTOMAKE="latest"
13
14 inherit eutils flag-o-matic gnuconfig autotools mysql_fx
15
16 # Shorten the path because the socket path length must be shorter than 107 chars
17 # and we will run a mysql server during test phase
18 S="${WORKDIR}/mysql"
19
20 [[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20070108"
21
22 if [[ ${PR#r} -lt 60 ]] ; then
23 IS_BITKEEPER=0
24 elif [[ ${PR#r} -lt 90 ]] ; then
25 IS_BITKEEPER=60
26 else
27 IS_BITKEEPER=90
28 fi
29
30 # MYSQL_VERSION_ID will be:
31 # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
32 # This is an important part, because many of the choices the MySQL ebuild will do
33 # depend on this variable.
34 # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
35
36 MYSQL_VERSION_ID=""
37 tpv=( ${PV//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
38 for vatom in 0 1 2 3 ; do
39 # pad to length 2
40 tpv[${vatom}]="00${tpv[${vatom}]}"
41 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
42 done
43 # strip leading "0" (otherwise it's considered an octal number by BASH)
44 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
45
46 # Be warned, *DEPEND are version-dependant
47 DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d )
48 userland_GNU? ( sys-process/procps )
49 >=sys-apps/sed-4
50 >=sys-apps/texinfo-4.7-r1
51 >=sys-libs/readline-4.1
52 >=sys-libs/zlib-1.2.3"
53
54 # Having different flavours at the same time is not a good idea
55 for i in "" "-community" ; do
56 [[ "${i}" == ${PN#mysql} ]] ||
57 DEPEND="${DEPEND} !dev-db/mysql${i}"
58 done
59
60 mysql_version_is_at_least "5.1" \
61 || DEPEND="${DEPEND} berkdb? ( sys-apps/ed )"
62
63 mysql_version_is_at_least "5.1.12" \
64 && DEPEND="${DEPEND} innodb? ( >=dev-util/cmake-2.4.3 )"
65
66 # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
67 PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
68
69 # BitKeeper dependency, compile-time only
70 [[ ${IS_BITKEEPER} -eq 90 ]] && DEPEND="${DEPEND} dev-util/bk_client"
71
72 # Define correct SRC_URIs
73 SRC_URI="${SERVER_URI}
74 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
75 mysql_version_is_at_least "5.1.12" \
76 && [[ -n "${PBXT_VERSION}" ]] \
77 && SRC_URI="${SRC_URI} pbxt? ( mirror://sourceforge/pbxt/pbxt-${PBXT_VERSION}.tar.gz )"
78
79 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
80 HOMEPAGE="http://www.mysql.com/"
81 LICENSE="GPL-2"
82 SLOT="0"
83 IUSE="big-tables debug embedded minimal perl selinux ssl static"
84 RESTRICT="confcache"
85
86 mysql_version_is_at_least "4.1" \
87 && IUSE="${IUSE} latin1"
88
89 mysql_version_is_at_least "4.1.3" \
90 && IUSE="${IUSE} cluster extraengine"
91
92 mysql_version_is_at_least "5.0" \
93 || IUSE="${IUSE} raid"
94
95 mysql_version_is_at_least "5.0.18" \
96 && IUSE="${IUSE} max-idx-128"
97
98 mysql_version_is_at_least "5.1" \
99 && IUSE="${IUSE} innodb"
100
101 mysql_version_is_at_least "5.1" \
102 || IUSE="${IUSE} berkdb"
103
104 mysql_version_is_at_least "5.1.12" \
105 && IUSE="${IUSE} pbxt"
106
107 RDEPEND="${DEPEND}
108 !minimal? ( dev-db/mysql-init-scripts )
109 selinux? ( sec-policy/selinux-mysql )"
110
111 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst \
112 pkg_postinst pkg_config pkg_postrm
113
114 #
115 # HELPER FUNCTIONS:
116 #
117
118 bitkeeper_fetch() {
119 local reposuf
120 if [[ -z "${1}" ]] ; then
121 local tpv
122 tpv=( ${PV//[-._]/ } )
123 reposuf="mysql-${tpv[0]}.${tpv[1]}"
124 else
125 reposuf="${1}"
126 fi
127 einfo "Using '${reposuf}' repository."
128 local repo_uri="bk://mysql.bkbits.net/${reposuf}"
129 ## -- ebk_store_dir: bitkeeper sources store directory
130 local ebk_store_dir="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bk-src"
131 ## -- ebk_fetch_cmd: bitkeeper fetch command
132 # always fetch the latest revision, use -r<revision> if a specified revision is wanted
133 # hint: does not work
134 local ebk_fetch_cmd="sfioball"
135 ## -- ebk_update_cmd: bitkeeper update command
136 local ebk_update_cmd="update"
137
138 # addread "/etc/bitkeeper"
139 addwrite "${ebk_store_dir}"
140
141 if [[ ! -d "${ebk_store_dir}" ]] ; then
142 debug-print "${FUNCNAME}: initial checkout, creating bitkeeper directory ..."
143 mkdir -p "${ebk_store_dir}" || die "BK: couldn't mkdir ${ebk_store_dir}"
144 fi
145
146 pushd "${ebk_store_dir}" || die "BK: couldn't chdir to ${ebk_store_dir}"
147
148 local wc_path=${reposuf}
149
150 if [[ ! -d "${wc_path}" ]] ; then
151 local options="-r+"
152
153 # first checkout
154 einfo "bitkeeper checkout start -->"
155 einfo " repository: ${repo_uri}"
156
157 ${ebk_fetch_cmd} ${options} "${repo_uri}" "${wc_path}" \
158 || die "BK: couldn't fetch from ${repo_uri}"
159 else
160 if [[ ! -d "${wc_path}/BK" ]] ; then
161 popd
162 die "Looks like ${wc_path} is not a bitkeeper path"
163 fi
164
165 # update working copy
166 einfo "bitkeeper update start -->"
167 einfo " repository: ${repo_uri}"
168
169 ${ebk_update_cmd} "${repo_uri}" "${wc_path}" \
170 || die "BK: couldn't update from ${repo_uri} to ${wc_path}"
171 fi
172
173 einfo " working copy: ${wc_path}"
174 cd "${wc_path}"
175 rsync -rlpgo --exclude="BK/" . "${S}" || die "BK: couldn't export to ${S}"
176
177 echo
178 popd
179 }
180
181 mysql_disable_test() {
182 local testname="${1}" ; shift
183 local reason="${@}"
184 local mysql_disable_file="${S}/mysql-test/t/disabled.def"
185 echo ${testname} : ${reason} >> "${mysql_disable_file}"
186 ewarn "test '${testname}' disabled: '${reason}'"
187 }
188
189 # void mysql_init_vars()
190 #
191 # Initialize global variables
192 # 2005-11-19 <vivo@gentoo.org>
193
194 mysql_init_vars() {
195 MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="/usr/share/mysql"}
196 MY_SYSCONFDIR=${MY_SYSCONFDIR="/etc/mysql"}
197 MY_LIBDIR=${MY_LIBDIR="/usr/$(get_libdir)/mysql"}
198 MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="/var/lib/mysql"}
199 MY_LOGDIR=${MY_LOGDIR="/var/log/mysql"}
200 MY_INCLUDEDIR=${MY_INCLUDEDIR="/usr/include/mysql"}
201
202 if [[ -z "${DATADIR}" ]] ; then
203 DATADIR=""
204 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
205 DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
206 | sed -ne '/datadir/s|^--datadir=||p' \
207 | tail -n1`
208 if [[ -z "${DATADIR}" ]] ; then
209 DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
210 | sed -e 's/.*=\s*//'`
211 fi
212 fi
213 if [[ -z "${DATADIR}" ]] ; then
214 DATADIR="${MY_LOCALSTATEDIR}"
215 einfo "Using default DATADIR"
216 fi
217 elog "MySQL DATADIR is ${DATADIR}"
218
219 if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
220 if [[ -e "${DATADIR}" ]] ; then
221 elog "Previous datadir found, it's YOUR job to change"
222 elog "ownership and take care of it"
223 PREVIOUS_DATADIR="yes"
224 else
225 PREVIOUS_DATADIR="no"
226 fi
227 export PREVIOUS_DATADIR
228 fi
229 fi
230
231 MY_SOURCEDIR=${SERVER_URI##*/}
232 MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
233
234 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
235 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
236 export MY_INCLUDEDIR DATADIR MY_SOURCEDIR
237 }
238
239 configure_minimal() {
240 # These are things we exclude from a minimal build, please
241 # note that the server actually does get built and installed,
242 # but we then delete it before packaging.
243 local minimal_exclude_list="server embedded-server extra-tools innodb bench berkeley-db row-based-replication"
244
245 for i in ${minimal_exclude_list} ; do
246 myconf="${myconf} --without-${i}"
247 done
248 myconf="${myconf} --with-extra-charsets=none"
249 myconf="${myconf} --enable-local-infile"
250
251 if use static ; then
252 myconf="${myconf} --with-client-ldflags=-all-static"
253 myconf="${myconf} --disable-shared"
254 else
255 myconf="${myconf} --enable-shared --enable-static"
256 fi
257
258 if mysql_version_is_at_least "4.1" && ! use latin1 ; then
259 myconf="${myconf} --with-charset=utf8"
260 myconf="${myconf} --with-collation=utf8_general_ci"
261 else
262 myconf="${myconf} --with-charset=latin1"
263 myconf="${myconf} --with-collation=latin1_swedish_ci"
264 fi
265 }
266
267 configure_common() {
268 myconf="${myconf} $(use_with big-tables)"
269 myconf="${myconf} --enable-local-infile"
270 myconf="${myconf} --with-extra-charsets=all"
271 myconf="${myconf} --with-mysqld-user=mysql"
272 myconf="${myconf} --with-server"
273 myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock"
274 myconf="${myconf} --without-libwrap"
275
276 if use static ; then
277 myconf="${myconf} --with-mysqld-ldflags=-all-static"
278 myconf="${myconf} --with-client-ldflags=-all-static"
279 myconf="${myconf} --disable-shared"
280 else
281 myconf="${myconf} --enable-shared --enable-static"
282 fi
283
284 if use debug ; then
285 myconf="${myconf} --with-debug=full"
286 else
287 myconf="${myconf} --without-debug"
288 mysql_version_is_at_least "4.1.3" \
289 && use cluster \
290 && myconf="${myconf} --without-ndb-debug"
291 fi
292
293 if mysql_version_is_at_least "4.1" && ! use latin1 ; then
294 myconf="${myconf} --with-charset=utf8"
295 myconf="${myconf} --with-collation=utf8_general_ci"
296 else
297 myconf="${myconf} --with-charset=latin1"
298 myconf="${myconf} --with-collation=latin1_swedish_ci"
299 fi
300
301 if use embedded ; then
302 myconf="${myconf} --with-embedded-privilege-control"
303 myconf="${myconf} --with-embedded-server"
304 else
305 myconf="${myconf} --without-embedded-privilege-control"
306 myconf="${myconf} --without-embedded-server"
307 fi
308
309 }
310
311 configure_40_41_50() {
312 myconf="${myconf} $(use_with perl bench)"
313 myconf="${myconf} --enable-assembler"
314 myconf="${myconf} --with-extra-tools"
315 myconf="${myconf} --with-innodb"
316 myconf="${myconf} --without-readline"
317 mysql_version_is_at_least "5.0" || myconf="${myconf} $(use_with raid)"
318
319 # --with-vio is not needed anymore, it's on by default and
320 # has been removed from configure
321 if use ssl ; then
322 mysql_version_is_at_least "5.0.4" || myconf="${myconf} --with-vio"
323 fi
324
325 if mysql_version_is_at_least "5.1.11" ; then
326 myconf="${myconf} $(use_with ssl)"
327 else
328 myconf="${myconf} $(use_with ssl openssl)"
329 fi
330
331 # The following fix is due to a bug with bdb on SPARC's. See:
332 # http://www.geocrawler.com/mail/msg.php3?msg_id=4754814&list=8
333 # It comes down to non-64-bit safety problems.
334 if use alpha || use amd64 || use hppa || use mips || use sparc ; then
335 elog "Berkeley DB support was disabled due to incompatible arch"
336 myconf="${myconf} --without-berkeley-db"
337 else
338 if use berkdb ; then
339 myconf="${myconf} --with-berkeley-db=./bdb"
340 else
341 myconf="${myconf} --without-berkeley-db"
342 fi
343 fi
344
345 if mysql_version_is_at_least "4.1.3" ; then
346 myconf="${myconf} --with-geometry"
347 myconf="${myconf} $(use_with cluster ndbcluster)"
348 fi
349
350 if mysql_version_is_at_least "4.1.3" && use extraengine ; then
351 # http://dev.mysql.com/doc/mysql/en/archive-storage-engine.html
352 myconf="${myconf} --with-archive-storage-engine"
353
354 # http://dev.mysql.com/doc/mysql/en/csv-storage-engine.html
355 myconf="${myconf} --with-csv-storage-engine"
356
357 # http://dev.mysql.com/doc/mysql/en/blackhole-storage-engine.html
358 myconf="${myconf} --with-blackhole-storage-engine"
359
360 # http://dev.mysql.com/doc/mysql/en/federated-storage-engine.html
361 # http://dev.mysql.com/doc/mysql/en/federated-description.html
362 # http://dev.mysql.com/doc/mysql/en/federated-limitations.html
363 if mysql_version_is_at_least "5.0.3" ; then
364 elog "Before using the Federated storage engine, please be sure to read"
365 elog "http://dev.mysql.com/doc/mysql/en/federated-limitations.html"
366 myconf="${myconf} --with-federated-storage-engine"
367 fi
368 fi
369
370 mysql_version_is_at_least "5.0.18" \
371 && use max-idx-128 \
372 && myconf="${myconf} --with-max-indexes=128"
373 }
374
375 configure_51() {
376 # TODO: !!!! readd --without-readline
377 # the failure depend upon config/ac-macros/readline.m4 checking into
378 # readline.h instead of history.h
379 myconf="${myconf} $(use_with ssl)"
380 myconf="${myconf} --enable-assembler"
381 myconf="${myconf} --with-geometry"
382 myconf="${myconf} --with-readline"
383 myconf="${myconf} --with-row-based-replication"
384 myconf="${myconf} --with-zlib=/usr/$(get_libdir)"
385 myconf="${myconf} --without-pstack"
386 use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
387
388 # 5.1 introduces a new way to manage storage engines (plugins)
389 # like configuration=none
390 local plugins="csv,myisam,myisammrg,heap"
391 if use extraengine ; then
392 # like configuration=max-no-ndb, archive and example removed in 5.1.11
393 plugins="${plugins},archive,blackhole,example,federated,partition"
394
395 elog "Before using the Federated storage engine, please be sure to read"
396 elog "http://dev.mysql.com/doc/refman/5.1/en/federated-limitations.html"
397 fi
398
399 if use innodb ; then
400 plugins="${plugins},innobase"
401 fi
402
403 # like configuration=max-no-ndb
404 if use cluster ; then
405 plugins="${plugins},ndbcluster"
406 myconf="${myconf} --with-ndb-binlog"
407 fi
408
409 if mysql_version_is_at_least "5.2" ; then
410 plugins="${plugins},falcon"
411 fi
412
413 myconf="${myconf} --with-plugins=${plugins}"
414 }
415
416 pbxt_src_compile() {
417 mysql_init_vars
418
419 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
420
421 einfo "Reconfiguring dir '${PWD}'"
422 AT_GNUCONF_UPDATE="yes" eautoreconf
423
424 local myconf=""
425 myconf="${myconf} --with-mysql=${S} --libdir=${D}/${MY_LIBDIR}"
426 use debug && myconf="${myconf} --with-debug=full"
427 # TODO: is it safe/needed to use econf here ?
428 ./configure ${myconf} || die "Problem configuring PBXT storage engine"
429 # TODO: is it safe/needed to use emake here ?
430 make || die "Problem making PBXT storage engine (${myconf})"
431
432 popd
433 # TODO: modify test suite for PBXT
434 }
435
436 pbxt_src_install() {
437 pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
438 make install || die "Failed to install PBXT"
439 popd
440 }
441
442 #
443 # EBUILD FUNCTIONS
444 #
445
446 mysql_pkg_setup() {
447 enewgroup mysql 60 || die "problem adding 'mysql' group"
448 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
449
450 # Check for USE flag problems in pkg_setup
451 if use static && use ssl ; then
452 eerror "MySQL does not support being built statically with SSL support enabled!"
453 die "MySQL does not support being built statically with SSL support enabled!"
454 fi
455
456 if ! mysql_version_is_at_least "5.0" \
457 && use raid \
458 && use static ; then
459 eerror "USE flags 'raid' and 'static' conflict, you cannot build MySQL statically"
460 eerror "with RAID support enabled."
461 die "USE flags 'raid' and 'static' conflict!"
462 fi
463
464 if mysql_version_is_at_least "4.1.3" \
465 && ( use cluster || use extraengine ) \
466 && use minimal ; then
467 eerror "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
468 die "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
469 fi
470
471 mysql_check_version_range "4.0 to 5.0.99.99" \
472 && use berkdb \
473 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
474 }
475
476 mysql_src_unpack() {
477 # Initialize the proper variables first
478 mysql_init_vars
479
480 unpack ${A}
481 if [[ ${IS_BITKEEPER} -eq 90 ]] ; then
482 if mysql_check_version_range "5.1 to 5.1.99" ; then
483 bitkeeper_fetch "mysql-5.1-ndb"
484 elif mysql_check_version_range "5.2 to 5.2.99" ; then
485 bitkeeper_fetch "mysql-5.2-falcon"
486 else
487 bitkeeper_fetch
488 fi
489 cd "${S}"
490 einfo "Running upstream autorun over BK sources ..."
491 BUILD/autorun.sh
492 else
493 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
494 cd "${S}"
495 fi
496
497 # Apply the patches for this MySQL version
498 EPATCH_SUFFIX="patch"
499 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
500 mysql_mv_patches
501 epatch
502
503 # Additional checks, remove bundled zlib
504 rm -f "${S}/zlib/"*.[ch]
505 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
506 rm -f "scripts/mysqlbug"
507
508 # Make charsets install in the right place
509 find . -name 'Makefile.am' \
510 -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
511
512 if mysql_version_is_at_least "4.1" ; then
513 # Remove what needs to be recreated, so we're sure it's actually done
514 find . -name Makefile \
515 -o -name Makefile.in \
516 -o -name configure \
517 -exec rm -f {} \;
518 rm -f "ltmain.sh"
519 rm -f "scripts/mysqlbug"
520 fi
521
522 local rebuilddirlist d
523
524 if mysql_version_is_at_least "5.1.12" ; then
525 rebuilddirlist="."
526 # TODO: check this with a cmake expert
527 use innodb \
528 && cmake \
529 -DCMAKE_C_COMPILER=$(which $(tc-getCC)) \
530 -DCMAKE_CXX_COMPILER=$(which $(tc-getCC)) \
531 "storage/innobase"
532 else
533 rebuilddirlist=". innobase"
534 fi
535
536 for d in ${rebuilddirlist} ; do
537 einfo "Reconfiguring dir '${d}'"
538 pushd "${d}" &>/dev/null
539 AT_GNUCONF_UPDATE="yes" eautoreconf
540 popd &>/dev/null
541 done
542
543 if mysql_check_version_range "4.1 to 5.0.99.99" \
544 && use berkdb ; then
545 [[ -w "bdb/dist/ltmain.sh" ]] && cp -f "ltmain.sh" "bdb/dist/ltmain.sh"
546 cp -f "/usr/share/aclocal/libtool.m4" "bdb/dist/aclocal/libtool.ac" \
547 || die "Could not copy libtool.m4 to bdb/dist/"
548 pushd "bdb/dist" &>/dev/null
549 sh s_all \
550 || die "Failed bdb reconfigure"
551 popd &>/dev/null
552 fi
553 }
554
555 mysql_src_compile() {
556 # Make sure the vars are correctly initialized
557 mysql_init_vars
558
559 # $myconf is modified by the configure_* functions
560 local myconf=""
561
562 if use minimal ; then
563 configure_minimal
564 else
565 configure_common
566 if mysql_version_is_at_least "5.1.10" ; then
567 configure_51
568 else
569 configure_40_41_50
570 fi
571 fi
572
573 # Bug #114895, bug #110149
574 filter-flags "-O" "-O[01]"
575
576 # glib-2.3.2_pre fix, bug #16496
577 append-flags "-DHAVE_ERRNO_AS_DEFINE=1"
578
579 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
580 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
581 mysql_version_is_at_least "5.0" \
582 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
583 export CXXFLAGS
584
585 econf \
586 --libexecdir="/usr/sbin" \
587 --sysconfdir="${MY_SYSCONFDIR}" \
588 --localstatedir="${MY_LOCALSTATEDIR}" \
589 --sharedstatedir="${MY_SHAREDSTATEDIR}" \
590 --libdir="${MY_LIBDIR}" \
591 --includedir="${MY_INCLUDEDIR}" \
592 --with-low-memory \
593 --with-client-ldflags=-lstdc++ \
594 --enable-thread-safe-client \
595 --with-comment="Gentoo Linux ${PF}" \
596 --without-docs \
597 ${myconf} || die "econf failed"
598
599 # TODO: Move this before autoreconf !!!
600 find . -type f -name Makefile -print0 \
601 | xargs -0 -n100 sed -i \
602 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
603
604 emake || die "emake failed"
605
606 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile
607 }
608
609 mysql_src_install() {
610 # Make sure the vars are correctly initialized
611 mysql_init_vars
612
613 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed"
614
615 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_install
616
617 insinto "${MY_INCLUDEDIR}"
618 doins "${MY_INCLUDEDIR}"/my_{config,dir}.h
619
620 # Convenience links
621 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
622 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
623 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
624
625 # Various junk (my-*.cnf moved elsewhere)
626 rm -Rf "${D}/usr/share/info"
627 for removeme in "mysql-log-rotate" mysql.server* \
628 binary-configure* my-*.cnf mi_test_all*
629 do
630 rm -f "${D}"/usr/share/mysql/${removeme}
631 done
632
633 # Clean up stuff for a minimal build
634 if use minimal ; then
635 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
636 rm -f "${D}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
637 rm -f "${D}/usr/sbin/mysqld"
638 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
639 fi
640
641 # Configuration stuff
642 if mysql_version_is_at_least "4.1" ; then
643 mysql_mycnf_version="4.1"
644 else
645 mysql_mycnf_version="4.0"
646 fi
647 insinto "${MY_SYSCONFDIR}"
648 doins scripts/mysqlaccess.conf
649 sed -e "s!@DATADIR@!${DATADIR}!g" \
650 "${FILESDIR}/my.cnf-${mysql_mycnf_version}" \
651 > "${TMPDIR}/my.cnf.ok"
652 if mysql_version_is_at_least "4.1" && use latin1 ; then
653 sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok"
654 fi
655 newins "${TMPDIR}/my.cnf.ok" my.cnf
656
657 # Minimal builds don't have the MySQL server
658 if ! use minimal ; then
659 # Empty directories ...
660 diropts "-m0750"
661 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
662 dodir "${DATADIR}"
663 keepdir "${DATADIR}"
664 chown -R mysql:mysql "${D}/${DATADIR}"
665 fi
666
667 diropts "-m0755"
668 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
669 dodir "${folder}"
670 keepdir "${folder}"
671 chown -R mysql:mysql "${D}/${folder}"
672 done
673 fi
674
675 # Docs
676 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE
677
678 # Minimal builds don't have the MySQL server
679 if ! use minimal ; then
680 docinto "support-files"
681 for script in \
682 support-files/my-*.cnf \
683 support-files/magic \
684 support-files/ndb-config-2-node.ini
685 do
686 dodoc "${script}"
687 done
688
689 docinto "scripts"
690 for script in scripts/mysql* ; do
691 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
692 done
693 fi
694
695 mysql_lib_symlinks "${D}"
696 }
697
698 mysql_pkg_preinst() {
699 enewgroup mysql 60 || die "problem adding 'mysql' group"
700 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
701 }
702
703 mysql_pkg_postinst() {
704 # Make sure the vars are correctly initialized
705 mysql_init_vars
706
707 # Check FEATURES="collision-protect" before removing this
708 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
709
710 # Secure the logfiles
711 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
712 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
713 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
714
715 # Minimal builds don't have the MySQL server
716 if ! use minimal ; then
717 docinto "support-files"
718 for script in \
719 support-files/my-*.cnf \
720 support-files/magic \
721 support-files/ndb-config-2-node.ini
722 do
723 dodoc "${script}"
724 done
725
726 docinto "scripts"
727 for script in scripts/mysql* ; do
728 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
729 done
730
731 einfo
732 elog "You might want to run:"
733 elog "\"emerge --config =${CATEGORY}/${PF}\""
734 elog "if this is a new install."
735 einfo
736 fi
737
738 if mysql_version_is_at_least "5.1.12" && use pbxt ; then
739 # TODO: explain it better
740 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';"
741 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;"
742 elog "if, after that, you cannot start the MySQL server,"
743 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
744 elog "use the MySQL upgrade script to restore the table"
745 elog "or execute the following SQL command:"
746 elog " CREATE TABLE IF NOT EXISTS plugin ("
747 elog " name char(64) binary DEFAULT '' NOT NULL,"
748 elog " dl char(128) DEFAULT '' NOT NULL,"
749 elog " PRIMARY KEY (name)"
750 elog " ) CHARACTER SET utf8 COLLATE utf8_bin;"
751 fi
752
753 mysql_check_version_range "4.0 to 5.0.99.99" \
754 && use berkdb \
755 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
756 }
757
758 mysql_pkg_config() {
759 # Make sure the vars are correctly initialized
760 mysql_init_vars
761
762 [[ -z "${DATADIR}" ]] && die "Sorry, unable to find DATADIR"
763
764 if built_with_use ${CATEGORY}/${PN} minimal ; then
765 die "Minimal builds do NOT include the MySQL server"
766 fi
767
768 local pwd1="a"
769 local pwd2="b"
770 local maxtry=5
771
772 if [[ -d "${ROOT}/${DATADIR}/mysql" ]] ; then
773 ewarn "You have already a MySQL database in place."
774 ewarn "(${ROOT}/${DATADIR}/*)"
775 ewarn "Please rename or delete it if you wish to replace it."
776 die "MySQL database already exists!"
777 fi
778
779 einfo "Creating the mysql database and setting proper"
780 einfo "permissions on it ..."
781
782 einfo "Insert a password for the mysql 'root' user"
783 ewarn "Avoid [\"'\\_%] characters in the password"
784 read -rsp " >" pwd1 ; echo
785
786 einfo "Retype the password"
787 read -rsp " >" pwd2 ; echo
788
789 if [[ "x$pwd1" != "x$pwd2" ]] ; then
790 die "Passwords are not the same"
791 fi
792
793 local options=""
794 local sqltmp="$(emktemp)"
795
796 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
797 [[ -r "${help_tables}" ]] \
798 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
799 || touch "${TMPDIR}/fill_help_tables.sql"
800 help_tables="${TMPDIR}/fill_help_tables.sql"
801
802 pushd "${TMPDIR}" &>/dev/null
803 "${ROOT}/usr/bin/mysql_install_db" | grep -B5 -A999 -i "ERROR"
804 popd &>/dev/null
805 [[ -f "${ROOT}/${DATADIR}/mysql/user.frm" ]] \
806 || die "MySQL databases not installed"
807 chown -R mysql:mysql "${ROOT}/${DATADIR}" 2> /dev/null
808 chmod 0750 "${ROOT}/${DATADIR}" 2> /dev/null
809
810 if mysql_version_is_at_least "4.1.3" ; then
811 options="--skip-ndbcluster"
812
813 # Filling timezones, see
814 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
815 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
816
817 if [[ -r "${help_tables}" ]] ; then
818 cat "${help_tables}" >> "${sqltmp}"
819 fi
820 fi
821
822 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
823 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
824 local mysqld="${ROOT}/usr/sbin/mysqld \
825 ${options} \
826 --user=mysql \
827 --skip-grant-tables \
828 --basedir=${ROOT}/usr \
829 --datadir=${ROOT}/${DATADIR} \
830 --skip-innodb \
831 --skip-bdb \
832 --skip-networking \
833 --max_allowed_packet=8M \
834 --net_buffer_length=16K \
835 --socket=${socket} \
836 --pid-file=${pidfile}"
837 ${mysqld} &
838 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
839 maxtry=$((${maxtry}-1))
840 echo -n "."
841 sleep 1
842 done
843
844 # Do this from memory, as we don't want clear text passwords in temp files
845 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
846 "${ROOT}/usr/bin/mysql" \
847 --socket=${socket} \
848 -hlocalhost \
849 -e "${sql}"
850
851 einfo "Loading \"zoneinfo\", this step may require a few seconds ..."
852
853 "${ROOT}/usr/bin/mysql" \
854 --socket=${socket} \
855 -hlocalhost \
856 -uroot \
857 -p"${pwd1}" \
858 mysql < "${sqltmp}"
859
860 # Stop the server and cleanup
861 kill $(< "${pidfile}" )
862 rm -f "${sqltmp}"
863 einfo "Stopping the server ..."
864 wait %1
865 einfo "Done"
866 }
867
868 mysql_pkg_postrm() {
869 : # mysql_lib_symlinks "${D}"
870 }

  ViewVC Help
Powered by ViewVC 1.1.20