2
# Copyright (C) 2000-2002, 2004 MySQL AB
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
# Create a bug report and mail it to the mysql mailing list
18
# Based on glibc bug reporting script.
20
echo "Finding system information for a MySQL bug report"
22
VERSION="@VERSION@@MYSQL_SERVER_SUFFIX@"
23
COMPILATION_COMMENT="@COMPILATION_COMMENT@"
24
BUGmysql="mysql@lists.mysql.com"
25
# This is set by configure
26
COMP_CALL_INFO="CC='@SAVE_CC@' CFLAGS='@SAVE_CFLAGS@' CXX='@SAVE_CXX@' CXXFLAGS='@SAVE_CXXFLAGS@' LDFLAGS='@SAVE_LDFLAGS@' ASFLAGS='@SAVE_ASFLAGS@'"
27
COMP_RUN_INFO="CC='@CC@' CFLAGS='@CFLAGS@' CXX='@CXX@' CXXFLAGS='@CXXFLAGS@' LDFLAGS='@LDFLAGS@' ASFLAGS='@ASFLAGS@'"
28
CONFIGURE_LINE="@CONF_COMMAND@"
31
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
33
TMP=`ls -l $pat 2>/dev/null`
41
PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
44
BUGADDR=${1-$BUGmysql}
45
ENVIRONMENT=`uname -a`
47
: ${USER=${LOGNAME-`whoami`}}
49
COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`
51
# Try to create a secure tmpfile
53
TEMPDIR=/tmp/mysqlbug-$$
54
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
55
TEMP=${TEMPDIR}/mysqlbug
57
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15
58
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0
60
# How to read the passwd database.
61
PASSWD="cat /etc/passwd"
63
if test -f /usr/lib/sendmail
65
MAIL_AGENT="/usr/lib/sendmail -oi -t"
66
elif test -f /usr/sbin/sendmail
68
MAIL_AGENT="/usr/sbin/sendmail -oi -t"
70
MAIL_AGENT="rmail $BUGmysql"
73
# Figure out how to echo a string without a trailing newline
76
*c) ECHON1='echo -n' ECHON2= ;;
77
*) ECHON1=echo ECHON2='\c' ;;
80
# Find out the name of the originator of this PR.
84
elif test -f $HOME/.fullname
86
ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
88
# Must use temp file due to incompatibilities in quoting behavior
89
# and to protect shell metacharacters in the expansion of $LOGNAME
90
$PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
91
ORIGINATOR="`cat $TEMP`"
95
if test -n "$ORGANIZATION"
97
if test -f "$ORGANIZATION"
99
ORGANIZATION="`cat $ORGANIZATION`"
102
if test -f $HOME/.organization
104
ORGANIZATION="`cat $HOME/.organization`"
105
elif test -f $HOME/.signature
107
ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"`
111
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
118
if expr "x$cmd" : "x/" > /dev/null
126
if test -x "$file" -a ! -d "$file"
139
echo "You can change editor by setting the environment variable VISUAL."
140
echo "If your shell is a bourne shell (sh) do"
141
echo "VISUAL=your_editors_name; export VISUAL"
142
echo "If your shell is a C shell (csh) do"
143
echo "setenv VISUAL your_editors_name"
146
# If they don't have a preferred editor set, then use emacs
151
# Honor debian sensible-editor
152
if test -x "/usr/bin/sensible-editor"
154
EDIT=/usr/bin/sensible-editor
166
used_editor=`which_1 $EDIT`
168
echo "test -x $used_editor"
169
if test -x "$used_editor"
171
echo "Using editor $used_editor";
175
echo "Could not find a text editor. (tried $EDIT)"
180
# Find out some information.
181
SYSTEM=`( test -f /bin/uname && /bin/uname -a ) || \
182
( test -f /usr/bin/uname && /usr/bin/uname -a ) || echo ""`
183
ARCH=`test -f /bin/arch && /bin/arch`
184
MACHINE=`test -f /bin/machine && /bin/machine`
187
for cmd in perl make gmake gcc cc
194
GCC_INFO=`$file -v 2>&1`
195
elif test $cmd = "perl"
197
PERL_INFO=`$file -v | grep -i version 2>&1`
199
FILE_PATHS="$FILE_PATHS $file"
203
admin=`which_1 mysqladmin`
207
MYSQL_SERVER=`$admin version 2> /dev/null`
214
SUBJECT_C="[50 character or so descriptive subject here (for reference)]"
215
ORGANIZATION_C='<organization of PR author (multiple lines)>'
216
LICENCE_C='[none | licence | email support | extended email support ]'
217
SYNOPSIS_C='<synopsis of the problem (one line)>'
218
SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
219
PRIORITY_C='<[ low | medium | high ] (one line)>'
220
CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
221
RELEASE_C='<release number or tag (one line)>'
222
ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
223
DESCRIPTION_C='<precise description of the problem (multiple lines)>'
224
HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
225
FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
229
SEND-PR: -*- send-pr -*-
230
SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
231
SEND-PR: will all comments (text enclosed in \`<' and \`>').
244
>Submitter-Id: <submitter ID>
245
>Originator: ${ORIGINATOR}
247
${ORGANIZATION- $ORGANIZATION_C}
248
>MySQL support: $LICENCE_C
249
>Synopsis: $SYNOPSIS_C
250
>Severity: $SEVERITY_C
251
>Priority: $PRIORITY_C
254
>Release: mysql-${VERSION} ($COMPILATION_COMMENT)
255
`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
256
>C compiler: @CC_VERSION@
257
>C++ compiler: @CXX_VERSION@
260
`test -n "$SYSTEM" && echo "System: $SYSTEM"`
261
`test -n "$ARCH" && echo "Architecture: $ARCH"`
262
`test -n "$MACHINE" && echo "Machine: $MACHINE"`
263
`test -n "$FILE_PATHS" && echo "Some paths: $FILE_PATHS"`
264
`test -n "$GCC_INFO" && echo "GCC: $GCC_INFO"`
265
`test -n "$COMP_CALL_INFO" && echo "Compilation info (call): $COMP_CALL_INFO"`
266
`test -n "$COMP_RUN_INFO" && echo "Compilation info (used): $COMP_RUN_INFO"`
267
`test -n "$LIBC_INFO" && echo "LIBC: $LIBC_INFO"`
268
`test -n "$CONFIGURE_LINE" && echo "Configure command: $CONFIGURE_LINE"`
269
`test -n "$PERL_INFO" && echo "Perl: $PERL_INFO"`
277
if cmp -s $TEMP $TEMP.x
279
echo "File not changed, no bug report submitted."
280
mv -f $TEMP /tmp/failed-mysql-bugreport
281
echo "The raw bug report exists in /tmp/failed-mysql-bugreport"
282
echo "If you use this remember that the first lines of the report are now a lie.."
287
# Check the enumeration fields
289
# This is a "sed-subroutine" with one keyword parameter
290
# (with workaround for Sun sed bug)
310
SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
312
""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
313
*) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
319
PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
321
""|low|medium|high) CNT=`expr $CNT + 1` ;;
322
*) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
328
CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
330
""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
331
*) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
337
VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[ ]*//'`
339
"$SYNOPSIS_C") echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;;
340
*) CNT=`expr $CNT + 1`
344
echo "Errors were found with the problem report."
347
# Check if subject of mail was changed, if not, use Synopsis field
349
subject=`grep "^Subject" $TEMP| sed 's/^Subject:[ ]*//'`
350
if [ X"$subject" = X"$SUBJECT_C" -o X"$subject" = X"$SYNOPSIS_C" ]; then
351
subject=`grep Synopsis $TEMP | sed 's/>Synopsis:[ ]*//'`
352
sed "s/^Subject:[ ]*.*/Subject: $subject/" $TEMP > $TEMP.tmp
353
mv -f $TEMP.tmp $TEMP
357
$ECHON1 "a)bort, e)dit or s)end? $ECHON2"
361
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
362
cat $TEMP >> $HOME/dead.mysqlbug
376
# Remove comments and send the problem report
377
# (we have to use patterns, where the comment contains regex chars)
379
# /^>Originator:/s;$ORIGINATOR;;
382
/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
383
/^>Confidential:/s;<.*>;;
384
/^>Synopsis:/s;$SYNOPSIS_C;;
385
/^>Severity:/s;<.*>;;
386
/^>Priority:/s;<.*>;;
388
/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
389
/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
390
/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
391
/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
392
/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
395
if $MAIL_AGENT < $TEMP.x
397
echo "$COMMAND: problem report sent"
400
echo "$COMMAND: mysterious mail failure, report not sent."
401
echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
402
cat $TEMP >> $HOME/dead.mysqlbug