1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
#!/bin/sh
# Create a bug report and mail it to the mysql mailing list
# Based on glibc bug reporting script.
echo "Finding system information for a MySQL bug report"
VERSION="@VERSION@@MYSQL_SERVER_SUFFIX@"
COMPILATION_COMMENT="@COMPILATION_COMMENT@"
BUGmysql="mysql@lists.mysql.com"
# This is set by configure
COMP_ENV_INFO="CC='@CC@' CFLAGS='@CFLAGS@' CXX='@CXX@' CXXFLAGS='@CXXFLAGS@' LDFLAGS='@LDFLAGS@' ASFLAGS='@ASFLAGS@'"
CONFIGURE_LINE="@CONF_COMMAND@"
LIBC_INFO=""
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
do
TMP=`ls -l $pat 2>/dev/null`
if test $? = 0
then
LIBC_INFO="$LIBC_INFO
$TMP"
fi
done
PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
export PATH
BUGADDR=${1-$BUGmysql}
ENVIRONMENT=`uname -a`
: ${USER=${LOGNAME-`whoami`}}
COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`
# Try to create a secure tmpfile
umask 077
TEMPDIR=/tmp/mysqlbug-$$
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
TEMP=${TEMPDIR}/mysqlbug
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0
# How to read the passwd database.
PASSWD="cat /etc/passwd"
if test -f /usr/lib/sendmail
then
MAIL_AGENT="/usr/lib/sendmail -oi -t"
elif test -f /usr/sbin/sendmail
then
MAIL_AGENT="/usr/sbin/sendmail -oi -t"
else
MAIL_AGENT="rmail $BUGmysql"
fi
# Figure out how to echo a string without a trailing newline
N=`echo 'hi there\c'`
case "$N" in
*c) ECHON1='echo -n' ECHON2= ;;
*) ECHON1=echo ECHON2='\c' ;;
esac
# Find out the name of the originator of this PR.
if test -n "$NAME"
then
ORIGINATOR="$NAME"
elif test -f $HOME/.fullname
then
ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
else
# Must use temp file due to incompatibilities in quoting behavior
# and to protect shell metacharacters in the expansion of $LOGNAME
$PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
ORIGINATOR="`cat $TEMP`"
rm -f $TEMP
fi
if test -n "$ORGANIZATION"
then
if test -f "$ORGANIZATION"
then
ORGANIZATION="`cat $ORGANIZATION`"
fi
else
if test -f $HOME/.organization
then
ORGANIZATION="`cat $HOME/.organization`"
elif test -f $HOME/.signature
then
ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"`
fi
fi
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
which_1 ()
{
for cmd
do
# Absolute path ?.
if expr "x$cmd" : "x/" > /dev/null
then
echo "$cmd"
exit 0
else
for d in $PATH_DIRS
do
file="$d/$cmd"
if test -x "$file" -a ! -d "$file"
then
echo "$file"
exit 0
fi
done
fi
done
exit 1
}
change_editor ()
{
echo "You can change editor by setting the environment variable VISUAL."
echo "If your shell is a bourne shell (sh) do"
echo "VISUAL=your_editors_name; export VISUAL"
echo "If your shell is a C shell (csh) do"
echo "setenv VISUAL your_editors_name"
}
# If they don't have a preferred editor set, then use emacs
if test -z "$VISUAL"
then
if test -z "$EDITOR"
then
EDIT=emacs
else
EDIT="$EDITOR"
fi
else
EDIT="$VISUAL"
fi
#which_1 $EDIT
used_editor=`which_1 $EDIT`
echo "test -x $used_editor"
if test -x "$used_editor"
then
echo "Using editor $used_editor";
change_editor
sleep 2
else
echo "Could not find a text editor. (tried $EDIT)"
change_editor
exit 1
fi
# Find out some information.
SYSTEM=`( test -f /bin/uname && /bin/uname -a ) || \
( test -f /usr/bin/uname && /usr/bin/uname -a ) || echo ""`
ARCH=`test -f /bin/arch && /bin/arch`
MACHINE=`test -f /bin/machine && /bin/machine`
FILE_PATHS=
for cmd in perl make gmake gcc cc
do
file=`which_1 $cmd`
if test $? = 0
then
if test $cmd = "gcc"
then
GCC_INFO=`$file -v 2>&1`
elif test $cmd = "perl"
then
PERL_INFO=`$file -v | grep -i version 2>&1`
fi
FILE_PATHS="$FILE_PATHS $file"
fi
done
admin=`which_1 mysqladmin`
MYSQL_SERVER=
if test -x "$admin"
then
MYSQL_SERVER=`$admin version 2> /dev/null`
if test "$?" = "1"
then
MYSQL_SERVER=""
fi
fi
SUBJECT_C="[50 character or so descriptive subject here (for reference)]"
ORGANIZATION_C='<organization of PR author (multiple lines)>'
LICENCE_C='[none | licence | email support | extended email support ]'
SYNOPSIS_C='<synopsis of the problem (one line)>'
SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
PRIORITY_C='<[ low | medium | high ] (one line)>'
CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
RELEASE_C='<release number or tag (one line)>'
ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
DESCRIPTION_C='<precise description of the problem (multiple lines)>'
HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
cat > $TEMP <<EOF
SEND-PR: -*- send-pr -*-
SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
SEND-PR: will all comments (text enclosed in \`<' and \`>').
SEND-PR:
From: ${USER}
To: ${BUGADDR}
Subject: $SUBJECT_C
>Description:
$DESCRIPTION_C
>How-To-Repeat:
$HOW_TO_REPEAT_C
>Fix:
$FIX_C
>Submitter-Id: <submitter ID>
>Originator: ${ORIGINATOR}
>Organization:
${ORGANIZATION- $ORGANIZATION_C}
>MySQL support: $LICENCE_C
>Synopsis: $SYNOPSIS_C
>Severity: $SEVERITY_C
>Priority: $PRIORITY_C
>Category: mysql
>Class: $CLASS_C
>Release: mysql-${VERSION} ($COMPILATION_COMMENT)
`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
>C compiler: @CC_VERSION@
>C++ compiler: @CXX_VERSION@
>Environment:
$ENVIRONMENT_C
`test -n "$SYSTEM" && echo "System: $SYSTEM"`
`test -n "$ARCH" && echo "Architecture: $ARCH"`
`test -n "$MACHINE" && echo "Machine: $MACHINE"`
`test -n "$FILE_PATHS" && echo "Some paths: $FILE_PATHS"`
`test -n "$GCC_INFO" && echo "GCC: $GCC_INFO"`
`test -n "$COMP_ENV_INFO" && echo "Compilation info: $COMP_ENV_INFO"`
`test -n "$LIBC_INFO" && echo "LIBC: $LIBC_INFO"`
`test -n "$CONFIGURE_LINE" && echo "Configure command: $CONFIGURE_LINE"`
`test -n "$PERL_INFO" && echo "Perl: $PERL_INFO"`
EOF
chmod u+w $TEMP
cp $TEMP $TEMP.x
eval $EDIT $TEMP
if cmp -s $TEMP $TEMP.x
then
echo "File not changed, no bug report submitted."
mv -f $TEMP /tmp/failed-mysql-bugreport
echo "The raw bug report exists in /tmp/failed-mysql-bugreport"
echo "If you use this remember that the first lines of the report are now a lie.."
exit 1
fi
#
# Check the enumeration fields
# This is a "sed-subroutine" with one keyword parameter
# (with workaround for Sun sed bug)
#
SED_CMD='
/$PATTERN/{
s|||
s|<.*>||
s|^[ ]*||
s|[ ]*$||
p
q
}'
while :; do
CNT=0
#
# 1) Severity
#
PATTERN=">Severity:"
SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
case "$SEVERITY" in
""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
*) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
esac
#
# 2) Priority
#
PATTERN=">Priority:"
PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
case "$PRIORITY" in
""|low|medium|high) CNT=`expr $CNT + 1` ;;
*) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
esac
#
# 3) Class
#
PATTERN=">Class:"
CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
case "$CLASS" in
""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
*) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
esac
#
# 4) Synopsis
#
VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[ ]*//'`
case "$VALUE" in
"$SYNOPSIS_C") echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;;
*) CNT=`expr $CNT + 1`
esac
test $CNT -lt 4 &&
echo "Errors were found with the problem report."
# Check if subject of mail was changed, if not, use Synopsis field
#
subject=`grep "^Subject" $TEMP| sed 's/^Subject:[ ]*//'`
if [ X"$subject" = X"$SUBJECT_C" -o X"$subject" = X"$SYNOPSIS_C" ]; then
subject=`grep Synopsis $TEMP | sed 's/>Synopsis:[ ]*//'`
sed "s/^Subject:[ ]*.*/Subject: $subject/" $TEMP > $TEMP.tmp
mv -f $TEMP.tmp $TEMP
fi
while :; do
$ECHON1 "a)bort, e)dit or s)end? $ECHON2"
read input
case "$input" in
a*)
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
cat $TEMP >> $HOME/dead.mysqlbug
xs=1; exit
;;
e*)
eval $EDIT $TEMP
continue 2
;;
s*)
break 2
;;
esac
done
done
#
# Remove comments and send the problem report
# (we have to use patterns, where the comment contains regex chars)
#
# /^>Originator:/s;$ORIGINATOR;;
sed -e "
/^SEND-PR:/d
/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
/^>Confidential:/s;<.*>;;
/^>Synopsis:/s;$SYNOPSIS_C;;
/^>Severity:/s;<.*>;;
/^>Priority:/s;<.*>;;
/^>Class:/s;<.*>;;
/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
" $TEMP > $TEMP.x
if $MAIL_AGENT < $TEMP.x
then
echo "$COMMAND: problem report sent"
xs=0; exit
else
echo "$COMMAND: mysterious mail failure, report not sent."
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
cat $TEMP >> $HOME/dead.mysqlbug
fi
exit 0
|