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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.79 - (hide 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 chtekk 1.69 # Copyright 1999-2007 Gentoo Foundation
2 vivo 1.1 # Distributed under the terms of the GNU General Public License v2
3 peper 1.79 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.78 2007/05/11 08:25:11 robbat2 Exp $
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 robbat2 1.73 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
75 chtekk 1.69 http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
76 vivo 1.60 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 chtekk 1.69 SLOT="0"
84 vivo 1.60 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 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 robbat2 1.75 if [[ -z "${MY_DATADIR}" ]] ; then
203     MY_DATADIR=""
204 chtekk 1.30 if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
205 robbat2 1.75 MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
206 vivo 1.26 | sed -ne '/datadir/s|^--datadir=||p' \
207     | tail -n1`
208 robbat2 1.75 if [[ -z "${MY_DATADIR}" ]] ; then
209     MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
210 vivo 1.55 | sed -e 's/.*=\s*//'`
211 vivo 1.8 fi
212     fi
213 robbat2 1.75 if [[ -z "${MY_DATADIR}" ]] ; then
214     MY_DATADIR="${MY_LOCALSTATEDIR}"
215     einfo "Using default MY_DATADIR"
216 vivo 1.8 fi
217 robbat2 1.75 elog "MySQL MY_DATADIR is ${MY_DATADIR}"
218 vivo 1.8
219 chtekk 1.30 if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
220 robbat2 1.75 if [[ -e "${MY_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 robbat2 1.75 export MY_INCLUDEDIR MY_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 cardoe 1.76 if use berkdb ; then
332 chtekk 1.77 # 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 cardoe 1.76 if use alpha || use amd64 || use hppa || use mips || use sparc ; then
336 chtekk 1.77 elog "Berkeley DB support was disabled due to compatibility issues on this arch"
337 cardoe 1.76 myconf="${myconf} --without-berkeley-db"
338     else
339 chtekk 1.39 myconf="${myconf} --with-berkeley-db=./bdb"
340     fi
341 cardoe 1.76 else
342     myconf="${myconf} --without-berkeley-db"
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 swegener 1.74 # TODO: check this with a cmake expert
527 cardoe 1.67 use innodb \
528 vivo 1.51 && cmake \
529 chtekk 1.72 -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) \
530     -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCC)) \
531 vivo 1.51 "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 chtekk 1.71 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 vivo 1.4 popd &>/dev/null
552 vivo 1.1 fi
553     }
554    
555 vivo 1.6 mysql_src_compile() {
556 chtekk 1.30 # Make sure the vars are correctly initialized
557     mysql_init_vars
558 vivo 1.1
559 chtekk 1.42 # $myconf is modified by the configure_* functions
560     local myconf=""
561 vivo 1.1
562 cardoe 1.67 if use minimal ; then
563 chtekk 1.42 configure_minimal
564 vivo 1.1 else
565 chtekk 1.42 configure_common
566 vivo 1.51 if mysql_version_is_at_least "5.1.10" ; then
567 chtekk 1.42 configure_51
568 vivo 1.1 else
569 chtekk 1.42 configure_40_41_50
570 vivo 1.1 fi
571 vivo 1.23 fi
572    
573 chtekk 1.30 # Bug #114895, bug #110149
574 vivo 1.1 filter-flags "-O" "-O[01]"
575 chtekk 1.30
576     # glib-2.3.2_pre fix, bug #16496
577 vivo 1.1 append-flags "-DHAVE_ERRNO_AS_DEFINE=1"
578    
579 vivo 1.48 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
580 chtekk 1.34 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
581 vivo 1.51 mysql_version_is_at_least "5.0" \
582 chtekk 1.34 && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
583 chtekk 1.39 export CXXFLAGS
584 vivo 1.1
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 chtekk 1.39 ${myconf} || die "econf failed"
598 vivo 1.1
599 chtekk 1.30 # TODO: Move this before autoreconf !!!
600 vivo 1.21 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 vivo 1.1
604 chtekk 1.39 emake || die "emake failed"
605 vivo 1.55
606 cardoe 1.67 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_compile
607 vivo 1.1 }
608    
609     mysql_src_install() {
610 chtekk 1.30 # Make sure the vars are correctly initialized
611     mysql_init_vars
612 vivo 1.1
613 chtekk 1.69 emake install DESTDIR="${D}" benchdir_root="${MY_SHAREDSTATEDIR}" || die "emake install failed"
614 vivo 1.55
615 cardoe 1.67 mysql_version_is_at_least "5.1.12" && use pbxt && pbxt_src_install
616 vivo 1.1
617     insinto "${MY_INCLUDEDIR}"
618     doins "${MY_INCLUDEDIR}"/my_{config,dir}.h
619    
620 chtekk 1.30 # Convenience links
621 chtekk 1.69 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
622     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
623     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
624 vivo 1.1
625 chtekk 1.30 # Various junk (my-*.cnf moved elsewhere)
626     rm -Rf "${D}/usr/share/info"
627 vivo 1.37 for removeme in "mysql-log-rotate" mysql.server* \
628     binary-configure* my-*.cnf mi_test_all*
629     do
630 chtekk 1.30 rm -f "${D}"/usr/share/mysql/${removeme}
631 vivo 1.1 done
632    
633 chtekk 1.69 # Clean up stuff for a minimal build
634 cardoe 1.67 if use minimal ; then
635 chtekk 1.30 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 vivo 1.26 rm -f "${D}/usr/sbin/mysqld"
638 chtekk 1.30 rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
639 vivo 1.1 fi
640    
641 chtekk 1.30 # Configuration stuff
642 vivo 1.51 if mysql_version_is_at_least "4.1" ; then
643 chtekk 1.30 mysql_mycnf_version="4.1"
644     else
645     mysql_mycnf_version="4.0"
646     fi
647 vivo 1.1 insinto "${MY_SYSCONFDIR}"
648 vivo 1.55 doins scripts/mysqlaccess.conf
649 robbat2 1.75 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
650 chtekk 1.30 "${FILESDIR}/my.cnf-${mysql_mycnf_version}" \
651 vivo 1.9 > "${TMPDIR}/my.cnf.ok"
652 cardoe 1.67 if mysql_version_is_at_least "4.1" && use latin1 ; then
653 chtekk 1.30 sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok"
654     fi
655 vivo 1.9 newins "${TMPDIR}/my.cnf.ok" my.cnf
656    
657 chtekk 1.30 # Minimal builds don't have the MySQL server
658 cardoe 1.67 if ! use minimal ; then
659 chtekk 1.30 # Empty directories ...
660 vivo 1.1 diropts "-m0750"
661     if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
662 robbat2 1.75 dodir "${MY_DATADIR}"
663     keepdir "${MY_DATADIR}"
664     chown -R mysql:mysql "${D}/${MY_DATADIR}"
665 vivo 1.1 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 chtekk 1.30 # Docs
676 vivo 1.1 dodoc README COPYING ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE
677 robbat2 1.78 doinfo ${S}/Docs/mysql.info
678 chtekk 1.30
679     # Minimal builds don't have the MySQL server
680 cardoe 1.67 if ! use minimal ; then
681 vivo 1.1 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 vivo 1.4 for script in scripts/mysql* ; do
692     [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
693 vivo 1.1 done
694 robbat2 1.78
695 vivo 1.1 fi
696 vivo 1.4
697 vivo 1.58 mysql_lib_symlinks "${D}"
698 vivo 1.15 }
699    
700     mysql_pkg_preinst() {
701 chtekk 1.30 enewgroup mysql 60 || die "problem adding 'mysql' group"
702     enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
703 vivo 1.1 }
704    
705     mysql_pkg_postinst() {
706 chtekk 1.30 # Make sure the vars are correctly initialized
707 vivo 1.1 mysql_init_vars
708    
709 chtekk 1.30 # Check FEATURES="collision-protect" before removing this
710 chtekk 1.69 [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
711 vivo 1.1
712 chtekk 1.30 # Secure the logfiles
713 vivo 1.1 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
714     chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
715     chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
716    
717 vivo 1.55 # Minimal builds don't have the MySQL server
718 cardoe 1.67 if ! use minimal ; then
719 vivo 1.55 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 chtekk 1.69
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 vivo 1.55 fi
739    
740 cardoe 1.67 if mysql_version_is_at_least "5.1.12" && use pbxt ; then
741 chtekk 1.69 # 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 vivo 1.63 elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
746 chtekk 1.69 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 vivo 1.4 fi
754 chtekk 1.69
755 vivo 1.51 mysql_check_version_range "4.0 to 5.0.99.99" \
756 cardoe 1.67 && use berkdb \
757 chtekk 1.41 && elog "Berkeley DB support is deprecated and will be removed in future versions!"
758 vivo 1.1 }
759    
760     mysql_pkg_config() {
761 chtekk 1.30 # Make sure the vars are correctly initialized
762 vivo 1.1 mysql_init_vars
763    
764 robbat2 1.75 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
765 chtekk 1.30
766 vivo 1.49 if built_with_use ${CATEGORY}/${PN} minimal ; then
767 vivo 1.1 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 robbat2 1.75 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
775 vivo 1.1 ewarn "You have already a MySQL database in place."
776 robbat2 1.75 ewarn "(${ROOT}/${MY_DATADIR}/*)"
777 vivo 1.1 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 chtekk 1.30 einfo "permissions on it ..."
783 vivo 1.1
784     einfo "Insert a password for the mysql 'root' user"
785     ewarn "Avoid [\"'\\_%] characters in the password"
786 chtekk 1.30 read -rsp " >" pwd1 ; echo
787 vivo 1.1
788 chtekk 1.30 einfo "Retype the password"
789 vivo 1.1 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 chtekk 1.30 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
799 vivo 1.1 [[ -r "${help_tables}" ]] \
800 vivo 1.8 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
801 vivo 1.1 || touch "${TMPDIR}/fill_help_tables.sql"
802     help_tables="${TMPDIR}/fill_help_tables.sql"
803    
804 vivo 1.4 pushd "${TMPDIR}" &>/dev/null
805 chtekk 1.30 "${ROOT}/usr/bin/mysql_install_db" | grep -B5 -A999 -i "ERROR"
806 vivo 1.4 popd &>/dev/null
807 robbat2 1.75 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
808 vivo 1.26 || die "MySQL databases not installed"
809 robbat2 1.75 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2> /dev/null
810     chmod 0750 "${ROOT}/${MY_DATADIR}" 2> /dev/null
811 vivo 1.1
812 vivo 1.51 if mysql_version_is_at_least "4.1.3" ; then
813 vivo 1.1 options="--skip-ndbcluster"
814    
815     # Filling timezones, see
816     # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
817 chtekk 1.30 "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
818 vivo 1.1
819     if [[ -r "${help_tables}" ]] ; then
820     cat "${help_tables}" >> "${sqltmp}"
821     fi
822     fi
823    
824 chtekk 1.30 local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
825     local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
826 vivo 1.26 local mysqld="${ROOT}/usr/sbin/mysqld \
827 vivo 1.1 ${options} \
828     --user=mysql \
829     --skip-grant-tables \
830     --basedir=${ROOT}/usr \
831 robbat2 1.75 --datadir=${ROOT}/${MY_DATADIR} \
832 vivo 1.1 --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 chtekk 1.30 ${mysqld} &
840 vivo 1.1 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
841 chtekk 1.30 maxtry=$((${maxtry}-1))
842 vivo 1.1 echo -n "."
843     sleep 1
844     done
845    
846 chtekk 1.30 # Do this from memory, as we don't want clear text passwords in temp files
847 vivo 1.1 local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'"
848 chtekk 1.30 "${ROOT}/usr/bin/mysql" \
849 vivo 1.1 --socket=${socket} \
850     -hlocalhost \
851     -e "${sql}"
852    
853 chtekk 1.30 einfo "Loading \"zoneinfo\", this step may require a few seconds ..."
854 vivo 1.1
855 chtekk 1.30 "${ROOT}/usr/bin/mysql" \
856 vivo 1.1 --socket=${socket} \
857     -hlocalhost \
858     -uroot \
859     -p"${pwd1}" \
860     mysql < "${sqltmp}"
861    
862 chtekk 1.30 # Stop the server and cleanup
863 vivo 1.1 kill $(< "${pidfile}" )
864 chtekk 1.30 rm -f "${sqltmp}"
865     einfo "Stopping the server ..."
866 vivo 1.1 wait %1
867 chtekk 1.30 einfo "Done"
868 vivo 1.1 }
869    
870     mysql_pkg_postrm() {
871 chtekk 1.70 : # mysql_lib_symlinks "${D}"
872 vivo 1.25 }

  ViewVC Help
Powered by ViewVC 1.1.20