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

Contents of /eclass/mysql-v2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Thu Nov 17 16:04:02 2011 UTC (2 years, 10 months ago) by dev-zero
Branch: MAIN
Changes since 1.9: +2 -2 lines
Fixed misplaced quotes in mysql-v2 eclass causing 'emerge --config mysql' to fail (bug #388673).

1 robbat2 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 dev-zero 1.10 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.9 2011/10/07 04:30:18 jmbsvicetto Exp $
4 robbat2 1.1
5     # @ECLASS: mysql-v2.eclass
6     # @MAINTAINER:
7     # Maintainers:
8     # - MySQL Team <mysql-bugs@gentoo.org>
9     # - Robin H. Johnson <robbat2@gentoo.org>
10     # - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
11     # @BLURB: This eclass provides most of the functions for mysql ebuilds
12     # @DESCRIPTION:
13     # The mysql-v2.eclass is the base eclass to build the mysql and
14     # alternative projects (mariadb) ebuilds.
15     # This eclass uses the mysql-autotools and mysql-cmake eclasses for the
16     # specific bits related to the build system.
17     # It provides the src_unpack, src_prepare, src_configure, src_compile,
18     # scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
19     # phase hooks.
20    
21     # @ECLASS-VARIABLE: BUILD
22 vapier 1.7 # @DESCRIPTION:
23     # Build type of the mysql version
24 robbat2 1.1 : ${BUILD:=autotools}
25    
26     case ${BUILD} in
27     "cmake")
28     BUILD_INHERIT="mysql-cmake"
29     ;;
30     "autotools")
31     BUILD_INHERIT="mysql-autotools"
32    
33     WANT_AUTOCONF="latest"
34     WANT_AUTOMAKE="latest"
35     ;;
36     *)
37     die "${BUILD} is not a valid build system for mysql"
38     ;;
39     esac
40    
41     MYSQL_EXTRAS=""
42    
43     # @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
44 vapier 1.7 # @DESCRIPTION:
45     # The version of the MYSQL_EXTRAS repo to use to build mysql
46 jmbsvicetto 1.9 # Use "none" to disable it's use
47 robbat2 1.1 [[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2"
48    
49     inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs
50    
51     #
52     # Supported EAPI versions and export functions
53     #
54    
55     case "${EAPI:-0}" in
56     2|3|4) ;;
57     *) die "Unsupported EAPI: ${EAPI}" ;;
58     esac
59    
60 jmbsvicetto 1.3 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm
61 robbat2 1.1
62     #
63     # VARIABLES:
64     #
65    
66     # Shorten the path because the socket path length must be shorter than 107 chars
67     # and we will run a mysql server during test phase
68     S="${WORKDIR}/mysql"
69    
70     [[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
71     if [[ "${MY_EXTRAS_VER}" == "live" ]]; then
72     EGIT_PROJECT=mysql-extras
73     EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git"
74     fi
75    
76     # @ECLASS-VARIABLE: MYSQL_PV_MAJOR
77     # @DESCRIPTION:
78     # Upstream MySQL considers the first two parts of the version number to be the
79     # major version. Upgrades that change major version should always run
80     # mysql_upgrade.
81     MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
82    
83     # Cluster is a special case...
84     if [[ "${PN}" == "mysql-cluster" ]]; then
85     case $PV in
86     6.1*|7.0*|7.1*) MYSQL_PV_MAJOR=5.1 ;;
87     esac
88     fi
89    
90    
91     # @ECLASS-VARIABLE: MYSQL_VERSION_ID
92     # @DESCRIPTION:
93     # MYSQL_VERSION_ID will be:
94     # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
95     # This is an important part, because many of the choices the MySQL ebuild will do
96     # depend on this variable.
97     # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
98     # We also strip off upstream's trailing letter that they use to respin tarballs
99     MYSQL_VERSION_ID=""
100     tpv="${PV%[a-z]}"
101     tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
102     for vatom in 0 1 2 3 ; do
103     # pad to length 2
104     tpv[${vatom}]="00${tpv[${vatom}]}"
105     MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
106     done
107     # strip leading "0" (otherwise it's considered an octal number by BASH)
108     MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
109    
110     # This eclass should only be used with at least mysql-5.1.50
111     mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50"
112    
113     # @ECLASS-VARIABLE: MYSQL_COMMUNITY_FEATURES
114     # @DESCRIPTION:
115     # Specifiy if community features are available. Possible values are 1 (yes)
116     # and 0 (no).
117     # Community features are available in mysql-community
118     # AND in the re-merged mysql-5.0.82 and newer
119     if [ "${PN}" == "mysql-community" -o "${PN}" == "mariadb" ]; then
120     MYSQL_COMMUNITY_FEATURES=1
121     elif [ "${MYSQL_PV_MAJOR}" == "5.1" ]; then
122     MYSQL_COMMUNITY_FEATURES=1
123     elif mysql_version_is_at_least "5.4.0"; then
124     MYSQL_COMMUNITY_FEATURES=1
125     else
126     MYSQL_COMMUNITY_FEATURES=0
127     fi
128    
129    
130     # @ECLASS-VARIABLE: XTRADB_VER
131     # @DEFAULT_UNSET
132     # @DESCRIPTION:
133     # Version of the XTRADB storage engine
134    
135     # @ECLASS-VARIABLE: PERCONA_VER
136     # @DEFAULT_UNSET
137     # @DESCRIPTION:
138     # Designation by PERCONA for a MySQL version to apply an XTRADB release
139    
140     # Work out the default SERVER_URI correctly
141     if [ -z "${SERVER_URI}" ]; then
142     [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
143     if [ "${PN}" == "mariadb" ]; then
144     MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})"
145     MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
146     SERVER_URI="
147     http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
148     http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
149     http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
150     http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz
151     http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
152     http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
153     "
154     # The community and cluster builds are on the mirrors
155     elif [[ "${MYSQL_COMMUNITY_FEATURES}" == "1" || ${PN} == "mysql-cluster" ]] ; then
156     if [[ "${PN}" == "mysql-cluster" ]] ; then
157     URI_DIR="MySQL-Cluster"
158     URI_FILE="mysql-cluster-gpl"
159     else
160     URI_DIR="MySQL"
161     URI_FILE="mysql"
162     fi
163     URI_A="${URI_FILE}-${MY_PV}.tar.gz"
164     MIRROR_PV=$(get_version_component_range 1-2 ${PV})
165     # Recently upstream switched to an archive site, and not on mirrors
166     SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
167     mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
168     # The (old) enterprise source is on the primary site only
169     elif [ "${PN}" == "mysql" ]; then
170     SERVER_URI="ftp://ftp.mysql.com/pub/mysql/src/mysql-${MY_PV}.tar.gz"
171     fi
172     fi
173    
174     # Define correct SRC_URIs
175     SRC_URI="${SERVER_URI}"
176    
177     # Gentoo patches to MySQL
178 jmbsvicetto 1.9 [[ ${MY_EXTRAS_VER} != live ]] && [[ ${MY_EXTRAS_VER} != none ]] \
179 robbat2 1.1 && SRC_URI="${SRC_URI}
180     mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
181     http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
182 jmbsvicetto 1.4 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
183     http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
184 robbat2 1.1
185     DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
186     HOMEPAGE="http://www.mysql.com/"
187     if [[ "${PN}" == "mariadb" ]]; then
188     HOMEPAGE="http://mariadb.org/"
189     DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
190     fi
191     if [[ "${PN}" == "mysql-community" ]]; then
192     DESCRIPTION="${DESCRIPTION} (obsolete, move to dev-db/mysql)"
193     fi
194     LICENSE="GPL-2"
195     SLOT="0"
196    
197     case "${BUILD}" in
198     "autotools")
199     IUSE="big-tables debug embedded minimal +perl selinux ssl static test"
200     ;;
201     "cmake")
202     IUSE="debug embedded minimal +perl selinux ssl static test"
203     ;;
204     esac
205    
206     IUSE="${IUSE} latin1"
207    
208     IUSE="${IUSE} extraengine"
209     if [[ ${PN} != "mysql-cluster" ]] ; then
210     IUSE="${IUSE} cluster"
211     fi
212    
213     IUSE="${IUSE} max-idx-128"
214     IUSE="${IUSE} berkdb"
215    
216     [[ ${MYSQL_COMMUNITY_FEATURES} == 1 ]] \
217     && IUSE="${IUSE} +community profiling"
218    
219     [[ ${PN} == "mariadb" ]] \
220     && IUSE="${IUSE} libevent"
221    
222     [[ ${PN} == "mariadb" ]] \
223     && mysql_version_is_at_least "5.2" \
224     && IUSE="${IUSE} oqgraph"
225    
226     [[ ${PN} == "mariadb" ]] \
227     && mysql_version_is_at_least "5.2.5" \
228     && IUSE="${IUSE} sphinx"
229    
230    
231     #
232     # DEPENDENCIES:
233     #
234    
235     # Be warned, *DEPEND are version-dependant
236     # These are used for both runtime and compiletime
237     DEPEND="
238     ssl? ( >=dev-libs/openssl-0.9.6d )
239 jmbsvicetto 1.9 kernel_linux? ( sys-process/procps )
240 robbat2 1.1 >=sys-apps/sed-4
241     >=sys-apps/texinfo-4.7-r1
242     >=sys-libs/readline-4.1
243     >=sys-libs/zlib-1.2.3
244     "
245    
246     [[ ${PN} == mariadb ]] \
247     && DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
248    
249     # Having different flavours at the same time is not a good idea
250     for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do
251     [[ ${i} == ${PN} ]] ||
252     DEPEND="${DEPEND} !dev-db/${i}"
253     done
254    
255 grobian 1.8 # prefix: first need to implement something for #196294
256 robbat2 1.1 RDEPEND="${DEPEND}
257 grobian 1.8 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
258 robbat2 1.1 selinux? ( sec-policy/selinux-mysql )
259     "
260    
261 jmbsvicetto 1.6 DEPEND="${DEPEND}
262     virtual/yacc
263     "
264    
265 robbat2 1.1 DEPEND="${DEPEND} static? ( || ( sys-libs/ncurses[static-libs] <=sys-libs/ncurses-5.7-r3 ) )"
266    
267     # compile-time-only
268     DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
269    
270     # compile-time-only
271     mysql_version_is_at_least "5.5.8" \
272     && DEPEND="${DEPEND} >=dev-util/cmake-2.6.3"
273    
274     [[ "${PN}" == "mariadb" ]] \
275     && mysql_version_is_at_least "5.2" \
276     && DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )"
277    
278     [[ "${PN}" == "mariadb" ]] \
279     && mysql_version_is_at_least "5.2.5" \
280     && DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
281    
282     # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
283     PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
284    
285     # For other stuff to bring us in
286     PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
287    
288    
289     #
290     # External patches
291     #
292    
293     # MariaDB has integrated PBXT
294     # PBXT_VERSION means that we have a PBXT patch for this PV
295     # PBXT was only introduced after 5.1.12
296     pbxt_patch_available() {
297     [[ ${PN} != "mariadb" ]] \
298     && [[ -n "${PBXT_VERSION}" ]]
299     return $?
300     }
301    
302     pbxt_available() {
303     pbxt_patch_available || [[ ${PN} == "mariadb" ]]
304     return $?
305     }
306    
307     # Get the percona tarball if XTRADB_VER and PERCONA_VER are both set
308     # MariaDB has integrated XtraDB
309     # XTRADB_VERS means that we have a XTRADB patch for this PV
310     # XTRADB was only introduced after 5.1.26
311     xtradb_patch_available() {
312     [[ ${PN} != "mariadb" ]] \
313     && [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]]
314     return $?
315     }
316    
317    
318     if pbxt_patch_available; then
319    
320     PBXT_P="pbxt-${PBXT_VERSION}"
321     PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz"
322     SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
323    
324     # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
325     # vs. built outside the dir
326     if pbxt_available; then
327    
328     IUSE="${IUSE} pbxt"
329     PBXT_NEWSTYLE=1
330     fi
331     fi
332    
333     if xtradb_patch_available; then
334     XTRADB_P="percona-xtradb-${XTRADB_VER}"
335     XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz"
336     XTRADB_SRC_B1="http://www.percona.com/"
337     XTRADB_SRC_B2="${XTRADB_SRC_B1}/percona-builds/"
338     XTRADB_SRC_URI1="${XTRADB_SRC_B2}/Percona-Server/Percona-Server-${XTRADB_SRC_URI_COMMON}"
339     XTRADB_SRC_URI2="${XTRADB_SRC_B2}/xtradb/${XTRADB_SRC_URI_COMMON}"
340     XTRADB_SRC_URI3="${XTRADB_SRC_B1}/${PN}/xtradb/${XTRADB_SRC_URI_COMMON}"
341     SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI1} ${XTRADB_SRC_URI2} ${XTRADB_SRC_URI3} )"
342     IUSE="${IUSE} xtradb"
343     fi
344    
345     #
346     # HELPER FUNCTIONS:
347     #
348    
349     # @FUNCTION: mysql-v2_disable_test
350     # @DESCRIPTION:
351     # Helper function to disable specific tests.
352     mysql-v2_disable_test() {
353     ${BUILD_INHERIT}_disable_test "$@"
354     }
355    
356     # @FUNCTION: mysql-v2_configure_minimal
357     # @DESCRIPTION:
358     # Helper function to configure minimal build
359     configure_minimal() {
360     ${BUILD_INHERIT}_configure_minimal "$@"
361     }
362    
363     # @FUNCTION: mysql-v2_configure_common
364     # @DESCRIPTION:
365     # Helper function to configure common builds
366     configure_common() {
367     ${BUILD_INHERIT}_configure_common "$@"
368     }
369    
370     #
371     # EBUILD FUNCTIONS
372     #
373    
374     # @FUNCTION: mysql-v2_pkg_setup
375     # @DESCRIPTION:
376     # Perform some basic tests and tasks during pkg_setup phase:
377     # die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
378     # check for conflicting use flags
379     # create new user and group for mysql
380     # warn about deprecated features
381     mysql-v2_pkg_setup() {
382    
383     if has test ${FEATURES} ; then
384     if ! use minimal ; then
385     if [[ $UID -eq 0 ]]; then
386     eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
387     fi
388     fi
389     fi
390    
391     # Check for USE flag problems in pkg_setup
392     if use static && use ssl ; then
393     M="MySQL does not support being built statically with SSL support enabled!"
394     eerror "${M}"
395     die "${M}"
396     fi
397    
398     if ! mysql_version_is_at_least "5.2" \
399     && use debug ; then
400     # Also in package.use.mask
401     die "Bug #344885: Upstream has broken USE=debug for 5.1 series >=5.1.51"
402     fi
403    
404     if ( use cluster || use extraengine || use embedded ) \
405     && use minimal ; then
406     M="USE flags 'cluster', 'extraengine', 'embedded' conflict with 'minimal' USE flag!"
407     eerror "${M}"
408     die "${M}"
409     fi
410    
411     if xtradb_patch_available \
412     && use xtradb \
413     && use embedded ; then
414     M="USE flags 'xtradb' and 'embedded' conflict and cause build failures"
415     eerror "${M}"
416     die "${M}"
417     fi
418    
419     # This should come after all of the die statements
420     enewgroup mysql 60 || die "problem adding 'mysql' group"
421     enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
422    
423     if [ "${PN}" != "mysql-cluster" ] && use cluster; then
424     ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
425     ewarn "5.1 series should NOT be put into production. In the near"
426     ewarn "future, it will be disabled from building."
427     ewarn ""
428     ewarn "If you need NDB support, you should instead move to the new"
429     ewarn "mysql-cluster package that represents that upstream NDB"
430     ewarn "development."
431     fi
432     }
433    
434     # @FUNCTION: mysql-v2_src_unpack
435     # @DESCRIPTION:
436     # Unpack the source code
437     mysql-v2_src_unpack() {
438    
439     # Initialize the proper variables first
440     mysql_init_vars
441    
442     unpack ${A}
443     # Grab the patches
444     [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-2_src_unpack
445    
446     mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
447     }
448    
449     # @FUNCTION: mysql-v2_src_prepare
450     # @DESCRIPTION:
451     # Apply patches to the source code and remove unneeded bundled libs.
452     mysql-v2_src_prepare() {
453     ${BUILD_INHERIT}_src_prepare "$@"
454     }
455    
456     # @FUNCTION: mysql-v2_src_configure
457     # @DESCRIPTION:
458     # Configure mysql to build the code for Gentoo respecting the use flags.
459     mysql-v2_src_configure() {
460     ${BUILD_INHERIT}_src_configure "$@"
461     }
462    
463     # @FUNCTION: mysql-v2_src_compile
464     # @DESCRIPTION:
465     # Compile the mysql code.
466     mysql-v2_src_compile() {
467     ${BUILD_INHERIT}_src_compile "$@"
468     }
469    
470     # @FUNCTION: mysql-v2_src_install
471     # @DESCRIPTION:
472     # Install mysql.
473     mysql-v2_src_install() {
474     ${BUILD_INHERIT}_src_install "$@"
475     }
476    
477     # @FUNCTION: mysql-v2_pkg_preinst
478     # @DESCRIPTION:
479     # Create the user and groups for mysql - die if that fails.
480     mysql-v2_pkg_preinst() {
481     enewgroup mysql 60 || die "problem adding 'mysql' group"
482     enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
483     }
484    
485     # @FUNCTION: mysql-v2_pkg_postinst
486     # @DESCRIPTION:
487     # Run post-installation tasks:
488     # create the dir for logfiles if non-existant
489     # touch the logfiles and secure them
490     # install scripts
491     # issue required steps for optional features
492     # issue deprecation warnings
493     mysql-v2_pkg_postinst() {
494    
495     # Make sure the vars are correctly initialized
496     mysql_init_vars
497    
498     # Check FEATURES="collision-protect" before removing this
499     [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
500    
501     # Secure the logfiles
502     touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
503     chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
504     chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
505    
506     # Minimal builds don't have the MySQL server
507     if ! use minimal ; then
508     docinto "support-files"
509     for script in \
510     support-files/my-*.cnf \
511     support-files/magic \
512     support-files/ndb-config-2-node.ini
513     do
514     [[ -f "${script}" ]] \
515     && dodoc "${script}"
516     done
517    
518     docinto "scripts"
519     for script in scripts/mysql* ; do
520     [[ -f "${script}" ]] \
521     && [[ "${script%.sh}" == "${script}" ]] \
522     && dodoc "${script}"
523     done
524    
525     einfo
526     elog "You might want to run:"
527     elog "\"emerge --config =${CATEGORY}/${PF}\""
528     elog "if this is a new install."
529     einfo
530    
531     einfo
532     elog "If you are upgrading major versions, you should run the"
533     elog "mysql_upgrade tool."
534     einfo
535     fi
536    
537     if pbxt_available && use pbxt ; then
538     # TODO: explain it better
539     elog " mysql> INSTALL PLUGIN pbxt SONAME 'libpbxt.so';"
540     elog " mysql> CREATE TABLE t1 (c1 int, c2 text) ENGINE=pbxt;"
541     elog "if, after that, you cannot start the MySQL server,"
542     elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
543     elog "use the MySQL upgrade script to restore the table"
544     elog "or execute the following SQL command:"
545     elog " CREATE TABLE IF NOT EXISTS plugin ("
546     elog " name char(64) binary DEFAULT '' NOT NULL,"
547     elog " dl char(128) DEFAULT '' NOT NULL,"
548     elog " PRIMARY KEY (name)"
549     elog " ) CHARACTER SET utf8 COLLATE utf8_bin;"
550     fi
551    
552     mysql_check_version_range "4.0 to 5.0.99.99" \
553     && use berkdb \
554     && elog "Berkeley DB support is deprecated and will be removed in future versions!"
555     }
556    
557     # @FUNCTION: mysql-v2_pkg_config
558     # @DESCRIPTION:
559     # Configure mysql environment.
560     mysql-v2_pkg_config() {
561    
562     local old_MY_DATADIR="${MY_DATADIR}"
563    
564     # Make sure the vars are correctly initialized
565     mysql_init_vars
566    
567     [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
568    
569     if built_with_use ${CATEGORY}/${PN} minimal ; then
570     die "Minimal builds do NOT include the MySQL server"
571     fi
572    
573     if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
574     local MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${MY_DATADIR})"
575     local old_MY_DATADIR_s="$(strip_duplicate_slashes ${ROOT}/${old_MY_DATADIR})"
576    
577     if [[ -d "${old_MY_DATADIR_s}" ]]; then
578     if [[ -d "${MY_DATADIR_s}" ]]; then
579     ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
580     ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
581     else
582     elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
583     mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
584     || die "Moving MY_DATADIR failed"
585     fi
586     else
587     ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
588     if [[ -d "${MY_DATADIR_s}" ]]; then
589     ewarn "Attempting to use ${MY_DATADIR_s}"
590     else
591     eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
592     die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
593     fi
594     fi
595     fi
596    
597     local pwd1="a"
598     local pwd2="b"
599     local maxtry=15
600    
601     if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then
602     MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")"
603     fi
604    
605     if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
606     ewarn "You have already a MySQL database in place."
607     ewarn "(${ROOT}/${MY_DATADIR}/*)"
608     ewarn "Please rename or delete it if you wish to replace it."
609     die "MySQL database already exists!"
610     fi
611    
612     # Bug #213475 - MySQL _will_ object strenously if your machine is named
613     # localhost. Also causes weird failures.
614     [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
615    
616     if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
617    
618     einfo "Please provide a password for the mysql 'root' user now, in the"
619     einfo "MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file."
620     ewarn "Avoid [\"'\\_%] characters in the password"
621     read -rsp " >" pwd1 ; echo
622    
623     einfo "Retype the password"
624     read -rsp " >" pwd2 ; echo
625    
626     if [[ "x$pwd1" != "x$pwd2" ]] ; then
627     die "Passwords are not the same"
628     fi
629     MYSQL_ROOT_PASSWORD="${pwd1}"
630     unset pwd1 pwd2
631     fi
632    
633     local options=""
634     local sqltmp="$(emktemp)"
635    
636     local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
637     [[ -r "${help_tables}" ]] \
638     && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
639     || touch "${TMPDIR}/fill_help_tables.sql"
640     help_tables="${TMPDIR}/fill_help_tables.sql"
641    
642     pushd "${TMPDIR}" &>/dev/null
643 dev-zero 1.10 "${ROOT}/usr/bin/mysql_install_db" --basedir=/usr >"${TMPDIR}"/mysql_install_db.log 2>&1
644 robbat2 1.1 if [ $? -ne 0 ]; then
645     grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
646     die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
647     fi
648     popd &>/dev/null
649     [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
650     || die "MySQL databases not installed"
651     chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
652     chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
653    
654     # Figure out which options we need to disable to do the setup
655     helpfile="${TMPDIR}/mysqld-help"
656     ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
657     for opt in grant-tables host-cache name-resolve networking slave-start bdb \
658     federated innodb ssl log-bin relay-log slow-query-log external-locking \
659     ndbcluster \
660     ; do
661     optexp="--(skip-)?${opt}" optfull="--skip-${opt}"
662     egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
663     done
664     # But some options changed names
665     egrep -sq external-locking "${helpfile}" && \
666     options="${options/skip-locking/skip-external-locking}"
667    
668     # Filling timezones, see
669     # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
670     "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
671    
672     if [[ -r "${help_tables}" ]] ; then
673     cat "${help_tables}" >> "${sqltmp}"
674     fi
675    
676     einfo "Creating the mysql database and setting proper"
677     einfo "permissions on it ..."
678    
679     local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
680     local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
681     local mysqld="${ROOT}/usr/sbin/mysqld \
682     ${options} \
683     --user=mysql \
684     --basedir=${ROOT}/usr \
685     --datadir=${ROOT}/${MY_DATADIR} \
686     --max_allowed_packet=8M \
687     --net_buffer_length=16K \
688     --default-storage-engine=MyISAM \
689     --socket=${socket} \
690     --pid-file=${pidfile}"
691     #einfo "About to start mysqld: ${mysqld}"
692     ebegin "Starting mysqld"
693     ${mysqld} &
694     rc=$?
695     while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
696     maxtry=$((${maxtry}-1))
697     echo -n "."
698     sleep 1
699     done
700     eend $rc
701    
702     if ! [[ -S "${socket}" ]]; then
703     die "Completely failed to start up mysqld with: ${mysqld}"
704     fi
705    
706     ebegin "Setting root password"
707     # Do this from memory, as we don't want clear text passwords in temp files
708     local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
709     "${ROOT}/usr/bin/mysql" \
710     --socket=${socket} \
711     -hlocalhost \
712     -e "${sql}"
713     eend $?
714    
715     ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
716     "${ROOT}/usr/bin/mysql" \
717     --socket=${socket} \
718     -hlocalhost \
719     -uroot \
720     -p"${MYSQL_ROOT_PASSWORD}" \
721     mysql < "${sqltmp}"
722     rc=$?
723     eend $?
724     [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
725    
726     # Stop the server and cleanup
727     einfo "Stopping the server ..."
728     kill $(< "${pidfile}" )
729     rm -f "${sqltmp}"
730     wait %1
731     einfo "Done"
732     }
733    
734     # @FUNCTION: mysql-v2_pkg_postrm
735     # @DESCRIPTION:
736     # Remove mysql symlinks.
737     mysql-v2_pkg_postrm() {
738    
739     : # mysql_lib_symlinks "${D}"
740     }

  ViewVC Help
Powered by ViewVC 1.1.20