1 |
commit: f73d71536e2fa0c17c523b3b57c4dfe488b63ad5 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Nov 1 20:13:25 2012 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Nov 1 20:19:29 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/mysql.git;a=commit;h=f73d7153 |
7 |
|
8 |
Bring in improved pkg_config block to fix bug #392361. |
9 |
|
10 |
--- |
11 |
eclass/mysql-v2.eclass | 94 +++++++++++++++++++++++++++++++++++++----------- |
12 |
eclass/mysql.eclass | 92 ++++++++++++++++++++++++++++++++++++----------- |
13 |
2 files changed, 144 insertions(+), 42 deletions(-) |
14 |
|
15 |
diff --git a/eclass/mysql-v2.eclass b/eclass/mysql-v2.eclass |
16 |
index 4c8d635..685b444 100644 |
17 |
--- a/eclass/mysql-v2.eclass |
18 |
+++ b/eclass/mysql-v2.eclass |
19 |
@@ -528,12 +528,35 @@ mysql-v2_pkg_postinst() { |
20 |
&& elog "Berkeley DB support is deprecated and will be removed in future versions!" |
21 |
} |
22 |
|
23 |
+# @FUNCTION: mysql-v2_getopt |
24 |
+# @DESCRIPTION: |
25 |
+# Use my_print_defaults to extract specific config options |
26 |
+mysql-v2_getopt() { |
27 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
28 |
+ section="$1" |
29 |
+ flag="--${2}=" |
30 |
+ "${mypd}" $section | sed -n "/^${flag}/p" |
31 |
+} |
32 |
+ |
33 |
+# @FUNCTION: mysql-v2_getoptval |
34 |
+# @DESCRIPTION: |
35 |
+# Use my_print_defaults to extract specific config options |
36 |
+mysql-v2_getoptval() { |
37 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
38 |
+ section="$1" |
39 |
+ flag="--${2}=" |
40 |
+ "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp" |
41 |
+} |
42 |
+ |
43 |
# @FUNCTION: mysql-v2_pkg_config |
44 |
# @DESCRIPTION: |
45 |
# Configure mysql environment. |
46 |
mysql-v2_pkg_config() { |
47 |
|
48 |
local old_MY_DATADIR="${MY_DATADIR}" |
49 |
+ local old_HOME="${HOME}" |
50 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
51 |
+ export HOME=/root |
52 |
|
53 |
# Make sure the vars are correctly initialized |
54 |
mysql_init_vars |
55 |
@@ -547,10 +570,10 @@ mysql-v2_pkg_config() { |
56 |
if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then |
57 |
local MY_DATADIR_s="${ROOT}/${MY_DATADIR}" |
58 |
MY_DATADIR_s="${MY_DATADIR_s%%/}" |
59 |
- local old_MY_DATADIR_s="${ROOT}/old_MY_DATADIR}" |
60 |
+ local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" |
61 |
old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" |
62 |
|
63 |
- if [[ -d "${old_MY_DATADIR_s}" ]]; then |
64 |
+ if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then |
65 |
if [[ -d "${MY_DATADIR_s}" ]]; then |
66 |
ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" |
67 |
ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" |
68 |
@@ -574,8 +597,27 @@ mysql-v2_pkg_config() { |
69 |
local pwd2="b" |
70 |
local maxtry=15 |
71 |
|
72 |
- if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then |
73 |
- MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")" |
74 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
75 |
+ MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)" |
76 |
+ fi |
77 |
+ MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)" |
78 |
+ # These are dir+prefix |
79 |
+ MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)" |
80 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
81 |
+ MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)" |
82 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
83 |
+ |
84 |
+ if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then |
85 |
+ einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" |
86 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR |
87 |
+ fi |
88 |
+ if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then |
89 |
+ einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" |
90 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN |
91 |
+ fi |
92 |
+ if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then |
93 |
+ einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" |
94 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG |
95 |
fi |
96 |
|
97 |
if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
98 |
@@ -606,7 +648,7 @@ mysql-v2_pkg_config() { |
99 |
unset pwd1 pwd2 |
100 |
fi |
101 |
|
102 |
- local options="" |
103 |
+ local options="--log-warnings=0" |
104 |
local sqltmp="$(emktemp)" |
105 |
|
106 |
local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" |
107 |
@@ -614,33 +656,41 @@ mysql-v2_pkg_config() { |
108 |
&& cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
109 |
|| touch "${TMPDIR}/fill_help_tables.sql" |
110 |
help_tables="${TMPDIR}/fill_help_tables.sql" |
111 |
- |
112 |
- pushd "${TMPDIR}" &>/dev/null |
113 |
- "${EROOT}/usr/bin/mysql_install_db" "--basedir=${EPREFIX}/usr" >"${TMPDIR}"/mysql_install_db.log 2>&1 |
114 |
- if [ $? -ne 0 ]; then |
115 |
- grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
116 |
- die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
117 |
- fi |
118 |
- popd &>/dev/null |
119 |
- [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
120 |
- || die "MySQL databases not installed" |
121 |
- chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
122 |
- chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
123 |
- |
124 |
+ |
125 |
# Figure out which options we need to disable to do the setup |
126 |
helpfile="${TMPDIR}/mysqld-help" |
127 |
${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
128 |
for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
129 |
federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
130 |
- ndbcluster \ |
131 |
+ ndbcluster log-slave-updates \ |
132 |
; do |
133 |
- optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
134 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
135 |
egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
136 |
done |
137 |
# But some options changed names |
138 |
egrep -sq external-locking "${helpfile}" && \ |
139 |
options="${options/skip-locking/skip-external-locking}" |
140 |
|
141 |
+ use prefix || options="${options} --user=mysql" |
142 |
+ |
143 |
+ pushd "${TMPDIR}" &>/dev/null |
144 |
+ #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}" |
145 |
+ cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db |
146 |
+ [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db |
147 |
+ cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}" |
148 |
+ einfo "Command: $cmd" |
149 |
+ eval $cmd \ |
150 |
+ >"${TMPDIR}"/mysql_install_db.log 2>&1 |
151 |
+ if [ $? -ne 0 ]; then |
152 |
+ grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
153 |
+ die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
154 |
+ fi |
155 |
+ popd &>/dev/null |
156 |
+ [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
157 |
+ || die "MySQL databases not installed" |
158 |
+ chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
159 |
+ chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
160 |
+ |
161 |
# Filling timezones, see |
162 |
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
163 |
"${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
164 |
@@ -657,6 +707,7 @@ mysql-v2_pkg_config() { |
165 |
local mysqld="${EROOT}/usr/sbin/mysqld \ |
166 |
${options} \ |
167 |
--user=mysql \ |
168 |
+ --log-warnings=0 \ |
169 |
--basedir=${EROOT}/usr \ |
170 |
--datadir=${ROOT}/${MY_DATADIR} \ |
171 |
--max_allowed_packet=8M \ |
172 |
@@ -666,6 +717,7 @@ mysql-v2_pkg_config() { |
173 |
--pid-file=${pidfile}" |
174 |
#einfo "About to start mysqld: ${mysqld}" |
175 |
ebegin "Starting mysqld" |
176 |
+ einfo "Command ${mysqld}" |
177 |
${mysqld} & |
178 |
rc=$? |
179 |
while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
180 |
@@ -693,7 +745,7 @@ mysql-v2_pkg_config() { |
181 |
--socket=${socket} \ |
182 |
-hlocalhost \ |
183 |
-uroot \ |
184 |
- -p"${MYSQL_ROOT_PASSWORD}" \ |
185 |
+ --password="${MYSQL_ROOT_PASSWORD}" \ |
186 |
mysql < "${sqltmp}" |
187 |
rc=$? |
188 |
eend $? |
189 |
|
190 |
diff --git a/eclass/mysql.eclass b/eclass/mysql.eclass |
191 |
index f14023a..9ead224 100644 |
192 |
--- a/eclass/mysql.eclass |
193 |
+++ b/eclass/mysql.eclass |
194 |
@@ -1288,11 +1288,34 @@ mysql_pkg_postinst() { |
195 |
&& elog "Berkeley DB support is deprecated and will be removed in future versions!" |
196 |
} |
197 |
|
198 |
+# @FUNCTION: mysql_getopt |
199 |
+# @DESCRIPTION: |
200 |
+# Use my_print_defaults to extract specific config options |
201 |
+mysql_getopt() { |
202 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
203 |
+ section="$1" |
204 |
+ flag="--${2}=" |
205 |
+ "${mypd}" $section | sed -n "/^${flag}/p" |
206 |
+} |
207 |
+ |
208 |
+# @FUNCTION: mysql_getoptval |
209 |
+# @DESCRIPTION: |
210 |
+# Use my_print_defaults to extract specific config options |
211 |
+mysql_getoptval() { |
212 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
213 |
+ section="$1" |
214 |
+ flag="--${2}=" |
215 |
+ "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp" |
216 |
+} |
217 |
+ |
218 |
# @FUNCTION: mysql_pkg_config |
219 |
# @DESCRIPTION: |
220 |
# Configure mysql environment. |
221 |
mysql_pkg_config() { |
222 |
local old_MY_DATADIR="${MY_DATADIR}" |
223 |
+ local old_HOME="${HOME}" |
224 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
225 |
+ export HOME=/root |
226 |
|
227 |
# Make sure the vars are correctly initialized |
228 |
mysql_init_vars |
229 |
@@ -1309,7 +1332,7 @@ mysql_pkg_config() { |
230 |
local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" |
231 |
old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" |
232 |
|
233 |
- if [[ -d "${old_MY_DATADIR_s}" ]]; then |
234 |
+ if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then |
235 |
if [[ -d "${MY_DATADIR_s}" ]]; then |
236 |
ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" |
237 |
ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" |
238 |
@@ -1333,8 +1356,27 @@ mysql_pkg_config() { |
239 |
local pwd2="b" |
240 |
local maxtry=15 |
241 |
|
242 |
- if [ -z "${MYSQL_ROOT_PASSWORD}" -a -f "${EROOT}/root/.my.cnf" ]; then |
243 |
- MYSQL_ROOT_PASSWORD="$(sed -n -e '/^password=/s,^password=,,gp' "${EROOT}/root/.my.cnf")" |
244 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
245 |
+ MYSQL_ROOT_PASSWORD="$(mysql_getoptval 'client mysql' password)" |
246 |
+ fi |
247 |
+ MYSQL_TMPDIR="$(mysql_getoptval mysqld tmpdir)" |
248 |
+ # These are dir+prefix |
249 |
+ MYSQL_RELAY_LOG="$(mysql_getoptval mysqld relay-log)" |
250 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
251 |
+ MYSQL_LOG_BIN="$(mysql_getoptval mysqld log-bin)" |
252 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
253 |
+ |
254 |
+ if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then |
255 |
+ einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" |
256 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR |
257 |
+ fi |
258 |
+ if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then |
259 |
+ einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" |
260 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN |
261 |
+ fi |
262 |
+ if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then |
263 |
+ einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" |
264 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG |
265 |
fi |
266 |
|
267 |
if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
268 |
@@ -1365,7 +1407,7 @@ mysql_pkg_config() { |
269 |
unset pwd1 pwd2 |
270 |
fi |
271 |
|
272 |
- local options="" |
273 |
+ local options="--log-warnings=0" |
274 |
local sqltmp="$(emktemp)" |
275 |
|
276 |
local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" |
277 |
@@ -1374,32 +1416,40 @@ mysql_pkg_config() { |
278 |
|| touch "${TMPDIR}/fill_help_tables.sql" |
279 |
help_tables="${TMPDIR}/fill_help_tables.sql" |
280 |
|
281 |
- pushd "${TMPDIR}" &>/dev/null |
282 |
- "${EROOT}/usr/bin/mysql_install_db" >"${TMPDIR}"/mysql_install_db.log 2>&1 |
283 |
- if [ $? -ne 0 ]; then |
284 |
- grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
285 |
- die "Failed to run mysql_install_db. Please review /var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
286 |
- fi |
287 |
- popd &>/dev/null |
288 |
- [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
289 |
- || die "MySQL databases not installed" |
290 |
- chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
291 |
- chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
292 |
- |
293 |
# Figure out which options we need to disable to do the setup |
294 |
helpfile="${TMPDIR}/mysqld-help" |
295 |
${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
296 |
for opt in grant-tables host-cache name-resolve networking slave-start bdb \ |
297 |
federated innodb ssl log-bin relay-log slow-query-log external-locking \ |
298 |
- ndbcluster \ |
299 |
+ ndbcluster log-slave-updates \ |
300 |
; do |
301 |
- optexp="--(skip-)?${opt}" optfull="--skip-${opt}" |
302 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
303 |
egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
304 |
done |
305 |
# But some options changed names |
306 |
egrep -sq external-locking "${helpfile}" && \ |
307 |
options="${options/skip-locking/skip-external-locking}" |
308 |
|
309 |
+ use prefix || options="${options} --user=mysql" |
310 |
+ |
311 |
+ pushd "${TMPDIR}" &>/dev/null |
312 |
+ #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}" |
313 |
+ cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db |
314 |
+ [ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db |
315 |
+ cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}" |
316 |
+ einfo "Command: $cmd" |
317 |
+ eval $cmd \ |
318 |
+ >"${TMPDIR}"/mysql_install_db.log 2>&1 |
319 |
+ if [ $? -ne 0 ]; then |
320 |
+ grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
321 |
+ die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
322 |
+ fi |
323 |
+ popd &>/dev/null |
324 |
+ [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
325 |
+ || die "MySQL databases not installed" |
326 |
+ chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
327 |
+ chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
328 |
+ |
329 |
if mysql_version_is_at_least "4.1.3" ; then |
330 |
# Filling timezones, see |
331 |
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
332 |
@@ -1413,13 +1463,12 @@ mysql_pkg_config() { |
333 |
einfo "Creating the mysql database and setting proper" |
334 |
einfo "permissions on it ..." |
335 |
|
336 |
- use prefix || options="${options} --user=mysql" |
337 |
- |
338 |
local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
339 |
local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
340 |
local mysqld="${EROOT}/usr/sbin/mysqld \ |
341 |
${options} \ |
342 |
--user=mysql \ |
343 |
+ --log-warnings=0 \ |
344 |
--basedir=${EROOT}/usr \ |
345 |
--datadir=${ROOT}/${MY_DATADIR} \ |
346 |
--max_allowed_packet=8M \ |
347 |
@@ -1429,6 +1478,7 @@ mysql_pkg_config() { |
348 |
--pid-file=${pidfile}" |
349 |
#einfo "About to start mysqld: ${mysqld}" |
350 |
ebegin "Starting mysqld" |
351 |
+ einfo "Command ${mysqld}" |
352 |
${mysqld} & |
353 |
rc=$? |
354 |
while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
355 |
@@ -1456,7 +1506,7 @@ mysql_pkg_config() { |
356 |
--socket=${socket} \ |
357 |
-hlocalhost \ |
358 |
-uroot \ |
359 |
- -p"${MYSQL_ROOT_PASSWORD}" \ |
360 |
+ --password="${MYSQL_ROOT_PASSWORD}" \ |
361 |
mysql < "${sqltmp}" |
362 |
rc=$? |
363 |
eend $? |