2
# Create a bug report and mail it to the mysql mailing list
3
# Based on glibc bug reporting script.
5
echo "Finding system information for a MySQL bug report"
8
COMPILATION_COMMENT="Source distribution"
9
BUGmysql="mysql@lists.mysql.com"
10
# This is set by configure
11
COMP_ENV_INFO="CC='gcc' CFLAGS='-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -mcpu=pentiumpro -O3 -fno-omit-frame-pointer' CXX='gcc' CXXFLAGS='-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -mcpu=pentiumpro -O3 -fno-omit-frame-pointer' LDFLAGS=''"
12
CONFIGURE_LINE="./configure '--prefix=/usr/local/mysql' '--enable-assembler' '--with-extra-charsets=complex' '--enable-thread-safe-client' '--with-innodb' '--with-berkeley-db' 'CFLAGS=-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -mcpu=pentiumpro -O3 -fno-omit-frame-pointer' 'CXXFLAGS=-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -mcpu=pentiumpro -O3 -fno-omit-frame-pointer' 'CXX=gcc'"
15
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
17
TMP=`ls -l $pat 2>/dev/null`
25
PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
28
BUGADDR=${1-$BUGmysql}
29
ENVIRONMENT=`uname -a`
31
: ${USER=${LOGNAME-`whoami`}}
33
COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`
35
# Try to create a secure tmpfile
37
TEMPDIR=/tmp/mysqlbug-$$
38
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
39
TEMP=${TEMPDIR}/mysqlbug
41
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15
42
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0
44
# How to read the passwd database.
45
PASSWD="cat /etc/passwd"
47
if test -f /usr/lib/sendmail
49
MAIL_AGENT="/usr/lib/sendmail -oi -t"
50
elif test -f /usr/sbin/sendmail
52
MAIL_AGENT="/usr/sbin/sendmail -oi -t"
54
MAIL_AGENT="rmail $BUGmysql"
57
# Figure out how to echo a string without a trailing newline
60
*c) ECHON1='echo -n' ECHON2= ;;
61
*) ECHON1=echo ECHON2='\c' ;;
64
# Find out the name of the originator of this PR.
68
elif test -f $HOME/.fullname
70
ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
72
# Must use temp file due to incompatibilities in quoting behavior
73
# and to protect shell metacharacters in the expansion of $LOGNAME
74
$PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
75
ORIGINATOR="`cat $TEMP`"
79
if test -n "$ORGANIZATION"
81
if test -f "$ORGANIZATION"
83
ORGANIZATION="`cat $ORGANIZATION`"
86
if test -f $HOME/.organization
88
ORGANIZATION="`cat $HOME/.organization`"
89
elif test -f $HOME/.signature
91
ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"`
95
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
102
if expr "x$cmd" : "x/" > /dev/null
110
if test -x "$file" -a ! -d "$file"
123
echo "You can change editor by setting the environment variable VISUAL."
124
echo "If your shell is a bourne shell (sh) do"
125
echo "VISUAL=your_editors_name; export VISUAL"
126
echo "If your shell is a C shell (csh) do"
127
echo "setenv VISUAL your_editors_name"
130
# If they don't have a preferred editor set, then use emacs
144
used_editor=`which_1 $EDIT`
146
echo "test -x $used_editor"
147
if test -x "$used_editor"
149
echo "Using editor $used_editor";
153
echo "Could not find a text editor. (tried $EDIT)"
158
# Find out some information.
159
SYSTEM=`( test -f /bin/uname && /bin/uname -a ) || \
160
( test -f /usr/bin/uname && /usr/bin/uname -a ) || echo ""`
161
ARCH=`test -f /bin/arch && /bin/arch`
162
MACHINE=`test -f /bin/machine && /bin/machine`
165
for cmd in perl make gmake gcc cc
172
GCC_INFO=`$file -v 2>&1`
173
elif test $cmd = "perl"
175
PERL_INFO=`$file -v | grep -i version 2>&1`
177
FILE_PATHS="$FILE_PATHS $file"
181
admin=`which_1 mysqladmin`
185
MYSQL_SERVER=`$admin version 2> /dev/null`
192
SUBJECT_C="[50 character or so descriptive subject here (for reference)]"
193
ORGANIZATION_C='<organization of PR author (multiple lines)>'
194
LICENCE_C='[none | licence | email support | extended email support ]'
195
SYNOPSIS_C='<synopsis of the problem (one line)>'
196
SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
197
PRIORITY_C='<[ low | medium | high ] (one line)>'
198
CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
199
RELEASE_C='<release number or tag (one line)>'
200
ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
201
DESCRIPTION_C='<precise description of the problem (multiple lines)>'
202
HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
203
FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
207
SEND-PR: -*- send-pr -*-
208
SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
209
SEND-PR: will all comments (text enclosed in \`<' and \`>').
222
>Submitter-Id: <submitter ID>
223
>Originator: ${ORIGINATOR}
225
${ORGANIZATION- $ORGANIZATION_C}
226
>MySQL support: $LICENCE_C
227
>Synopsis: $SYNOPSIS_C
228
>Severity: $SEVERITY_C
229
>Priority: $PRIORITY_C
232
>Release: mysql-${VERSION} ($COMPILATION_COMMENT)
233
`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
236
`test -n "$SYSTEM" && echo "System: $SYSTEM"`
237
`test -n "$ARCH" && echo "Architecture: $ARCH"`
238
`test -n "$MACHINE" && echo "Machine: $MACHINE"`
239
`test -n "$FILE_PATHS" && echo "Some paths: $FILE_PATHS"`
240
`test -n "$GCC_INFO" && echo "GCC: $GCC_INFO"`
241
`test -n "$COMP_ENV_INFO" && echo "Compilation info: $COMP_ENV_INFO"`
242
`test -n "$LIBC_INFO" && echo "LIBC: $LIBC_INFO"`
243
`test -n "$CONFIGURE_LINE" && echo "Configure command: $CONFIGURE_LINE"`
244
`test -n "$PERL_INFO" && echo "Perl: $PERL_INFO"`
252
if cmp -s $TEMP $TEMP.x
254
echo "File not changed, no bug report submitted."
255
cp $TEMP /tmp/failed-mysql-bugreport
256
echo "The raw bug report exists in /tmp/failed-mysql-bugreport"
257
echo "If you use this remember that the first lines of the report now is a lie.."
262
# Check the enumeration fields
264
# This is a "sed-subroutine" with one keyword parameter
265
# (with workaround for Sun sed bug)
285
SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
287
""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
288
*) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
294
PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
296
""|low|medium|high) CNT=`expr $CNT + 1` ;;
297
*) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
303
CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
305
""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
306
*) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
312
VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[ ]*//'`
314
"$SYNOPSIS_C") echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;;
315
*) CNT=`expr $CNT + 1`
319
echo "Errors were found with the problem report."
322
# Check if subject of mail was changed, if not, use Synopsis field
324
subject=`grep "^Subject" $TEMP| sed 's/^Subject:[ ]*//'`
325
if [ X"$subject" = X"$SUBJECT_C" -o X"$subject" = X"$SYNOPSIS_C" ]; then
326
subject=`grep Synopsis $TEMP | sed 's/>Synopsis:[ ]*//'`
327
sed "s/^Subject:[ ]*.*/Subject: $subject/" $TEMP > $TEMP.tmp
328
mv -f $TEMP.tmp $TEMP
332
$ECHON1 "a)bort, e)dit or s)end? $ECHON2"
336
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
337
cat $TEMP >> $HOME/dead.mysqlbug
351
# Remove comments and send the problem report
352
# (we have to use patterns, where the comment contains regex chars)
354
# /^>Originator:/s;$ORIGINATOR;;
357
/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
358
/^>Confidential:/s;<.*>;;
359
/^>Synopsis:/s;$SYNOPSIS_C;;
360
/^>Severity:/s;<.*>;;
361
/^>Priority:/s;<.*>;;
363
/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
364
/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
365
/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
366
/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
367
/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
370
if $MAIL_AGENT < $TEMP.x
372
echo "$COMMAND: problem report sent"
375
echo "$COMMAND: mysterious mail failure, report not sent."
376
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
377
cat $TEMP >> $HOME/dead.mysqlbug