You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

403 lines
10 KiB

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