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

Contents of /eclass/mysql.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.77 - (hide annotations) (download)
Wed May 9 21:14:22 2007 UTC (7 years, 4 months ago) by chtekk
Branch: MAIN
Changes since 1.76: +5 -5 lines
Fix spacing and spelling.

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

  ViewVC Help
Powered by ViewVC 1.1.20