~ken-vandine/+junk/mysql-3.23.58

« back to all changes in this revision

Viewing changes to scripts/mysqlbug

  • Committer: Ken VanDine
  • Date: 2018-01-27 03:45:15 UTC
  • Revision ID: ken.vandine@canonical.com-20180127034515-wpgsf0e7g0dq3qhv
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Create a bug report and mail it to the mysql mailing list
 
3
# Based on glibc bug reporting script.
 
4
 
 
5
echo "Finding system information for a MySQL bug report"
 
6
 
 
7
VERSION="3.23.58"
 
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'"
 
13
 
 
14
LIBC_INFO=""
 
15
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
 
16
do
 
17
    TMP=`ls -l $pat 2>/dev/null`
 
18
    if test $? = 0
 
19
    then
 
20
      LIBC_INFO="$LIBC_INFO
 
21
$TMP"
 
22
    fi
 
23
done
 
24
 
 
25
PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
 
26
export PATH
 
27
 
 
28
BUGADDR=${1-$BUGmysql}
 
29
ENVIRONMENT=`uname -a`
 
30
 
 
31
: ${USER=${LOGNAME-`whoami`}}
 
32
 
 
33
COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`
 
34
 
 
35
# Try to create a secure tmpfile
 
36
umask 077
 
37
TEMPDIR=/tmp/mysqlbug-$$
 
38
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
 
39
TEMP=${TEMPDIR}/mysqlbug
 
40
 
 
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
 
43
 
 
44
# How to read the passwd database.
 
45
PASSWD="cat /etc/passwd"
 
46
 
 
47
if test -f /usr/lib/sendmail
 
48
then
 
49
  MAIL_AGENT="/usr/lib/sendmail -oi -t"
 
50
elif test -f /usr/sbin/sendmail
 
51
then
 
52
  MAIL_AGENT="/usr/sbin/sendmail -oi -t"
 
53
else
 
54
  MAIL_AGENT="rmail $BUGmysql"
 
55
fi
 
56
 
 
57
# Figure out how to echo a string without a trailing newline
 
58
N=`echo 'hi there\c'`
 
59
case "$N" in
 
60
  *c)   ECHON1='echo -n' ECHON2= ;;
 
61
  *)    ECHON1=echo ECHON2='\c' ;;
 
62
esac
 
63
 
 
64
# Find out the name of the originator of this PR.
 
65
if test -n "$NAME" 
 
66
then
 
67
  ORIGINATOR="$NAME"
 
68
elif test -f $HOME/.fullname
 
69
then
 
70
  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
 
71
else
 
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`"
 
76
  rm -f $TEMP
 
77
fi
 
78
 
 
79
if test -n "$ORGANIZATION"
 
80
then
 
81
  if test -f "$ORGANIZATION"
 
82
  then
 
83
    ORGANIZATION="`cat $ORGANIZATION`"
 
84
  fi
 
85
else
 
86
  if test -f $HOME/.organization
 
87
  then
 
88
    ORGANIZATION="`cat $HOME/.organization`"
 
89
  elif test -f $HOME/.signature
 
90
  then
 
91
    ORGANIZATION=`sed -e "s/^/  /" $HOME/.signature; echo ">"`
 
92
  fi
 
93
fi
 
94
 
 
95
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
 
96
 
 
97
which_1 ()
 
98
{
 
99
  for cmd
 
100
  do
 
101
    # Absolute path ?. 
 
102
    if expr "x$cmd" : "x/" > /dev/null
 
103
    then
 
104
      echo "$cmd"
 
105
      exit 0
 
106
    else
 
107
      for d in $PATH_DIRS
 
108
      do
 
109
        file="$d/$cmd"
 
110
        if test -x "$file" -a ! -d "$file"
 
111
        then
 
112
          echo "$file"
 
113
          exit 0
 
114
        fi
 
115
      done
 
116
    fi
 
117
  done
 
118
  exit 1
 
119
}
 
120
 
 
121
change_editor ()
 
122
{
 
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"
 
128
}
 
129
 
 
130
# If they don't have a preferred editor set, then use emacs
 
131
if test -z "$VISUAL"
 
132
then
 
133
  if test -z "$EDITOR"
 
134
  then
 
135
    EDIT=emacs
 
136
  else
 
137
    EDIT="$EDITOR"
 
138
  fi
 
139
else
 
140
  EDIT="$VISUAL"
 
141
fi
 
142
 
 
143
#which_1 $EDIT
 
144
used_editor=`which_1 $EDIT`
 
145
 
 
146
echo "test -x $used_editor"
 
147
if test -x "$used_editor"
 
148
then
 
149
  echo "Using editor $used_editor";
 
150
  change_editor
 
151
  sleep 2
 
152
else
 
153
  echo "Could not find a text editor. (tried $EDIT)"
 
154
  change_editor
 
155
  exit 1
 
156
fi
 
