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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.69 - (hide 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 chtekk 1.69 # Copyright 1999-2007 Gentoo Foundation
2 vivo 1.1 # Distributed under the terms of the GNU General Public License v2
3 chtekk 1.69 # $Header: $
4 vivo 1.1
5 vivo 1.54 # Author: Francesco Riosa (Retired) <vivo@gentoo.org>
6 chtekk 1.30 # Maintainer: Luca Longinotti <chtekk@gentoo.org>
7 vivo 1.1
8 chtekk 1.69 # 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 chtekk 1.30
11 vivo 1.59 WANT_AUTOCONF="latest"
12     WANT_AUTOMAKE="latest"
13 chtekk 1.69
14 vivo 1.55 inherit eutils flag-o-matic gnuconfig autotools mysql_fx
15 vivo 1.54
16 vivo 1.59 # 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 vivo 1.65 [[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20070108"
21 vivo 1.54
22 vivo 1.60 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 chtekk 1.69
36 vivo 1.60 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 chtekk 1.69 >=sys-libs/zlib-1.2.3"
53 vivo 1.60
54 chtekk 1.69 # Having different flavours at the same time is not a good idea
55     for i in "" "-community" ; do
56 vivo 1.60 [[ "${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 chtekk 1.69 mysql_version_is_at_least "5.1.12" \
64     && DEPEND="${DEPEND} innodb? ( >=dev-util/cmake-2.4.3 )"
65    
66 vivo 1.60 # 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 chtekk 1.69 SRC_URI="${SERVER_URI}
74     http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
75 vivo 1.60 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 chtekk 1.69 SLOT="0"
83 vivo 1.60 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 chtekk 1.68 !minimal? ( dev-db/mysql-init-scripts )
109     selinux? ( sec-policy/selinux-mysql )"
110 chtekk 1.39
111 vivo 1.26 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst \
112 swegener 1.36 pkg_postinst pkg_config pkg_postrm
113 vivo 1.1
114 vivo 1.37 #
115     # HELPER FUNCTIONS:
116     #
117    
118 vivo 1.51 bitkeeper_fetch() {
119 vivo 1.56 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 chtekk 1.69 einfo "Using '${reposuf}' repository."
128 vivo 1.56 local repo_uri="bk://mysql.bkbits.net/${reposuf}"
129 chtekk 1.69 ## -- ebk_store_dir: bitkeeper sources store directory
130 vivo 1.51 local ebk_store_dir="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bk-src"
131 chtekk 1.69 ## -- ebk_fetch_cmd: bitkeeper fetch command
132 vivo 1.51 # 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 chtekk 1.69 ## -- ebk_update_cmd: bitkeeper update command
136 vivo 1.51 local ebk_update_cmd="update"
137    
138 chtekk 1.69 # addread "/etc/bitkeeper"
139 vivo 1.51 addwrite "${ebk_store_dir}"
140    
141 chtekk 1.69 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 vivo 1.51 fi
145    
146 chtekk 1.69 pushd "${ebk_store_dir}" || die "BK: couldn't chdir to ${ebk_store_dir}"
147 vivo 1.51
148 vivo 1.56 local wc_path=${reposuf}
149 vivo 1.51
150 chtekk 1.69 if [[ ! -d "${wc_path}" ]] ; then
151 vivo 1.51 local options="-r+"
152 chtekk 1.69
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 vivo 1.51 else
160 chtekk 1.69 if [[ ! -d "${wc_path}/BK" ]] ; then
161 vivo 1.51 popd
162 chtekk 1.69 die "Looks like ${wc_path} is not a bitkeeper path"
163 vivo 1.51 fi
164    
165     # update working copy
166     einfo "bitkeeper update start -->"
167 chtekk 1.69 einfo " repository: ${repo_uri}"
168 vivo 1.51
169     ${ebk_update_cmd} "${repo_uri}" "${wc_path}" \
170 chtekk 1.69 || die "BK: couldn't update from ${repo_uri} to ${wc_path}"
171 vivo 1.51 fi
172    
173 chtekk 1.69 einfo " working copy: ${wc_path}"
174 vivo 1.51 cd "${wc_path}"
175 chtekk 1.69 rsync -rlpgo --exclude="BK/" . "${S}" || die "BK: couldn't export to ${S}"
176 swegener 1.53
177 vivo 1.51 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 chtekk 1.69 ewarn "test '${testname}' disabled: '${reason}'"
187 vivo 1.51 }
188    
189 vivo 1.8 # void mysql_init_vars()
190     #
191 chtekk 1.30 # Initialize global variables
192     # 2005-11-19 <vivo@gentoo.org>
193    
194 vivo 1.8 mysql_init_vars() {
195 chtekk 1.69 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 vivo 1.8
202 chtekk 1.30 if [[ -z "${DATADIR}" ]] ; then
203 vivo 1.8 DATADIR=""
204 chtekk 1.30 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
205 chtekk 1.69 DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
206 vivo 1.26 | sed -ne '/datadir/s|^--datadir=||p' \
207     | tail -n1`
208 chtekk 1.30 if [[ -z "${DATADIR}" ]] ; then
209 vivo 1.55 DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
210     | sed -e 's/.*=\s*//'`
211 vivo 1.8 fi
212     fi
213 chtekk 1.30 if [[ -z "${DATADIR}" ]] ; then
214 vivo 1.55 DATADIR="${MY_LOCALSTATEDIR}"
215 vivo 1.8 einfo "Using default DATADIR"
216     fi
217 chtekk 1.39 elog "MySQL DATADIR is ${DATADIR}"
218 vivo 1.8
219 chtekk 1.30 if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
220     if [[ -e "${DATADIR}" ]] ; then
221 chtekk 1.39 elog "Previous datadir found, it's YOUR job to change"
222     elog "ownership and take care of it"
223 vivo 1.8 PREVIOUS_DATADIR="yes"
224     else
225     PREVIOUS_DATADIR="no"
226     fi
227 chtekk 1.30 export PREVIOUS_DATADIR
228 vivo 1.8 fi
229     fi
230    
231 vivo 1.55 MY_SOURCEDIR=${SERVER_URI##*/}
232     MY_SOURCEDIR=${MY_SOURCEDIR%.tar*}
233    
234 chtekk 1.69 export MY_SHAREDSTATEDIR MY_SYSCONFDIR
235 vivo 1.8 export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
236 vivo 1.55 export MY_INCLUDEDIR DATADIR MY_SOURCEDIR
237 vivo 1.8 }
238    
239 vivo 1.37 configure_minimal() {
240 vivo 1.46 # 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 vivo 1.37
245 vivo 1.46 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 vivo 1.47
251 cardoe 1.67 if use static ; then
252 vivo 1.47 myconf="${myconf} --with-client-ldflags=-all-static"
253     myconf="${myconf} --disable-shared"
254     else
255     myconf="${myconf} --enable-shared --enable-static"
256     fi
257 chtekk 1.50
258 chtekk 1.69 if mysql_version_is_at_least "4.1" && ! use latin1 ; then
259 chtekk 1.50 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 vivo 1.37 }
266    
267     configure_common() {
268 chtekk 1.39 myconf="${myconf} $(use_with big-tables)"
269 vivo 1.37 myconf="${myconf} --enable-local-infile"
270     myconf="${myconf} --with-extra-charsets=all"
271     myconf="${myconf} --with-mysqld-user=mysql"
272 chtekk 1.39 myconf="${myconf} --with-server"
273 vivo 1.43 myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock"
274 vivo 1.37 myconf="${myconf} --without-libwrap"
275 chtekk 1.39
276 cardoe 1.67 if use static ; then
277 vivo 1.37 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 cardoe 1.67 if use debug ; then
285 vivo 1.37 myconf="${myconf} --with-debug=full"
286     else
287     myconf="${myconf} --without-debug"
288 vivo 1.51 mysql_version_is_at_least "4.1.3" \
289 cardoe 1.67 && use cluster \
290 vivo 1.37 && myconf="${myconf} --without-ndb-debug"
291     fi
292 chtekk 1.39
293 cardoe 1.67 if mysql_version_is_at_least "4.1" && ! use latin1 ; then
294 vivo 1.37 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 chtekk 1.39
301 cardoe 1.67 if use embedded ; then
302 vivo 1.37 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 vivo 1.51 mysql_version_is_at_least "5.0" || myconf="${myconf} $(use_with raid)"
318 vivo 1.37
319 chtekk 1.69 # --with-vio is not needed anymore, it's on by default and
320     # has been removed from configure
321 cardoe 1.67 if use ssl ; then
322 chtekk 1.69 mysql_version_is_at_least "5.0.4" || myconf="${myconf} --with-vio"
323 vivo 1.62 fi
324    
325     if mysql_version_is_at_least "5.1.11" ; then
326     myconf="${myconf} $(use_with ssl)"
327 vivo 1.37 else
328 vivo 1.62 myconf="${myconf} $(use_with ssl openssl)"
329 vivo 1.37 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 chtekk 1.69 if use alpha || use amd64 || use hppa || use mips || use sparc ; then
335 chtekk 1.39 elog "Berkeley DB support was disabled due to incompatible arch"
336 vivo 1.37 myconf="${myconf} --without-berkeley-db"
337     else
338 cardoe 1.67 if use berkdb ; then
339 chtekk 1.39 myconf="${myconf} --with-berkeley-db=./bdb"
340     else
341     myconf="${myconf} --without-berkeley-db"
342     fi
343 vivo 1.37 fi
344    
345 vivo 1.51 if mysql_version_is_at_least "4.1.3" ; then
346 vivo 1.37 myconf="${myconf} --with-geometry"
347     myconf="${myconf} $(use_with cluster ndbcluster)"
348     fi
349    
350 cardoe 1.67 if mysql_version_is_at_least "4.1.3" && use extraengine ; then
351 vivo 1.37 # 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 vivo 1.51 if mysql_version_is_at_least "5.0.3" ; then
364 chtekk 1.39 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 vivo 1.37 myconf="${myconf} --with-federated-storage-engine"
367     fi
368     fi
369    
370 vivo 1.51 mysql_version_is_at_least "5.0.18" \
371 cardoe 1.67 && use max-idx-128 \
372 vivo 1.37 && myconf="${myconf} --with-max-indexes=128"
373     }
374    
375 chtekk 1.39 configure_51() {
376 chtekk 1.40 # TODO: !!!! readd --without-readline
377 chtekk 1.39 # the failure depend upon config/ac-macros/readline.m4 checking into
378 vivo 1.37 # 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 cardoe 1.67 use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
387 chtekk 1.39
388 vivo 1.37 # 5.1 introduces a new way to manage storage engines (plugins)
389     # like configuration=none
390     local plugins="csv,myisam,myisammrg,heap"
391 cardoe 1.67 if use extraengine ; then
392 vivo 1.37 # like configuration=max-no-ndb, archive and example removed in 5.1.11
393 vivo 1.52 plugins="${plugins},archive,blackhole,example,federated,partition"
394 vivo 1.37
395 chtekk 1.39 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 vivo 1.37 fi
398    
399 cardoe 1.67 if use innodb ; then
400 vivo 1.37 plugins="${plugins},innobase"
401     fi
402    
403     # like configuration=max-no-ndb
404 cardoe 1.67 if use cluster ; then
405 vivo 1.37 plugins="${plugins},ndbcluster"
406     myconf="${myconf} --with-ndb-binlog"
407     fi
408    
409 vivo 1.58 if mysql_version_is_at_least "5.2" ; then
410     plugins="${plugins},falcon"
411     fi
412    
413 vivo 1.37 myconf="${myconf} --with-plugins=${plugins}"
414     }
415    
416 vivo 1.51 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 chtekk 1.69 local myconf=""
425     myconf="${myconf} --with-mysql=${S} --libdir=${D}/${MY_LIBDIR}"
426 cardoe 1.67 use debug && myconf="${myconf} --with-debug=full"
427 chtekk 1.69 # 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 vivo 1.51
432     popd
433 chtekk 1.69 # TODO: modify test suite for PBXT
434 vivo 1.51 }
435    
436     pbxt_src_install() {
437     pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
438 chtekk 1.69 make install || die "Failed to install PBXT"
439 vivo 1.51 popd
440     }
441    
442 vivo 1.37 #
443     # EBUILD FUNCTIONS
444     #
445    
446 vivo 1.1 mysql_pkg_setup() {
447 chtekk 1.30 enewgroup mysql 60 || die "problem adding 'mysql' group"
448     enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
449 swegener 1.53
450 chtekk 1.30 # Check for USE flag problems in pkg_setup
451 cardoe 1.67 if use static && use ssl ; then
452 chtekk 1.30 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 vivo 1.1
456 vivo 1.51 if ! mysql_version_is_at_least "5.0" \
457 cardoe 1.67 && use raid \
458     && use static ; then
459 chtekk 1.30 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 vivo 1.1 fi
463    
464 vivo 1.51 if mysql_version_is_at_least "4.1.3" \
465 cardoe 1.67 && ( use cluster || use extraengine ) \
466     && use minimal ; then
467 chtekk 1.30 eerror "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
468     die "USE flags 'cluster' and 'extraengine' conflict with 'minimal' USE flag!"
469 vivo 1.1 fi
470 chtekk 1.39
471 vivo 1.51 mysql_check_version_range "4.0 to 5.0.99.99" \
472 cardoe 1.67 && use berkdb \
473 chtekk 1.41 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
474 chtekk 1.30 }
475    
476     mysql_src_unpack() {
477     # Initialize the proper variables first
478     mysql_init_vars
479 vivo 1.1
480 chtekk 1.30 unpack ${A}
481 vivo 1.55 if [[ ${IS_BITKEEPER} -eq 90 ]] ; then
482 vivo 1.56 if mysql_check_version_range "5.1 to 5.1.99" ; then
483     bitkeeper_fetch "mysql-5.1-ndb"
484 chtekk 1.69 elif mysql_check_version_range "5.2 to 5.2.99" ; then
485 vivo 1.56 bitkeeper_fetch "mysql-5.2-falcon"
486     else
487     bitkeeper_fetch
488     fi
489 vivo 1.55 cd "${S}"
490 chtekk 1.69 einfo "Running upstream autorun over BK sources ..."
491 vivo 1.55 BUILD/autorun.sh
492     else
493     mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
494     cd "${S}"
495     fi
496 vivo 1.1
497 chtekk 1.30 # Apply the patches for this MySQL version
498 vivo 1.55 EPATCH_SUFFIX="patch"
499 chtekk 1.69 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
500 vivo 1.55 mysql_mv_patches
501 chtekk 1.69 epatch
502 vivo 1.1
503 chtekk 1.30 # Additional checks, remove bundled zlib
504 vivo 1.1 rm -f "${S}/zlib/"*.[ch]
505     sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
506 chtekk 1.30 rm -f "scripts/mysqlbug"
507 vivo 1.1
508     # Make charsets install in the right place
509 vivo 1.37 find . -name 'Makefile.am' \
510     -exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
511 vivo 1.1
512 vivo 1.55 if mysql_version_is_at_least "4.1" ; then
513 chtekk 1.30 # 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 vivo 1.37 rm -f "scripts/mysqlbug"
520 chtekk 1.30 fi
521 vivo 1.1
522 vivo 1.51 local rebuilddirlist d
523 vivo 1.1
524 vivo 1.51 if mysql_version_is_at_least "5.1.12" ; then
525 chtekk 1.42 rebuilddirlist="."
526 chtekk 1.69 # TODO: check this with a cmake expert
527 cardoe 1.67 use innodb \
528 vivo 1.51 && cmake \
529     -DCMAKE_C_COMPILER=$(which $(tc-getCC)) \
530     -DCMAKE_CXX_COMPILER=$(which $(tc-getCC)) \
531     "storage/innobase"
532 vivo 1.1 else
533     rebuilddirlist=". innobase"
534     fi
535    
536 chtekk 1.30 for d in ${rebuilddirlist} ; do
537     einfo "Reconfiguring dir '${d}'"
538 vivo 1.4 pushd "${d}" &>/dev/null
539 vivo 1.21 AT_GNUCONF_UPDATE="yes" eautoreconf
540 vivo 1.4 popd &>/dev/null
541 vivo 1.1 done
542    
543 vivo 1.51 if mysql_check_version_range "4.1 to 5.0.99.99" \
544 cardoe 1.67 && use berkdb ; then
545 vivo 1.51 [[ -w "bdb/dist/ltmain.sh" ]] && cp -f "ltmain.sh" "bdb/dist/ltmain.sh"
546     pushd "bdb/dist" \
547 chtekk 1.30 && sh s_all \
548     || die "Failed bdb reconfigure" \
549     &>/dev/null
550 vivo 1.4 popd &>/dev/null
551 vivo 1.1 fi
552     }
553    
554 vivo 1.6 mysql_src_compile() {
555 chtekk 1.30 # Make sure the vars are correctly initialized
556     mysql_init_vars
557 vivo 1.1
558 chtekk 1.42 # $myconf is modified by the configure_* functions
559     local myconf=""
560 vivo 1.1
561 cardoe 1.67 if use minimal ; then
562 chtekk 1.42 configure_minimal
563 vivo 1.1 else
564 chtekk 1.42 configure_common
565 vivo 1.51 if mysql_version_is_at_least "5.1.10" ; then
566 chtekk 1.42 configure_51
567 vivo 1.1 else
568 chtekk 1.42 configure_40_41_50
569 vivo 1.1 fi
570 vivo 1.23 fi
571    
572 chtekk 1.30 # Bug #114895, bug #110149
573 vivo 1.1 filter-flags "-O" "-O[01]"
574 chtekk 1.30
575     # glib-2.3.2_pre fix, bug #16496
576 vivo 1.1 append-flags "-DHAVE_ERRNO_AS_DEFINE=1"
577    
578 vivo 1.48 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
579 chtekk 1.34 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
580 vivo 1.51 mysql_version_is_at_least "5.0" \
581 chtekk 1.34 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
582 chtekk 1.39 export CXXFLAGS
583 vivo 1.1
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 chtekk 1.39 ${myconf} || die "econf failed"
597 vivo 1.1
598 chtekk 1.30 # TODO: Move this before autoreconf !!!
599 vivo 1.21 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 vivo 1.1
603 chtekk 1.39 emake || die "emake failed"
604 vivo 1.55
605 cardoe 1.67 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile
606 vivo 1.1 }
607    
608     mysql_src_install() {
609 chtekk 1.30 # Make sure the vars are correctly initialized
610     mysql_init_vars
611 vivo 1.1
612 chtekk 1.69 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed"
613 vivo 1.55
614 cardoe 1.67 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_install
615 vivo 1.1
616     insinto "${MY_INCLUDEDIR}"
617     doins "${MY_INCLUDEDIR}"/my_{config,dir}.h
618    
619 chtekk 1.30 # Convenience links
620 chtekk 1.69 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
621     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
622     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
623 vivo 1.1
624 chtekk 1.30 # Various junk (my-*.cnf moved elsewhere)
625     rm -Rf "${D}/usr/share/info"
626 vivo 1.37 for removeme in "mysql-log-rotate" mysql.server* \
627     binary-configure* my-*.cnf mi_test_all*
628     do
629 chtekk 1.30 rm -f "${D}"/usr/share/mysql/${removeme}
630 vivo 1.1 done
631    
632 chtekk 1.69 # Clean up stuff for a minimal build
633 cardoe 1.67 if use minimal ; then
634 chtekk 1.30 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 vivo 1.26 rm -f "${D}/usr/sbin/mysqld"
637 chtekk 1.30 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
638 vivo 1.1 fi
639    
640 chtekk 1.30 # Configuration stuff
641 vivo 1.51 if mysql_version_is_at_least "4.1" ; then
642 chtekk 1.30 mysql_mycnf_version="4.1"
643     else
644     mysql_mycnf_version="4.0"
645     fi
646 vivo 1.1 insinto "${MY_SYSCONFDIR}"
647 vivo 1.55 doins scripts/mysqlaccess.conf
648 chtekk 1.69 sed -e "s!@DATADIR@!${DATADIR}!g" \
649 chtekk 1.30 "${FILESDIR}/my.cnf-${mysql_mycnf_version}" \
650 vivo 1.9 > "${TMPDIR}/my.cnf.ok"
651 cardoe 1.67 if mysql_version_is_at_least "4.1" && use latin1 ; then
652 chtekk 1.30 sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok"
653     fi
654 vivo 1.9 newins "${TMPDIR}/my.cnf.ok" my.cnf
655    
656 chtekk 1.30 # Minimal builds don't have the MySQL server
657 cardoe 1.67 if ! use minimal ; then
658 chtekk 1.30 # Empty directories ...
659 vivo 1.1 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 chtekk 1.30 # Docs
675 vivo 1.1 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE
676 chtekk 1.30
677     # Minimal builds don't have the MySQL server
678 cardoe 1.67 if ! use minimal ; then
679 vivo 1.1 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 vivo 1.4 for script in scripts/mysql* ; do
690     [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
691 vivo 1.1 done
692     fi
693 vivo 1.4
694 vivo 1.58 mysql_lib_symlinks "${D}"
695 vivo 1.15 }
696    
697     mysql_pkg_preinst() {
698 chtekk 1.30 enewgroup mysql 60 || die "problem adding 'mysql' group"
699     enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
700 vivo 1.1 }
701    
702     mysql_pkg_postinst() {
703 chtekk 1.30 # Make sure the vars are correctly initialized
704 vivo 1.1 mysql_init_vars
705    
706 chtekk 1.30 # Check FEATURES="collision-protect" before removing this
707 chtekk 1.69 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
708 vivo 1.1
709 chtekk 1.30 # Secure the logfiles
710 vivo 1.1 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
711     chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
712     chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
713    
714 vivo 1.55 # Minimal builds don't have the MySQL server
715 cardoe 1.67 if ! use minimal ; then
716 vivo 1.55 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 chtekk 1.69
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 vivo 1.55 fi
736    
737 cardoe 1.67 if mysql_version_is_at_least "5.1.12" && use pbxt ; then
738 chtekk 1.69 # 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 vivo 1.63 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
743 chtekk 1.69 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 vivo 1.4 fi
751 chtekk 1.69
752 vivo 1.51 mysql_check_version_range "4.0 to 5.0.99.99" \
753 cardoe 1.67 && use berkdb \
754 chtekk 1.41 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
755 vivo 1.1 }
756    
757     mysql_pkg_config() {
758 chtekk 1.30 # Make sure the vars are correctly initialized
759 vivo 1.1 mysql_init_vars
760    
761 chtekk 1.30 [[ -z "${DATADIR}" ]] && die "Sorry, unable to find DATADIR"
762    
763 vivo 1.49 if built_with_use ${CATEGORY}/${PN} minimal ; then
764 vivo 1.1 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 chtekk 1.30 einfo "permissions on it ..."
780 vivo 1.1
781     einfo "Insert a password for the mysql 'root' user"
782     ewarn "Avoid [\"'\\_%] characters in the password"
783 chtekk 1.30 read -rsp " >" pwd1 ; echo
784 vivo 1.1
785 chtekk 1.30 einfo "Retype the password"
786 vivo 1.1 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 chtekk 1.30 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
796 vivo 1.1 [[ -r "${help_tables}" ]] \
797 vivo 1.8 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
798 vivo 1.1 || touch "${TMPDIR}/fill_help_tables.sql"
799     help_tables="${TMPDIR}/fill_help_tables.sql"
800    
801 vivo 1.4 pushd "${TMPDIR}" &>/dev/null
802 chtekk 1.30 "${ROOT}/usr/bin/mysql_install_db" | grep -B5 -A999 -i "ERROR"
803 vivo 1.4 popd &>/dev/null
804 chtekk 1.30 [[ -f "${ROOT}/${DATADIR}/mysql/user.frm" ]] \
805 vivo 1.26 || die "MySQL databases not installed"
806 chtekk 1.30 chown -R mysql:mysql "${ROOT}/${DATADIR}" 2> /dev/null
807     chmod 0750 "${ROOT}/${DATADIR}" 2> /dev/null
808 vivo 1.1
809 vivo 1.51 if mysql_version_is_at_least "4.1.3" ; then
810 vivo 1.1 options="--skip-ndbcluster"
811    
812     # Filling timezones, see
813     # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
814 chtekk 1.30 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
815 vivo 1.1
816     if [[ -r "${help_tables}" ]] ; then
817     cat "${help_tables}" >> "${sqltmp}"
818     fi
819     fi
820    
821 chtekk 1.30 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
822     local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
823 vivo 1.26 local mysqld="${ROOT}/usr/sbin/mysqld \
824 vivo 1.1 ${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 chtekk 1.30 ${mysqld} &
837 vivo 1.1 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
838 chtekk 1.30 maxtry=$((${maxtry}-1))
839 vivo 1.1 echo -n "."
840     sleep 1
841     done
842    
843 chtekk 1.30 # Do this from memory, as we don't want clear text passwords in temp files
844 vivo 1.1 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
845 chtekk 1.30 "${ROOT}/usr/bin/mysql" \
846 vivo 1.1 --socket=${socket} \
847     -hlocalhost \
848     -e "${sql}"
849    
850 chtekk 1.30 einfo "Loading \"zoneinfo\", this step may require a few seconds ..."
851 vivo 1.1
852 chtekk 1.30 "${ROOT}/usr/bin/mysql" \
853 vivo 1.1 --socket=${socket} \
854     -hlocalhost \
855     -uroot \
856     -p"${pwd1}" \
857     mysql < "${sqltmp}"
858    
859 chtekk 1.30 # Stop the server and cleanup
860 vivo 1.1 kill $(< "${pidfile}" )
861 chtekk 1.30 rm -f "${sqltmp}"
862     einfo "Stopping the server ..."
863 vivo 1.1 wait %1
864 chtekk 1.30 einfo "Done"
865 vivo 1.1 }
866    
867     mysql_pkg_postrm() {
868 chtekk 1.69 # mysql_lib_symlinks "${D}"
869 vivo 1.25 }

  ViewVC Help
Powered by ViewVC 1.1.20