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.

382 lines
9.2 KiB

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