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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.79 - (show annotations) (download)
Mon Jul 2 14:24:27 2007 UTC (6 years, 9 months ago) by peper
Branch: MAIN
Changes since 1.78: +1 -2 lines
(QA) RESTRICT clean up.

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.78 2007/05/11 08:25:11 robbat2 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 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
75 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
76 mysql_version_is_at_least "5.1.12" \
77 && [[ -n "${PBXT_VERSION}" ]] \
78 && SRC_URI="${SRC_URI} pbxt? ( mirror://sourceforge/pbxt/pbxt-${PBXT_VERSION}.tar.gz )"
79
80 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
81 HOMEPAGE="http://www.mysql.com/"
82 LICENSE="GPL-2"
83 SLOT="0"
84 IUSE="big-tables debug embedded minimal perl selinux ssl static"
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 "${MY_DATADIR}" ]] ; then
203 MY_DATADIR=""
204 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
205 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
206 | sed -ne '/datadir/s|^--datadir=||p' \
207 | tail -n1`
208 if [[ -z "${MY_DATADIR}" ]] ; then
209 MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
210 | sed -e 's/.*=\s*//'`
211 fi
212 fi
213 if [[ -z "${MY_DATADIR}" ]] ; then
214 MY_DATADIR="${MY_LOCALSTATEDIR}"
215 einfo "Using default MY_DATADIR"
216 fi
217 elog "MySQL MY_DATADIR is ${MY_DATADIR}"
218
219 if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
220 if [[ -e "${MY_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 MY_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 if use berkdb ; then
332 # The following fix is due to a bug with bdb on SPARC's. See:
333 # http://www.geocrawler.com/mail/msg.php3?msg_id=4754814&list=8
334 # It comes down to non-64-bit safety problems.
335 if use alpha || use amd64 || use hppa || use mips || use sparc ; then
336 elog "Berkeley DB support was disabled due to compatibility issues on this arch"
337 myconf="${myconf} --without-berkeley-db"
338 else
339 myconf="${myconf} --with-berkeley-db=./bdb"
340 fi
341 else
342 myconf="${myconf} --without-berkeley-db"
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=$(type -P $(tc-getCC)) \
530 -DCMAKE_CXX_COMPILER=$(type -P $(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@!${MY_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 "${MY_DATADIR}"
663 keepdir "${MY_DATADIR}"
664 chown -R mysql:mysql "${D}/${MY_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 doinfo ${S}/Docs/mysql.info
678
679 # Minimal builds don't have the MySQL server
680 if ! use minimal ; then
681 docinto "support-files"
682 for script in \
683 support-files/my-*.cnf \
684 support-files/magic \
685 support-files/ndb-config-2-node.ini
686 do
687 dodoc "${script}"
688 done
689
690 docinto "scripts"
691 for script in scripts/mysql* ; do
692 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
693 done
694
695 fi
696
697 mysql_lib_symlinks "${D}"
698 }
699
700 mysql_pkg_preinst() {
701 enewgroup mysql 60 || die "problem adding 'mysql' group"
702 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
703 }
704
705 mysql_pkg_postinst() {
706 # Make sure the vars are correctly initialized
707 mysql_init_vars
708
709 # Check FEATURES="collision-protect" before removing this
710 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
711
712 # Secure the logfiles
713 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
714 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
715 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
716
717 # Minimal builds don't have the MySQL server
718 if ! use minimal ; then
719 docinto "support-files"
720 for script in \
721 support-files/my-*.cnf \
722 support-files/magic \
723 support-files/ndb-config-2-node.ini
724 do
725 dodoc "${script}"
726 done
727
728 docinto "scripts"
729 for script in scripts/mysql* ; do
730 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
731 done
732
733 einfo
734 elog "You might want to run:"
735 elog "\"emerge --config =${CATEGORY}/${PF}\""
736 elog "if this is a new install."
737 einfo
738 fi
739
740 if mysql_version_is_at_least "5.1.12" && use pbxt ; then
741 # TODO: explain it better
742 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';"
743 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;"
744 elog "if, after that, you cannot start the MySQL server,"
745 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
746 elog "use the MySQL upgrade script to restore the table"
747 elog "or execute the following SQL command:"
748 elog " CREATE TABLE IF NOT EXISTS plugin ("
749 elog " name char(64) binary DEFAULT '' NOT NULL,"
750 elog " dl char(128) DEFAULT '' NOT NULL,"
751 elog " PRIMARY KEY (name)"
752 elog " ) CHARACTER SET utf8 COLLATE utf8_bin;"
753 fi
754
755 mysql_check_version_range "4.0 to 5.0.99.99" \
756 && use berkdb \
757 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
758 }
759
760 mysql_pkg_config() {
761 # Make sure the vars are correctly initialized
762 mysql_init_vars
763
764 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
765
766 if built_with_use ${CATEGORY}/${PN} minimal ; then
767 die "Minimal builds do NOT include the MySQL server"
768 fi
769
770 local pwd1="a"
771 local pwd2="b"
772 local maxtry=5
773
774 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
775 ewarn "You have already a MySQL database in place."
776 ewarn "(${ROOT}/${MY_DATADIR}/*)"
777 ewarn "Please rename or delete it if you wish to replace it."
778 die "MySQL database already exists!"
779 fi
780
781 einfo "Creating the mysql database and setting proper"
782 einfo "permissions on it ..."
783
784 einfo "Insert a password for the mysql 'root' user"
785 ewarn "Avoid [\"'\\_%] characters in the password"
786 read -rsp " >" pwd1 ; echo
787
788 einfo "Retype the password"
789 read -rsp " >" pwd2 ; echo
790
791 if [[ "x$pwd1" != "x$pwd2" ]] ; then
792 die "Passwords are not the same"
793 fi
794
795 local options=""
796 local sqltmp="$(emktemp)"
797
798 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
799 [[ -r "${help_tables}" ]] \
800 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
801 || touch "${TMPDIR}/fill_help_tables.sql"
802 help_tables="${TMPDIR}/fill_help_tables.sql"
803
804 pushd "${TMPDIR}" &>/dev/null
805 "${ROOT}/usr/bin/mysql_install_db" | grep -B5 -A999 -i "ERROR"
806 popd &>/dev/null
807 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
808 || die "MySQL databases not installed"
809 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2> /dev/null
810 chmod 0750 "${ROOT}/${MY_DATADIR}" 2> /dev/null
811
812 if mysql_version_is_at_least "4.1.3" ; then
813 options="--skip-ndbcluster"
814
815 # Filling timezones, see
816 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
817 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
818
819 if [[ -r "${help_tables}" ]] ; then
820 cat "${help_tables}" >> "${sqltmp}"
821 fi
822 fi
823
824 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
825 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
826 local mysqld="${ROOT}/usr/sbin/mysqld \
827 ${options} \
828 --user=mysql \
829 --skip-grant-tables \
830 --basedir=${ROOT}/usr \
831 --datadir=${ROOT}/${MY_DATADIR} \
832 --skip-innodb \
833 --skip-bdb \
834 --skip-networking \
835 --max_allowed_packet=8M \
836 --net_buffer_length=16K \
837 --socket=${socket} \
838 --pid-file=${pidfile}"
839 ${mysqld} &
840 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
841 maxtry=$((${maxtry}-1))
842 echo -n "."
843 sleep 1
844 done
845
846 # Do this from memory, as we don't want clear text passwords in temp files
847 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
848 "${ROOT}/usr/bin/mysql" \
849 --socket=${socket} \
850 -hlocalhost \
851 -e "${sql}"
852
853 einfo "Loading \"zoneinfo\", this step may require a few seconds ..."
854
855 "${ROOT}/usr/bin/mysql" \
856 --socket=${socket} \
857 -hlocalhost \
858 -uroot \
859 -p"${pwd1}" \
860 mysql < "${sqltmp}"
861
862 # Stop the server and cleanup
863 kill $(< "${pidfile}" )
864 rm -f "${sqltmp}"
865 einfo "Stopping the server ..."
866 wait %1
867 einfo "Done"
868 }
869
870 mysql_pkg_postrm() {
871 : # mysql_lib_symlinks "${D}"
872 }

  ViewVC Help
Powered by ViewVC 1.1.20