157
 
 
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`
 
163
FILE_PATHS=
 
164
 
 
165
for cmd in perl make gmake gcc cc
 
166
do
 
167
  file=`which_1 $cmd`
 
168
  if test $? = 0
 
169
  then
 
170
    if test $cmd = "gcc"
 
171
    then
 
172
      GCC_INFO=`$file -v 2>&1`
 
173
    elif test $cmd = "perl"
 
174
    then
 
175
      PERL_INFO=`$file -v | grep -i version 2>&1`
 
176
    fi
 
177
    FILE_PATHS="$FILE_PATHS $file"
 
178
  fi
 
179
done
 
180
 
 
181
admin=`which_1 mysqladmin`
 
182
MYSQL_SERVER=
 
183
if test -x "$admin"
 
184
then
 
185
  MYSQL_SERVER=`$admin version 2> /dev/null`
 
186
  if test "$?" = "1"
 
187
  then
 
188
    MYSQL_SERVER=""
 
189
  fi
 
190
fi
 
191
 
 
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)>'
 
204
 
 
205
 
 
206
cat > $TEMP <<EOF
 
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 \`>').
 
210
SEND-PR:
 
211
From: ${USER}
 
212
To: ${BUGADDR}
 
213
Subject: $SUBJECT_C
 
214
 
 
215
>Description:
 
216
        $DESCRIPTION_C
 
217
>How-To-Repeat:
 
218
        $HOW_TO_REPEAT_C
 
219
>Fix:
 
220
        $FIX_C
 
221
 
 
222
>Submitter-Id:  <submitter ID>
 
223
>Originator:    ${ORIGINATOR}
 
224
>Organization:
 
225
${ORGANIZATION- $ORGANIZATION_C}
 
226
>MySQL support: $LICENCE_C
 
227
>Synopsis:      $SYNOPSIS_C
 
228
>Severity:      $SEVERITY_C
 
229
>Priority:      $PRIORITY_C
 
230
>Category:      mysql
 
231
>Class:         $CLASS_C
 
232
>Release:       mysql-${VERSION} ($COMPILATION_COMMENT)
 
233
`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
 
234
>Environment:
 
235
        $ENVIRONMENT_C
 
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"`
 
245
EOF
 
246
 
 
247
chmod u+w $TEMP
 
248
cp $TEMP $TEMP.x
 
249
 
 
250
eval $EDIT $TEMP
 
251
 
 
252
if cmp -s $TEMP $TEMP.x
 
253
then
 
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.."
 
258
  exit 1
 
259
fi
 
260
 
 
261
#
 
262
#       Check the enumeration fields
 
263
 
 
264
# This is a "sed-subroutine" with one keyword parameter
 
265
# (with workaround for Sun sed bug)
 
266
#
 
267
SED_CMD='
 
268
/$PATTERN/{
 
269
s|||
 
270
s|<.*>||
 
271
s|^[    ]*||
 
272
s|[     ]*$||
 
273
p
 
274
q
 
275
}'
 
276
 
 
277
 
 
278
while :; do
 
279
  CNT=0
 
280
 
 
281
  #
 
282
  # 1) Severity
 
283
  #
 
284
  PATTERN=">Severity:"
 
285
  SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
 
286
  case "$SEVERITY" in
 
287
    ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
 
288
    *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
 
289
  esac
 
290
  #
 
291
  # 2) Priority
 
292
  #
 
293
  PATTERN=">Priority:"
 
294
  PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
 
295
  case "$PRIORITY" in
 
296
    ""|low|medium|high) CNT=`expr $CNT + 1` ;;
 
297
    *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
 
298
  esac
 
299
  #
 
300
  # 3) Class
 
301
  #
 
302
  PATTERN=">Class:"
 
303
  CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
 
304
  case "$CLASS" in
 
305
    ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
 
306
    *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
 
307
  esac
 
308
 
 
309
  #
 
310
  # 4) Synopsis
 
311
  #
 
312
  VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[  ]*//'`
 
313
  case "$VALUE" in
 
314
    "$SYNOPSIS_C")  echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;;
 
315
    *) CNT=`expr $CNT + 1` 
 
316
  esac
 
317
 
 
318
  test $CNT -lt 4  &&
 
319
    echo "Errors were found with the problem report."
 
320
 
 
321
 
 
322
  #       Check if subject of mail was changed, if not, use Synopsis field
 
323
  #
 
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
 
329
  fi
 
330
 
 
331
  while :; do
 
332
    $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
 
333
    read input
 
334
    case "$input" in
 
335
      a*)
 
336
        echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
 
337
        cat $TEMP >> $HOME/dead.mysqlbug
 
338
        xs=1; exit
 
339
        ;;
 
340
      e*)
 
341
        eval $EDIT $TEMP
 
342
        continue 2
 
343
        ;;
 
344
      s*)
 
345
        break 2
 
346
        ;;
 
347
    esac
 
348
  done
 
349
done
 
350
#
 
351
#       Remove comments and send the problem report
 
352
#       (we have to use patterns, where the comment contains regex chars)
 
353
#
 
354
# /^>Originator:/s;$ORIGINATOR;;
 
355
sed  -e "
 
356
/^SEND-PR:/d
 
357
/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
 
358
/^>Confidential:/s;<.*>;;
 
359
/^>Synopsis:/s;$SYNOPSIS_C;;
 
360
/^>Severity:/s;<.*>;;
 
361
/^>Priority:/s;<.*>;;
 
362
/^>Class:/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;;
 
368
" $TEMP > $TEMP.x
 
369
 
 
370
if $MAIL_AGENT < $TEMP.x
 
371
then
 
372
  echo "$COMMAND: problem report sent"
 
373
  xs=0; exit
 
374
else
 
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
 
378
fi
 
379
 
 
380
exit 0