2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
4 # Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5 # version written by Heinz G. Seidl (hgs@cygnus.com).
7 # This file is part of GNU GNATS.
9 # GNU GNATS is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3, or (at your option)
14 # GNU GNATS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU GNATS; see the file COPYING3. If not see
21 # <http://www.gnu.org/licenses/>.
23 # The version of this send-pr.
26 # The submitter-id for your site.
29 # The default mail address for PR submissions.
30 GNATS_ADDR
=gcc-gnats@gcc.gnu.org
32 # The default release for this host.
33 # We have to guess at what program_transform_name might have done.
34 # "sed 1q" because neither "head -1" nor "head -n 1" is universal, argh.
36 DEFAULT_GCC
="`echo $0 | sed -e 's/bug//'`"
37 DEFAULT_RELEASE
="`$DEFAULT_GCC --version | sed 1q`"
39 # The default organization.
42 # What mailer to use. This must come after the config file, since it is
45 if [ -f /usr
/sbin
/sendmail
]; then
46 MAIL_AGENT
="/usr/sbin/sendmail -oi -t"
48 MAIL_AGENT
="/usr/lib/sendmail -oi -t"
50 MAILER
=`echo $MAIL_AGENT | sed -e 's, .*,,'`
51 if [ ! -f "$MAILER" ] ; then
52 echo "$COMMAND: Cannot file mail program \"$MAILER\"."
53 echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
58 # How to read the passwd database.
59 PASSWD
="cat /etc/passwd"
63 if [ $ECHON = bsd
] ; then
66 elif [ $ECHON = sysv
] ; then
76 if [ -z "$TMPDIR" ]; then
79 if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
80 TMPDIR
="`echo $TMPDIR | sed -e 's,/$,,'`"
84 if [ @have_mktemp_command@
= yes ]; then
85 TEMP0
=`mktemp $TMPDIR/poXXXXXX` ||
exit 1
86 TEMP
=`mktemp $TMPDIR/pXXXXXX` ||
exit 1
87 BAD
=`mktemp $TMPDIR/pbadXXXXXX` ||
exit 1
88 REF
=`mktemp $TMPDIR/pfXXXXXX` ||
exit 1
89 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $BAD $REF"
96 mkdir
$TEMPD ||
exit 1
97 REMOVE_TEMP
="rm -rf $TEMPD"
101 if [ "$LOGNAME" = "" ]; then
102 if [ "$USER" != "" ]; then
110 REPLY_TO
="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
112 # Find out the name of the originator of this PR.
113 if [ -n "$NAME" ]; then
115 elif [ -f $HOME/.fullname
]; then
116 ORIGINATOR
="`sed -e '1q' $HOME/.fullname`"
118 # Must use temp file due to incompatibilities in quoting behavior
119 # and to protect shell metacharacters in the expansion of $LOGNAME
120 $PASSWD |
grep "^$LOGNAME:" |
awk -F: '{print $5}' |
sed -e 's/,.*//' > $TEMP0
121 ORIGINATOR
="`cat $TEMP0`"
125 if [ -n "$ORGANIZATION" ]; then
126 if [ -f "$ORGANIZATION" ]; then
127 ORGANIZATION
="`cat $ORGANIZATION`"
130 if [ -n "$DEFAULT_ORGANIZATION" ]; then
131 ORGANIZATION
="$DEFAULT_ORGANIZATION"
132 elif [ -f $HOME/.organization
]; then
133 ORGANIZATION
="`cat $HOME/.organization`"
137 # If they don't have a preferred editor set, then use
138 if [ -z "$VISUAL" ]; then
139 if [ -z "$EDITOR" ]; then
148 # Find out some information.
149 SYSTEM
=`( [ -f /bin/uname ] && /bin/uname -a ) || \
150 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
151 ARCH
=`[ -f /bin/arch ] && /bin/arch`
152 MACHINE
=`[ -f /bin/machine ] && /bin/machine`
154 COMMAND
=`echo $0 | sed -e 's,.*/,,'`
155 USAGE
="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
156 [-c address] [--request-id] [--version]"
162 while [ $# -gt 0 ]; do
164 -r) ;; # Ignore for backward compat.
165 -t |
--to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
166 shift ; GNATS_ADDR
="$1"
167 EXPLICIT_GNATS_ADDR
=true
169 -f |
--file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
171 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
172 echo "$COMMAND: cannot read $IN_FILE"
177 -b |
--batch) BATCH
=true
;;
178 -c |
--cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
181 -s |
--severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
182 shift ; SEVERITY_C
="$1"
184 -p |
-P |
--print) PRINT
=true
;;
185 -L |
--list) FORMAT
=norm
;;
186 -l |
-CL |
--lisp) FORMAT
=lisp
;;
187 --request-id) REQUEST_ID
=true
;;
188 -h |
--help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
189 -V |
--version) cat <<EOF
190 gccbug (GCC) $DEFAULT_RELEASE
191 Copyright (C) 2002 Free Software Foundation, Inc.
192 This is free software; see the source for copying conditions. There is NO
193 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
196 $REMOVE_TEMP; exit 0 ;;
197 -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
198 *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
203 # spam does not need to be listed here
204 CATEGORIES
="ada bootstrap c++ c debug driver fortran inline-asm java libgcj libobjc libstdc++ middle-end objc other pch preprocessor rtl-optimization target tree-optimization web"
207 lisp
) echo "$CATEGORIES" | \
208 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
212 norm
) l
=`echo "$CATEGORIES" | \
213 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
214 END {print max + 1;}'`
216 if [ $c -eq 0 ]; then c
=1; fi
217 echo "$CATEGORIES" | \
218 awk 'BEGIN {print "Known categories:"; i = 0 }
219 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
226 ORIGINATOR_C
='<name of the PR author (one line)>'
227 ORGANIZATION_C
='<organization of PR author (multiple lines)>'
228 SYNOPSIS_C
='<synopsis of the problem (one line)>'
229 if [ -z "$SEVERITY_C" ]; then
230 SEVERITY_C
='<[ non-critical | serious | critical ] (one line)>'
232 PRIORITY_C
='<[ low | medium ] (one line)>'
233 CATEGORY_C
='<choose from the top of this file (one line)>'
234 RELEASE_C
='<release number or tag (one line)>'
235 ENVIRONMENT_C
='<machine, os, target, libraries (multiple lines)>'
236 DESCRIPTION_C
='<precise description of the problem (multiple lines)>'
237 HOW_TO_REPEAT_C
='<When reporting a compiler error, preprocessor output must be included>'
238 FIX_C
='<how to correct or work around the problem, if known (multiple lines)>'
240 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
242 trap '$REMOVE_TEMP; exit $xs' 0
243 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
245 # If they told us to use a specific file, then do so.
246 if [ -n "$IN_FILE" ]; then
247 if [ "$IN_FILE" = "-" ]; then
248 # The PR is coming from the standard input.
249 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
250 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
255 # Use the file they named.
256 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
257 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
264 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
265 # If their PR_FORM points to a bogus entry, then bail.
266 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
267 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
269 PRINT_INTERN
=bad_prform
273 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
275 ( echo "$COMMAND: could not copy $PR_FORM" ; xs
=1; exit )
277 for file in $TEMP $REF ; do
278 cat > $file << '__EOF__'
279 SEND-PR
: -*- send-pr
-*-
280 SEND-PR
: Lines starting with
`SEND-PR' will be removed automatically, as
281 SEND-PR: will all comments (text enclosed in `<' and `>').
283 SEND-PR
: Please consult the GCC manual
if you are not sure how to
284 SEND-PR
: fill out a problem report.
285 SEND-PR
: Note that the Synopsis field is mandatory. The Subject
(for
286 SEND-PR
: the
mail) will be made the same as Synopsis unless explicitly
289 SEND-PR
: Choose from the following categories
:
293 # Format the categories so they fit onto lines.
294 l
=`echo "$CATEGORIES" | \
295 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
296 END {print max + 1;}'`
298 if [ $c -eq 0 ]; then c
=1; fi
299 echo "$CATEGORIES" | \
300 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
301 { printf ("%-'$l'.'$l's", $0);
302 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
303 END { printf "\nSEND-PR:\n"; }' >> $file
305 cat >> $file << __EOF__
311 X-send-pr-version: $VERSION
315 >Submitter-Id: $SUBMITTER
316 >Originator: $ORIGINATOR
317 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
319 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
320 >Synopsis: $SYNOPSIS_C
321 >Severity: $SEVERITY_C
322 SEND-PR: critical GCC is completely not operational; no work-around known.
323 SEND-PR: serious GCC is not working properly; a work-around is possible.
324 SEND-PR: non-critical Report indicates minor problem.
325 >Priority: $PRIORITY_C
326 SEND-PR: medium The problem should be solved in the next release.
327 SEND-PR: low The problem should be solve in a future release.
328 >Category: $CATEGORY_C
329 >Class: <[ doc-bug | accepts-illegal | rejects-legal | wrong-code | ice-on-legal-code| ice-on-illegal-code | pessimizes-code | sw-bug | change-request | support ] (one line)>
330 SEND-PR: doc-bug The documentation is incorrect.
331 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
332 SEND-PR: rejects-legal GCC gives an error message for correct code.
333 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
334 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
335 SEND-PR: for correct code
336 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
337 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
338 SEND-PR: sw-bug Software bug of some other class than above
339 SEND-PR: change-request A feature in GCC is missing.
340 SEND-PR: support I need help with gcc.
341 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
343 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
344 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
345 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
351 cat >> $file << \__EOF__
352 configured with
: @gcc_config_arguments@
354 cat >> $file << __EOF__
365 if [ "$PRINT" = true
-o "$PRINT_INTERN" = true
]; then
371 if [ -z "$REQUEST_ID" ]; then
374 ed
-s $TEMP << '__EOF__'
375 /^Subject
/s
/^Subject
:.
*/Subject
: request
for a customer id
/
376 /^
>Category
/s
/^
>Category
:.
*/>Category
: send-pr
/
382 if cmp -s $REF $TEMP ; then
383 echo "$COMMAND: problem report not filled out, therefore not sent"
389 # Check the enumeration fields
391 # This is a "sed-subroutine" with one keyword parameter
392 # (with workaround for Sun sed bug)
405 while [ -z "$REQUEST_ID" ]; do
410 PATTERN
=">Confidential:"
411 CONFIDENTIAL
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
412 case "$CONFIDENTIAL" in
413 no
) CNT
=`expr $CNT + 1` ;;
414 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
420 SEVERITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
422 ""|non-critical|serious|critical
) CNT
=`expr $CNT + 1` ;;
423 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
429 PRIORITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
431 ""|low|medium
) CNT
=`expr $CNT + 1` ;;
432 high
) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
433 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
439 CATEGORY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
443 if [ "$C" = "$CATEGORY" ]; then FOUND
=true
; break ; fi
445 if [ -n "$FOUND" ]; then
448 if [ -z "$CATEGORY" ]; then
449 echo "$COMMAND: you must include a Category: field in your report."
451 echo "$COMMAND: \`$CATEGORY' is not a known category."
458 CLASS
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
460 ""|doc-bug|accepts-illegal|rejects-legal|wrong-code|ice-on-legal-code|ice-on-illegal-code|pessimizes-code|sw-bug|change-request|support
) CNT
=`expr $CNT + 1` ;;
461 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
464 # 6) Check that synopsis is not empty
466 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev
/null
468 echo "$COMMAND: Synopsis must not be empty."
473 [ $CNT -lt 6 -a -z "$BATCH" ] &&
474 echo "Errors were found with the problem report."
477 if [ -z "$BATCH" ]; then
478 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
481 if [ $CNT -eq 6 ]; then
489 if [ -z "$BATCH" ]; then
490 echo "$COMMAND: the problem report remains in $BAD and is not sent."
491 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
494 echo "$COMMAND: the problem report is not sent."
510 # Make sure the mail has got a Subject. If not, use the same as
514 if grep '^Subject:[ ]*$' $TEMP > /dev
/null
516 SYNOPSIS
=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
517 ed
-s $TEMP << __EOF__
518 /^Subject:/s/:.*\$/: $SYNOPSIS/
525 # Remove comments and send the problem report
526 # (we have to use patterns, where the comment contains regex chars)
528 # /^>Originator:/s;$ORIGINATOR;;
531 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
532 /^>Confidential:/s;<.*>;;
533 /^>Synopsis:/s;$SYNOPSIS_C;;
534 /^>Severity:/s;<.*>;;
535 /^>Priority:/s;<.*>;;
536 /^>Category:/s;$CATEGORY_C;;
538 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
539 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
540 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
541 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
542 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
545 if $MAIL_AGENT < $REF; then
546 echo "$COMMAND: problem report sent"
549 echo "$COMMAND: mysterious mail failure."
550 if [ -z "$BATCH" ]; then
551 echo "$COMMAND: the problem report remains in $BAD and is not sent."
552 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
555 echo "$COMMAND: the problem report is not sent."