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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.69 - (show annotations) (download)
Fri Jan 12 20:51:28 2007 UTC (7 years, 6 months ago) by chtekk
Branch: MAIN
Changes since 1.68: +91 -159 lines
Revert slotted changes, cleanup.

1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
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 pushd "bdb/dist" \
547 && sh s_all \
548 || die "Failed bdb reconfigure" \
549 &>/dev/null
550 popd &>/dev/null
551 fi
552 }
553
554 mysql_src_compile() {
555 # Make sure the vars are correctly initialized
556 mysql_init_vars
557
558 # $myconf is modified by the configure_* functions
559 local myconf=""
560
561 if use minimal ; then
562 configure_minimal
563 else
564 configure_common
565 if mysql_version_is_at_least "5.1.10" ; then
566 configure_51
567 else
568 configure_40_41_50
569 fi
570 fi
571
572 # Bug #114895, bug #110149
573 filter-flags "-O" "-O[01]"
574
575 # glib-2.3.2_pre fix, bug #16496
576 append-flags "-DHAVE_ERRNO_AS_DEFINE=1"
577
578 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
579 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
580 mysql_version_is_at_least "5.0" \
581 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
582 export CXXFLAGS
583
584 econf \
585 --libexecdir="/usr/sbin" \
586 --sysconfdir="${MY_SYSCONFDIR}" \
587 --localstatedir="${MY_LOCALSTATEDIR}" \
588 --sharedstatedir="${MY_SHAREDSTATEDIR}" \
589 --libdir="${MY_LIBDIR}" \
590 --includedir="${MY_INCLUDEDIR}" \
591 --with-low-memory \
592 --with-client-ldflags=-lstdc++ \
593 --enable-thread-safe-client \
594 --with-comment="Gentoo Linux ${PF}" \
595 --without-docs \
596 ${myconf} || die "econf failed"
597
598 # TODO: Move this before autoreconf !!!
599 find . -type f -name Makefile -print0 \
600 | xargs -0 -n100 sed -i \
601 -e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
602
603 emake || die "emake failed"
604
605 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile
606 }
607
608 mysql_src_install() {
609 # Make sure the vars are correctly initialized
610 mysql_init_vars
611
612 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed"
613
614 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_install
615
616 insinto "${MY_INCLUDEDIR}"
617 doins "${MY_INCLUDEDIR}"/my_{config,dir}.h
618
619 # Convenience links
620 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
621 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
622 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
623
624 # Various junk (my-*.cnf moved elsewhere)
625 rm -Rf "${D}/usr/share/info"
626 for removeme in "mysql-log-rotate" mysql.server* \
627 binary-configure* my-*.cnf mi_test_all*
628 do
629 rm -f "${D}"/usr/share/mysql/${removeme}
630 done
631
632 # Clean up stuff for a minimal build
633 if use minimal ; then
634 rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
635 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}
636 rm -f "${D}/usr/sbin/mysqld"
637 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
638 fi
639
640 # Configuration stuff
641 if mysql_version_is_at_least "4.1" ; then
642 mysql_mycnf_version="4.1"
643 else
644 mysql_mycnf_version="4.0"
645 fi
646 insinto "${MY_SYSCONFDIR}"
647 doins scripts/mysqlaccess.conf
648 sed -e "s!@DATADIR@!${DATADIR}!g" \
649 "${FILESDIR}/my.cnf-${mysql_mycnf_version}" \
650 > "${TMPDIR}/my.cnf.ok"
651 if mysql_version_is_at_least "4.1" && use latin1 ; then
652 sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok"
653 fi
654 newins "${TMPDIR}/my.cnf.ok" my.cnf
655
656 # Minimal builds don't have the MySQL server
657 if ! use minimal ; then
658 # Empty directories ...
659 diropts "-m0750"
660 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
661 dodir "${DATADIR}"
662 keepdir "${DATADIR}"
663 chown -R mysql:mysql "${D}/${DATADIR}"
664 fi
665
666 diropts "-m0755"
667 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
668 dodir "${folder}"
669 keepdir "${folder}"
670 chown -R mysql:mysql "${D}/${folder}"
671 done
672 fi
673
674 # Docs
675 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE
676
677 # Minimal builds don't have the MySQL server
678 if ! use minimal ; then
679 docinto "support-files"
680 for script in \
681 support-files/my-*.cnf \
682 support-files/magic \
683 support-files/ndb-config-2-node.ini
684 do
685 dodoc "${script}"
686 done
687
688 docinto "scripts"
689 for script in scripts/mysql* ; do
690 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
691 done
692 fi
693
694 mysql_lib_symlinks "${D}"
695 }
696
697 mysql_pkg_preinst() {
698 enewgroup mysql 60 || die "problem adding 'mysql' group"
699 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
700 }
701
702 mysql_pkg_postinst() {
703 # Make sure the vars are correctly initialized
704 mysql_init_vars
705
706 # Check FEATURES="collision-protect" before removing this
707 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
708
709 # Secure the logfiles
710 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
711 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
712 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
713
714 # Minimal builds don't have the MySQL server
715 if ! use minimal ; then
716 docinto "support-files"
717 for script in \
718 support-files/my-*.cnf \
719 support-files/magic \
720 support-files/ndb-config-2-node.ini
721 do
722 dodoc "${script}"
723 done
724
725 docinto "scripts"
726 for script in scripts/mysql* ; do
727 [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
728 done
729
730 einfo
731 elog "You might want to run:"
732 elog "\"emerge --config =${CATEGORY}/${PF}\""
733 elog "if this is a new install."
734 einfo
735 fi
736
737 if mysql_version_is_at_least "5.1.12" && use pbxt ; then
738 # TODO: explain it better
739 elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';"
740 elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;"
741 elog "if, after that, you cannot start the MySQL server,"
742 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
743 elog "use the MySQL upgrade script to restore the table"
744 elog "or execute the following SQL command:"
745 elog " CREATE TABLE IF NOT EXISTS plugin ("
746 elog " name char(64) binary DEFAULT '' NOT NULL,"
747 elog " dl char(128) DEFAULT '' NOT NULL,"
748 elog " PRIMARY KEY (name)"
749 elog " ) CHARACTER SET utf8 COLLATE utf8_bin;"
750 fi
751
752 mysql_check_version_range "4.0 to 5.0.99.99" \
753 && use berkdb \
754 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
755 }
756
757 mysql_pkg_config() {
758 # Make sure the vars are correctly initialized
759 mysql_init_vars
760
761 [[ -z "${DATADIR}" ]] && die "Sorry, unable to find DATADIR"
762
763 if built_with_use ${CATEGORY}/${PN} minimal ; then
764 die "Minimal builds do NOT include the MySQL server"
765 fi
766
767 local pwd1="a"
768 local pwd2="b"
769 local maxtry=5
770
771 if [[ -d "${ROOT}/${DATADIR}/mysql" ]] ; then
772 ewarn "You have already a MySQL database in place."
773 ewarn "(${ROOT}/${DATADIR}/*)"
774 ewarn "Please rename or delete it if you wish to replace it."
775 die "MySQL database already exists!"
776 fi
777
778 einfo "Creating the mysql database and setting proper"
779 einfo "permissions on it ..."
780
781 einfo "Insert a password for the mysql 'root' user"
782 ewarn "Avoid [\"'\\_%] characters in the password"
783 read -rsp " >" pwd1 ; echo
784
785 einfo "Retype the password"
786 read -rsp " >" pwd2 ; echo
787
788 if [[ "x$pwd1" != "x$pwd2" ]] ; then
789 die "Passwords are not the same"
790 fi
791
792 local options=""
793 local sqltmp="$(emktemp)"
794
795 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
796 [[ -r "${help_tables}" ]] \
797 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
798 || touch "${TMPDIR}/fill_help_tables.sql"
799 help_tables="${TMPDIR}/fill_help_tables.sql"
800
801 pushd "${TMPDIR}" &>/dev/null
802 "${ROOT}/usr/bin/mysql_install_db" | grep -B5 -A999 -i "ERROR"
803 popd &>/dev/null
804 [[ -f "${ROOT}/${DATADIR}/mysql/user.frm" ]] \
805 || die "MySQL databases not installed"
806 chown -R mysql:mysql "${ROOT}/${DATADIR}" 2> /dev/null
807 chmod 0750 "${ROOT}/${DATADIR}" 2> /dev/null
808
809 if mysql_version_is_at_least "4.1.3" ; then
810 options="--skip-ndbcluster"
811
812 # Filling timezones, see
813 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
814 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
815
816 if [[ -r "${help_tables}" ]] ; then
817 cat "${help_tables}" >> "${sqltmp}"
818 fi
819 fi
820
821 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
822 local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
823 local mysqld="${ROOT}/usr/sbin/mysqld \
824 ${options} \
825 --user=mysql \
826 --skip-grant-tables \
827 --basedir=${ROOT}/usr \
828 --datadir=${ROOT}/${DATADIR} \
829 --skip-innodb \
830 --skip-bdb \
831 --skip-networking \
832 --max_allowed_packet=8M \
833 --net_buffer_length=16K \
834 --socket=${socket} \
835 --pid-file=${pidfile}"
836 ${mysqld} &
837 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
838 maxtry=$((${maxtry}-1))
839 echo -n "."
840 sleep 1
841 done
842
843 # Do this from memory, as we don't want clear text passwords in temp files
844 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
845 "${ROOT}/usr/bin/mysql" \
846 --socket=${socket} \
847 -hlocalhost \
848 -e "${sql}"
849
850 einfo "Loading \"zoneinfo\", this step may require a few seconds ..."
851
852 "${ROOT}/usr/bin/mysql" \
853 --socket=${socket} \
854 -hlocalhost \
855 -uroot \
856 -p"${pwd1}" \
857 mysql < "${sqltmp}"
858
859 # Stop the server and cleanup
860 kill $(< "${pidfile}" )
861 rm -f "${sqltmp}"
862 einfo "Stopping the server ..."
863 wait %1
864 einfo "Done"
865 }
866
867 mysql_pkg_postrm() {
868 # mysql_lib_symlinks "${D}"
869 }

  ViewVC Help
Powered by ViewVC 1.1.20