| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.11 2011/12/27 07:37:20 robbat2 Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.16 2012/05/06 10:42:36 heroxbd Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: mysql-v2.eclass |
5 | # @ECLASS: mysql-v2.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Maintainers: |
7 | # Maintainers: |
| 8 | # - MySQL Team <mysql-bugs@gentoo.org> |
8 | # - MySQL Team <mysql-bugs@gentoo.org> |
| … | |
… | |
| 13 | # The mysql-v2.eclass is the base eclass to build the mysql and |
13 | # The mysql-v2.eclass is the base eclass to build the mysql and |
| 14 | # alternative projects (mariadb) ebuilds. |
14 | # alternative projects (mariadb) ebuilds. |
| 15 | # This eclass uses the mysql-autotools and mysql-cmake eclasses for the |
15 | # This eclass uses the mysql-autotools and mysql-cmake eclasses for the |
| 16 | # specific bits related to the build system. |
16 | # specific bits related to the build system. |
| 17 | # It provides the src_unpack, src_prepare, src_configure, src_compile, |
17 | # It provides the src_unpack, src_prepare, src_configure, src_compile, |
| 18 | # scr_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm |
18 | # src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm |
| 19 | # phase hooks. |
19 | # phase hooks. |
| 20 | |
20 | |
| 21 | # @ECLASS-VARIABLE: BUILD |
21 | # @ECLASS-VARIABLE: BUILD |
| 22 | # @DESCRIPTION: |
22 | # @DESCRIPTION: |
| 23 | # Build type of the mysql version |
23 | # Build type of the mysql version |
| … | |
… | |
| 51 | # |
51 | # |
| 52 | # Supported EAPI versions and export functions |
52 | # Supported EAPI versions and export functions |
| 53 | # |
53 | # |
| 54 | |
54 | |
| 55 | case "${EAPI:-0}" in |
55 | case "${EAPI:-0}" in |
| 56 | 2|3|4) ;; |
56 | 3|4) ;; |
| 57 | *) die "Unsupported EAPI: ${EAPI}" ;; |
57 | *) die "Unsupported EAPI: ${EAPI}" ;; |
| 58 | esac |
58 | esac |
| 59 | |
59 | |
| 60 | EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
60 | EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm |
| 61 | |
61 | |
| … | |
… | |
| 77 | # @DESCRIPTION: |
77 | # @DESCRIPTION: |
| 78 | # Upstream MySQL considers the first two parts of the version number to be the |
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 |
79 | # major version. Upgrades that change major version should always run |
| 80 | # mysql_upgrade. |
80 | # mysql_upgrade. |
| 81 | MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" |
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 | |
82 | |
| 91 | # @ECLASS-VARIABLE: MYSQL_VERSION_ID |
83 | # @ECLASS-VARIABLE: MYSQL_VERSION_ID |
| 92 | # @DESCRIPTION: |
84 | # @DESCRIPTION: |
| 93 | # MYSQL_VERSION_ID will be: |
85 | # MYSQL_VERSION_ID will be: |
| 94 | # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] |
86 | # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] |
| … | |
… | |
| 108 | MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} |
100 | MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} |
| 109 | |
101 | |
| 110 | # This eclass should only be used with at least mysql-5.1.50 |
102 | # 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" |
103 | mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50" |
| 112 | |
104 | |
| 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 |
105 | # @ECLASS-VARIABLE: XTRADB_VER |
| 131 | # @DEFAULT_UNSET |
106 | # @DEFAULT_UNSET |
| 132 | # @DESCRIPTION: |
107 | # @DESCRIPTION: |
| 133 | # Version of the XTRADB storage engine |
108 | # Version of the XTRADB storage engine |
| 134 | |
109 | |
| … | |
… | |
| 139 | |
114 | |
| 140 | # Work out the default SERVER_URI correctly |
115 | # Work out the default SERVER_URI correctly |
| 141 | if [ -z "${SERVER_URI}" ]; then |
116 | if [ -z "${SERVER_URI}" ]; then |
| 142 | [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}" |
117 | [ -z "${MY_PV}" ] && MY_PV="${PV//_/-}" |
| 143 | if [ "${PN}" == "mariadb" ]; then |
118 | if [ "${PN}" == "mariadb" ]; then |
| 144 | MARIA_FULL_PV="$(replace_version_separator 3 '-' ${PV})" |
119 | MARIA_FULL_PV="$(replace_version_separator 3 '-' ${MY_PV})" |
| 145 | MARIA_FULL_P="${PN}-${MARIA_FULL_PV}" |
120 | MARIA_FULL_P="${PN}-${MARIA_FULL_PV}" |
| 146 | SERVER_URI=" |
121 | SERVER_URI=" |
| 147 | http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz |
122 | 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 |
123 | 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 |
124 | 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 |
125 | 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 |
126 | 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 |
127 | http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz |
| 153 | " |
128 | " |
| 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 |
129 | else |
| 160 | URI_DIR="MySQL" |
130 | URI_DIR="MySQL" |
| 161 | URI_FILE="mysql" |
131 | URI_FILE="mysql" |
| 162 | fi |
|
|
| 163 | URI_A="${URI_FILE}-${MY_PV}.tar.gz" |
132 | URI_A="${URI_FILE}-${MY_PV}.tar.gz" |
| 164 | MIRROR_PV=$(get_version_component_range 1-2 ${PV}) |
133 | MIRROR_PV=$(get_version_component_range 1-2 ${PV}) |
| 165 | # Recently upstream switched to an archive site, and not on mirrors |
134 | # 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} |
135 | SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A} |
| 167 | mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}" |
136 | 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 |
137 | fi |
| 172 | fi |
138 | fi |
| 173 | |
139 | |
| 174 | # Define correct SRC_URIs |
140 | # Define correct SRC_URIs |
| 175 | SRC_URI="${SERVER_URI}" |
141 | SRC_URI="${SERVER_URI}" |
| … | |
… | |
| 185 | DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." |
151 | DESCRIPTION="A fast, multi-threaded, multi-user SQL database server." |
| 186 | HOMEPAGE="http://www.mysql.com/" |
152 | HOMEPAGE="http://www.mysql.com/" |
| 187 | if [[ "${PN}" == "mariadb" ]]; then |
153 | if [[ "${PN}" == "mariadb" ]]; then |
| 188 | HOMEPAGE="http://mariadb.org/" |
154 | HOMEPAGE="http://mariadb.org/" |
| 189 | DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged." |
155 | 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 |
156 | fi |
| 194 | LICENSE="GPL-2" |
157 | LICENSE="GPL-2" |
| 195 | SLOT="0" |
158 | SLOT="0" |
| 196 | |
159 | |
| 197 | case "${BUILD}" in |
160 | case "${BUILD}" in |
| … | |
… | |
| 204 | esac |
167 | esac |
| 205 | |
168 | |
| 206 | IUSE="${IUSE} latin1" |
169 | IUSE="${IUSE} latin1" |
| 207 | |
170 | |
| 208 | IUSE="${IUSE} extraengine" |
171 | IUSE="${IUSE} extraengine" |
| 209 | if [[ ${PN} != "mysql-cluster" ]] ; then |
|
|
| 210 | IUSE="${IUSE} cluster" |
172 | IUSE="${IUSE} cluster" |
| 211 | fi |
|
|
| 212 | |
173 | |
| 213 | IUSE="${IUSE} max-idx-128" |
174 | IUSE="${IUSE} max-idx-128" |
| 214 | IUSE="${IUSE} berkdb" |
175 | IUSE="${IUSE} berkdb" |
| 215 | |
|
|
| 216 | [[ ${MYSQL_COMMUNITY_FEATURES} == 1 ]] \ |
|
|
| 217 | && IUSE="${IUSE} +community profiling" |
176 | IUSE="${IUSE} +community profiling" |
| 218 | |
177 | |
| 219 | [[ ${PN} == "mariadb" ]] \ |
178 | [[ ${PN} == "mariadb" ]] \ |
| 220 | && IUSE="${IUSE} libevent" |
179 | && IUSE="${IUSE} libevent" |
| 221 | |
180 | |
| 222 | [[ ${PN} == "mariadb" ]] \ |
181 | [[ ${PN} == "mariadb" ]] \ |
| … | |
… | |
| 227 | && mysql_version_is_at_least "5.2.5" \ |
186 | && mysql_version_is_at_least "5.2.5" \ |
| 228 | && IUSE="${IUSE} sphinx" |
187 | && IUSE="${IUSE} sphinx" |
| 229 | |
188 | |
| 230 | mysql_version_is_at_least "5.5.7" \ |
189 | mysql_version_is_at_least "5.5.7" \ |
| 231 | && IUSE="${IUSE} systemtap" |
190 | && IUSE="${IUSE} systemtap" |
| 232 | |
|
|
| 233 | |
191 | |
| 234 | # |
192 | # |
| 235 | # DEPENDENCIES: |
193 | # DEPENDENCIES: |
| 236 | # |
194 | # |
| 237 | |
195 | |
| … | |
… | |
| 248 | |
206 | |
| 249 | [[ ${PN} == mariadb ]] \ |
207 | [[ ${PN} == mariadb ]] \ |
| 250 | && DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" |
208 | && DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )" |
| 251 | |
209 | |
| 252 | # Having different flavours at the same time is not a good idea |
210 | # Having different flavours at the same time is not a good idea |
| 253 | for i in "mysql" "mysql-community" "mysql-cluster" "mariadb" ; do |
211 | for i in "mysql" "mariadb" ; do |
| 254 | [[ ${i} == ${PN} ]] || |
212 | [[ ${i} == ${PN} ]] || |
| 255 | DEPEND="${DEPEND} !dev-db/${i}" |
213 | DEPEND="${DEPEND} !dev-db/${i}" |
| 256 | done |
214 | done |
| 257 | |
215 | |
| 258 | # prefix: first need to implement something for #196294 |
216 | # prefix: first need to implement something for #196294 |
| … | |
… | |
| 288 | # dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
246 | # dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
| 289 | PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
247 | PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
| 290 | |
248 | |
| 291 | # For other stuff to bring us in |
249 | # For other stuff to bring us in |
| 292 | PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" |
250 | PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}" |
| 293 | |
|
|
| 294 | |
251 | |
| 295 | # |
252 | # |
| 296 | # External patches |
253 | # External patches |
| 297 | # |
254 | # |
| 298 | |
255 | |
| … | |
… | |
| 325 | |
282 | |
| 326 | PBXT_P="pbxt-${PBXT_VERSION}" |
283 | PBXT_P="pbxt-${PBXT_VERSION}" |
| 327 | PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" |
284 | PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz" |
| 328 | SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" |
285 | SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )" |
| 329 | |
286 | |
|
|
287 | fi |
|
|
288 | |
| 330 | # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins |
289 | # PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins |
| 331 | # vs. built outside the dir |
290 | # vs. built outside the dir |
| 332 | if pbxt_available; then |
291 | if pbxt_available; then |
| 333 | |
292 | |
| 334 | IUSE="${IUSE} pbxt" |
293 | IUSE="${IUSE} pbxt" |
| 335 | PBXT_NEWSTYLE=1 |
294 | PBXT_NEWSTYLE=1 |
| 336 | fi |
|
|
| 337 | fi |
295 | fi |
| 338 | |
296 | |
| 339 | if xtradb_patch_available; then |
297 | if xtradb_patch_available; then |
| 340 | XTRADB_P="percona-xtradb-${XTRADB_VER}" |
298 | XTRADB_P="percona-xtradb-${XTRADB_VER}" |
| 341 | XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" |
299 | XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz" |
| … | |
… | |
| 386 | # warn about deprecated features |
344 | # warn about deprecated features |
| 387 | mysql-v2_pkg_setup() { |
345 | mysql-v2_pkg_setup() { |
| 388 | |
346 | |
| 389 | if has test ${FEATURES} ; then |
347 | if has test ${FEATURES} ; then |
| 390 | if ! use minimal ; then |
348 | if ! use minimal ; then |
| 391 | if [[ $UID -eq 0 ]]; then |
349 | if ! has userpriv ${FEATURES} ; then |
| 392 | eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
350 | eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
| 393 | fi |
351 | fi |
| 394 | fi |
352 | fi |
| 395 | fi |
353 | fi |
| 396 | |
354 | |
| … | |
… | |
| 424 | |
382 | |
| 425 | # This should come after all of the die statements |
383 | # This should come after all of the die statements |
| 426 | enewgroup mysql 60 || die "problem adding 'mysql' group" |
384 | enewgroup mysql 60 || die "problem adding 'mysql' group" |
| 427 | enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" |
385 | enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" |
| 428 | |
386 | |
| 429 | if [ "${PN}" != "mysql-cluster" ] && use cluster; then |
387 | if use cluster; then |
| 430 | ewarn "Upstream has noted that the NDB cluster support in the 5.0 and" |
388 | ewarn "Upstream has noted that the NDB cluster support in the 5.0 and" |
| 431 | ewarn "5.1 series should NOT be put into production. In the near" |
389 | ewarn "5.1 series should NOT be put into production. In the near" |
| 432 | ewarn "future, it will be disabled from building." |
390 | ewarn "future, it will be disabled from building." |
| 433 | ewarn "" |
|
|
| 434 | ewarn "If you need NDB support, you should instead move to the new" |
|
|
| 435 | ewarn "mysql-cluster package that represents that upstream NDB" |
|
|
| 436 | ewarn "development." |
|
|
| 437 | fi |
391 | fi |
| 438 | } |
392 | } |
| 439 | |
393 | |
| 440 | # @FUNCTION: mysql-v2_src_unpack |
394 | # @FUNCTION: mysql-v2_src_unpack |
| 441 | # @DESCRIPTION: |
395 | # @DESCRIPTION: |
| … | |
… | |
| 500 | |
454 | |
| 501 | # Make sure the vars are correctly initialized |
455 | # Make sure the vars are correctly initialized |
| 502 | mysql_init_vars |
456 | mysql_init_vars |
| 503 | |
457 | |
| 504 | # Check FEATURES="collision-protect" before removing this |
458 | # Check FEATURES="collision-protect" before removing this |
| 505 | [[ -d "${ROOT}/var/log/mysql" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
459 | [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
| 506 | |
460 | |
| 507 | # Secure the logfiles |
461 | # Secure the logfiles |
| 508 | touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} |
462 | touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} |
| 509 | chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* |
463 | chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* |
| 510 | chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* |
464 | chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* |
| … | |
… | |
| 602 | |
556 | |
| 603 | local pwd1="a" |
557 | local pwd1="a" |
| 604 | local pwd2="b" |
558 | local pwd2="b" |
| 605 | local maxtry=15 |
559 | local maxtry=15 |
| 606 | |
560 | |
| 607 | if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${ROOT}/root/.my.cnf" ]; then |
561 | if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then |
| 608 | MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${ROOT}/root/.my.cnf")" |
562 | MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")" |
| 609 | fi |
563 | fi |
| 610 | |
564 | |
| 611 | if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
565 | if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
| 612 | ewarn "You have already a MySQL database in place." |
566 | ewarn "You have already a MySQL database in place." |
| 613 | ewarn "(${ROOT}/${MY_DATADIR}/*)" |
567 | ewarn "(${ROOT}/${MY_DATADIR}/*)" |
| … | |
… | |
| 644 | && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
598 | && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
| 645 | || touch "${TMPDIR}/fill_help_tables.sql" |
599 | || touch "${TMPDIR}/fill_help_tables.sql" |
| 646 | help_tables="${TMPDIR}/fill_help_tables.sql" |
600 | help_tables="${TMPDIR}/fill_help_tables.sql" |
| 647 | |
601 | |
| 648 | pushd "${TMPDIR}" &>/dev/null |
602 | pushd "${TMPDIR}" &>/dev/null |
| 649 | "${ROOT}/usr/bin/mysql_install_db" --basedir=/usr >"${TMPDIR}"/mysql_install_db.log 2>&1 |
603 | "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1 |
| 650 | if [ $? -ne 0 ]; then |
604 | if [ $? -ne 0 ]; then |
| 651 | grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
605 | grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
| 652 | die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
606 | die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
| 653 | fi |
607 | fi |
| 654 | popd &>/dev/null |
608 | popd &>/dev/null |
| 655 | [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
609 | [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
| 656 | || die "MySQL databases not installed" |
610 | || die "MySQL databases not installed" |
| 657 | chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
611 | chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
| 658 | chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
612 | chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
| 659 | |
613 | |
| 660 | # Figure out which options we need to disable to do the setup |
614 | # Figure out which options we need to disable to do the setup |
| 661 | helpfile="${TMPDIR}/mysqld-help" |
615 | helpfile="${TMPDIR}/mysqld-help" |
| 662 | ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
616 | ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
| 663 | for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
617 | for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
| 664 | federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
618 | federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
| 665 | ndbcluster \ |
619 | ndbcluster \ |
| 666 | ; do |
620 | ; do |
| 667 | optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
621 | optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
| … | |
… | |
| 671 | egrep -sq external-locking "${helpfile}" && \ |
625 | egrep -sq external-locking "${helpfile}" && \ |
| 672 | options="${options/skip-locking/skip-external-locking}" |
626 | options="${options/skip-locking/skip-external-locking}" |
| 673 | |
627 | |
| 674 | # Filling timezones, see |
628 | # Filling timezones, see |
| 675 | # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
629 | # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
| 676 | "${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
630 | "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
| 677 | |
631 | |
| 678 | if [[ -r "${help_tables}" ]] ; then |
632 | if [[ -r "${help_tables}" ]] ; then |
| 679 | cat "${help_tables}" >> "${sqltmp}" |
633 | cat "${help_tables}" >> "${sqltmp}" |
| 680 | fi |
634 | fi |
| 681 | |
635 | |
| 682 | einfo "Creating the mysql database and setting proper" |
636 | einfo "Creating the mysql database and setting proper" |
| 683 | einfo "permissions on it ..." |
637 | einfo "permissions on it ..." |
| 684 | |
638 | |
| 685 | local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
639 | local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
| 686 | local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
640 | local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
| 687 | local mysqld="${ROOT}/usr/sbin/mysqld \ |
641 | local mysqld="${EROOT}/usr/sbin/mysqld \ |
| 688 | ${options} \ |
642 | ${options} \ |
| 689 | --user=mysql \ |
643 | --user=mysql \ |
| 690 | --basedir=${ROOT}/usr \ |
644 | --basedir=${EROOT}/usr \ |
| 691 | --datadir=${ROOT}/${MY_DATADIR} \ |
645 | --datadir=${ROOT}/${MY_DATADIR} \ |
| 692 | --max_allowed_packet=8M \ |
646 | --max_allowed_packet=8M \ |
| 693 | --net_buffer_length=16K \ |
647 | --net_buffer_length=16K \ |
| 694 | --default-storage-engine=MyISAM \ |
648 | --default-storage-engine=MyISAM \ |
| 695 | --socket=${socket} \ |
649 | --socket=${socket} \ |
| … | |
… | |
| 710 | fi |
664 | fi |
| 711 | |
665 | |
| 712 | ebegin "Setting root password" |
666 | ebegin "Setting root password" |
| 713 | # Do this from memory, as we don't want clear text passwords in temp files |
667 | # Do this from memory, as we don't want clear text passwords in temp files |
| 714 | local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
668 | local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
| 715 | "${ROOT}/usr/bin/mysql" \ |
669 | "${EROOT}/usr/bin/mysql" \ |
| 716 | --socket=${socket} \ |
670 | --socket=${socket} \ |
| 717 | -hlocalhost \ |
671 | -hlocalhost \ |
| 718 | -e "${sql}" |
672 | -e "${sql}" |
| 719 | eend $? |
673 | eend $? |
| 720 | |
674 | |
| 721 | ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." |
675 | ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." |
| 722 | "${ROOT}/usr/bin/mysql" \ |
676 | "${EROOT}/usr/bin/mysql" \ |
| 723 | --socket=${socket} \ |
677 | --socket=${socket} \ |
| 724 | -hlocalhost \ |
678 | -hlocalhost \ |
| 725 | -uroot \ |
679 | -uroot \ |
| 726 | -p"${MYSQL_ROOT_PASSWORD}" \ |
680 | -p"${MYSQL_ROOT_PASSWORD}" \ |
| 727 | mysql < "${sqltmp}" |
681 | mysql < "${sqltmp}" |
| … | |
… | |
| 740 | # @FUNCTION: mysql-v2_pkg_postrm |
694 | # @FUNCTION: mysql-v2_pkg_postrm |
| 741 | # @DESCRIPTION: |
695 | # @DESCRIPTION: |
| 742 | # Remove mysql symlinks. |
696 | # Remove mysql symlinks. |
| 743 | mysql-v2_pkg_postrm() { |
697 | mysql-v2_pkg_postrm() { |
| 744 | |
698 | |
| 745 | : # mysql_lib_symlinks "${D}" |
699 | : # mysql_lib_symlinks "${ED}" |
| 746 | } |
700 | } |