1 |
robbat2 10/03/24 03:09:08 |
2 |
|
3 |
Modified: mysql.eclass |
4 |
Log: |
5 |
Last commit in the latest round of mysql changes: pkg_config now checks for options before disabling them during setup to avoid more zealous error checking from upstream. |
6 |
|
7 |
Revision Changes Path |
8 |
1.140 eclass/mysql.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mysql.eclass?rev=1.140&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mysql.eclass?rev=1.140&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mysql.eclass?r1=1.139&r2=1.140 |
13 |
|
14 |
Index: mysql.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v |
17 |
retrieving revision 1.139 |
18 |
retrieving revision 1.140 |
19 |
diff -p -w -b -B -u -u -r1.139 -r1.140 |
20 |
--- mysql.eclass 15 Mar 2010 19:27:04 -0000 1.139 |
21 |
+++ mysql.eclass 24 Mar 2010 03:09:08 -0000 1.140 |
22 |
@@ -1,6 +1,6 @@ |
23 |
# Copyright 1999-2009 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.139 2010/03/15 19:27:04 robbat2 Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.140 2010/03/24 03:09:08 robbat2 Exp $ |
27 |
|
28 |
# @ECLASS: mysql.eclass |
29 |
# @MAINTAINER: |
30 |
@@ -925,7 +925,9 @@ mysql_src_install() { |
31 |
fi |
32 |
|
33 |
# Configuration stuff |
34 |
- if mysql_version_is_at_least "4.1" ; then |
35 |
+ if mysql_version_is_at_least "5.1" ; then |
36 |
+ mysql_mycnf_version="5.1" |
37 |
+ elif mysql_version_is_at_least "4.1" ; then |
38 |
mysql_mycnf_version="4.1" |
39 |
else |
40 |
mysql_mycnf_version="4.0" |
41 |
@@ -937,7 +939,9 @@ mysql_src_install() { |
42 |
"${FILESDIR}/my.cnf-${mysql_mycnf_version}" \ |
43 |
> "${TMPDIR}/my.cnf.ok" |
44 |
if mysql_version_is_at_least "4.1" && use latin1 ; then |
45 |
- sed -e "s|utf8|latin1|g" -i "${TMPDIR}/my.cnf.ok" |
46 |
+ sed -i \ |
47 |
+ -e "/character-set/s|utf8|latin1|g" \ |
48 |
+ "${TMPDIR}/my.cnf.ok" |
49 |
fi |
50 |
newins "${TMPDIR}/my.cnf.ok" my.cnf |
51 |
|
52 |
@@ -1102,7 +1106,8 @@ mysql_pkg_config() { |
53 |
|
54 |
local pwd1="a" |
55 |
local pwd2="b" |
56 |
- local maxtry=5 |
57 |
+ local MYSQL_ROOT_PASSWORD='' |
58 |
+ local maxtry=15 |
59 |
|
60 |
if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
61 |
ewarn "You have already a MySQL database in place." |
62 |
@@ -1115,10 +1120,10 @@ mysql_pkg_config() { |
63 |
# localhost. Also causes weird failures. |
64 |
[[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
65 |
|
66 |
- einfo "Creating the mysql database and setting proper" |
67 |
- einfo "permissions on it ..." |
68 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
69 |
|
70 |
- einfo "Insert a password for the mysql 'root' user" |
71 |
+ einfo "Please provide a password for the mysql 'root' user now," |
72 |
+ einfo "or in the MYSQL_ROOT_PASSWORD env var." |
73 |
ewarn "Avoid [\"'\\_%] characters in the password" |
74 |
read -rsp " >" pwd1 ; echo |
75 |
|
76 |
@@ -1128,6 +1133,9 @@ mysql_pkg_config() { |
77 |
if [[ "x$pwd1" != "x$pwd2" ]] ; then |
78 |
die "Passwords are not the same" |
79 |
fi |
80 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
81 |
+ unset pwd1 pwd2 |
82 |
+ fi |
83 |
|
84 |
local options="" |
85 |
local sqltmp="$(emktemp)" |
86 |
@@ -1150,9 +1158,20 @@ mysql_pkg_config() { |
87 |
chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
88 |
chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
89 |
|
90 |
- if mysql_version_is_at_least "4.1.3" ; then |
91 |
- options="--skip-ndbcluster" |
92 |
+ # Figure out which options we need to disable to do the setup |
93 |
+ helpfile="${TMPDIR}/mysqld-help" |
94 |
+ ${ROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
95 |
+ for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
96 |
+ federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
97 |
+ ; do |
98 |
+ optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
99 |
+ egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
100 |
+ done |
101 |
+ # But some options changed names |
102 |
+ egrep -sq external-locking "${helpfile}" && \ |
103 |
+ options="${options/skip-locking/skip-external-locking}" |
104 |
|
105 |
+ if mysql_version_is_at_least "4.1.3" ; then |
106 |
# Filling timezones, see |
107 |
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
108 |
"${ROOT}/usr/bin/mysql_tzinfo_to_sql" "${ROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
109 |
@@ -1162,48 +1181,59 @@ mysql_pkg_config() { |
110 |
fi |
111 |
fi |
112 |
|
113 |
+ einfo "Creating the mysql database and setting proper" |
114 |
+ einfo "permissions on it ..." |
115 |
+ |
116 |
local socket="${ROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
117 |
local pidfile="${ROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
118 |
local mysqld="${ROOT}/usr/sbin/mysqld \ |
119 |
${options} \ |
120 |
--user=mysql \ |
121 |
- --skip-grant-tables \ |
122 |
--basedir=${ROOT}/usr \ |
123 |
--datadir=${ROOT}/${MY_DATADIR} \ |
124 |
- --skip-innodb \ |
125 |
- --skip-bdb \ |
126 |
- --skip-networking \ |
127 |
--max_allowed_packet=8M \ |
128 |
--net_buffer_length=16K \ |
129 |
--socket=${socket} \ |
130 |
--pid-file=${pidfile}" |
131 |
+ #einfo "About to start mysqld: ${mysqld}" |
132 |
+ ebegin "Starting mysqld" |
133 |
${mysqld} & |
134 |
+ rc=$? |
135 |
while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
136 |
maxtry=$((${maxtry}-1)) |
137 |
echo -n "." |
138 |
sleep 1 |
139 |
done |
140 |
+ eend $rc |
141 |
+ |
142 |
+ if ! [[ -S "${socket}" ]]; then |
143 |
+ die "Completely failed to start up mysqld with: ${mysqld}" |
144 |
+ fi |
145 |
|
146 |
+ ebegin "Setting root password" |
147 |
# Do this from memory, as we don't want clear text passwords in temp files |
148 |
- local sql="UPDATE mysql.user SET Password = PASSWORD('${pwd1}') WHERE USER='root'" |
149 |
+ local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
150 |
"${ROOT}/usr/bin/mysql" \ |
151 |
--socket=${socket} \ |
152 |
-hlocalhost \ |
153 |
-e "${sql}" |
154 |
+ eend $? |
155 |
|
156 |
- einfo "Loading \"zoneinfo\", this step may require a few seconds ..." |
157 |
- |
158 |
+ ebegin "Loading \"zoneinfo\", this step may require a few seconds ..." |
159 |
"${ROOT}/usr/bin/mysql" \ |
160 |
--socket=${socket} \ |
161 |
-hlocalhost \ |
162 |
-uroot \ |
163 |
- -p"${pwd1}" \ |
164 |
+ -p"${MYSQL_ROOT_PASSWORD}" \ |
165 |
mysql < "${sqltmp}" |
166 |
+ rc=$? |
167 |
+ eend $? |
168 |
+ [ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!" |
169 |
|
170 |
# Stop the server and cleanup |
171 |
+ einfo "Stopping the server ..." |
172 |
kill $(< "${pidfile}" ) |
173 |
rm -f "${sqltmp}" |
174 |
- einfo "Stopping the server ..." |
175 |
wait %1 |
176 |
einfo "Done" |
177 |
} |