2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to
21 # the Free Software Foundation, 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
24 # The version of this send-pr.
27 # The submitter-id for your site.
30 # The default mail address for PR submissions.
31 GNATS_ADDR
=gcc-gnats@gcc.gnu.org
33 # The default release for this host.
34 DEFAULT_RELEASE
="@gcc_version_full@"
36 # The default organization.
39 # What mailer to use. This must come after the config file, since it is
42 if [ -f /usr
/sbin
/sendmail
]; then
43 MAIL_AGENT
="/usr/sbin/sendmail -oi -t"
45 MAIL_AGENT
="/usr/lib/sendmail -oi -t"
47 MAILER
=`echo $MAIL_AGENT | sed -e 's, .*,,'`
48 if [ ! -f "$MAILER" ] ; then
49 echo "$COMMAND: Cannot file mail program \"$MAILER\"."
50 echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
55 # How to read the passwd database.
56 PASSWD
="cat /etc/passwd"
60 if [ $ECHON = bsd
] ; then
63 elif [ $ECHON = sysv
] ; then
73 if [ -z "$TMPDIR" ]; then
76 if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
77 TMPDIR
="`echo $TMPDIR | sed -e 's,/$,,'`"
81 if [ @have_mktemp_command@
= yes ]; then
82 TEMP0
=`mktemp $TMPDIR/poXXXXXX` ||
exit 1
83 TEMP
=`mktemp $TMPDIR/pXXXXXX` ||
exit 1
84 BAD
=`mktemp $TMPDIR/pbadXXXXXX` ||
exit 1
85 REF
=`mktemp $TMPDIR/pfXXXXXX` ||
exit 1
86 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $BAD $REF"
93 mkdir
$TEMPD ||
exit 1
94 REMOVE_TEMP
="rm -rf $TEMPD"
98 if [ "$LOGNAME" = "" ]; then
99 if [ "$USER" != "" ]; then
107 REPLY_TO
="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
109 # Find out the name of the originator of this PR.
110 if [ -n "$NAME" ]; then
112 elif [ -f $HOME/.fullname
]; then
113 ORIGINATOR
="`sed -e '1q' $HOME/.fullname`"
115 # Must use temp file due to incompatibilities in quoting behavior
116 # and to protect shell metacharacters in the expansion of $LOGNAME
117 $PASSWD |
grep "^$LOGNAME:" |
awk -F: '{print $5}' |
sed -e 's/,.*//' > $TEMP0
118 ORIGINATOR
="`cat $TEMP0`"
122 if [ -n "$ORGANIZATION" ]; then
123 if [ -f "$ORGANIZATION" ]; then
124 ORGANIZATION
="`cat $ORGANIZATION`"
127 if [ -n "$DEFAULT_ORGANIZATION" ]; then
128 ORGANIZATION
="$DEFAULT_ORGANIZATION"
129 elif [ -f $HOME/.organization
]; then
130 ORGANIZATION
="`cat $HOME/.organization`"
134 # If they don't have a preferred editor set, then use
135 if [ -z "$VISUAL" ]; then
136 if [ -z "$EDITOR" ]; then
145 # Find out some information.
146 SYSTEM
=`( [ -f /bin/uname ] && /bin/uname -a ) || \
147 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
148 ARCH
=`[ -f /bin/arch ] && /bin/arch`
149 MACHINE
=`[ -f /bin/machine ] && /bin/machine`
151 COMMAND
=`echo $0 | sed -e 's,.*/,,'`
152 USAGE
="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
153 [-c address] [--request-id] [--version]"
159 while [ $# -gt 0 ]; do
161 -r) ;; # Ignore for backward compat.
162 -t |
--to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
163 shift ; GNATS_ADDR
="$1"
164 EXPLICIT_GNATS_ADDR
=true
166 -f |
--file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
168 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
169 echo "$COMMAND: cannot read $IN_FILE"
174 -b |
--batch) BATCH
=true
;;
175 -c |
--cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
178 -s |
--severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
179 shift ; SEVERITY_C
="$1"
181 -p |
-P |
--print) PRINT
=true
;;
182 -L |
--list) FORMAT
=norm
;;
183 -l |
-CL |
--lisp) FORMAT
=lisp
;;
184 --request-id) REQUEST_ID
=true
;;
185 -h |
--help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
186 -V |
--version) cat <<EOF
187 gccbug (GCC) $DEFAULT_RELEASE
188 Copyright (C) 2002 Free Software Foundation, Inc.
189 This is free software; see the source for copying conditions. There is NO
190 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
193 $REMOVE_TEMP; exit 0 ;;
194 -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
195 *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
200 # spam does not need to be listed here
201 CATEGORIES
="ada bootstrap c++ c debug driver fortran inline-asm java libf2c libgcj libobjc libstdc++ middle-end objc optimization other pch preprocessor target web"
204 lisp
) echo "$CATEGORIES" | \
205 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
209 norm
) l
=`echo "$CATEGORIES" | \
210 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
211 END {print max + 1;}'`
213 if [ $c -eq 0 ]; then c
=1; fi
214 echo "$CATEGORIES" | \
215 awk 'BEGIN {print "Known categories:"; i = 0 }
216 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
223 ORIGINATOR_C
='<name of the PR author (one line)>'
224 ORGANIZATION_C
='<organization of PR author (multiple lines)>'
225 SYNOPSIS_C
='<synopsis of the problem (one line)>'
226 if [ -z "$SEVERITY_C" ]; then
227 SEVERITY_C
='<[ non-critical | serious | critical ] (one line)>'
229 PRIORITY_C
='<[ low | medium ] (one line)>'
230 CATEGORY_C
='<choose from the top of this file (one line)>'
231 RELEASE_C
='<release number or tag (one line)>'
232 ENVIRONMENT_C
='<machine, os, target, libraries (multiple lines)>'
233 DESCRIPTION_C
='<precise description of the problem (multiple lines)>'
234 HOW_TO_REPEAT_C
='<When reporting a compiler error, preprocessor output must be included>'
235 FIX_C
='<how to correct or work around the problem, if known (multiple lines)>'
237 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
239 trap '$REMOVE_TEMP; exit $xs' 0
240 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
242 # If they told us to use a specific file, then do so.
243 if [ -n "$IN_FILE" ]; then
244 if [ "$IN_FILE" = "-" ]; then
245 # The PR is coming from the standard input.
246 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
247 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
252 # Use the file they named.
253 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
254 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
261 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
262 # If their PR_FORM points to a bogus entry, then bail.
263 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
264 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
266 PRINT_INTERN
=bad_prform
270 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
272 ( echo "$COMMAND: could not copy $PR_FORM" ; xs
=1; exit )
274 for file in $TEMP $REF ; do
275 cat > $file << '__EOF__'
276 SEND-PR
: -*- send-pr
-*-
277 SEND-PR
: Lines starting with
`SEND-PR' will be removed automatically, as
278 SEND-PR: will all comments (text enclosed in `<' and `>').
280 SEND-PR
: Please consult the GCC manual
if you are not sure how to
281 SEND-PR
: fill out a problem report.
282 SEND-PR
: Note that the Synopsis field is mandatory. The Subject
(for
283 SEND-PR
: the
mail) will be made the same as Synopsis unless explicitly
286 SEND-PR
: Choose from the following categories
:
290 # Format the categories so they fit onto lines.
291 l
=`echo "$CATEGORIES" | \
292 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
293 END {print max + 1;}'`
295 if [ $c -eq 0 ]; then c
=1; fi
296 echo "$CATEGORIES" | \
297 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
298 { printf ("%-'$l'.'$l's", $0);
299 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
300 END { printf "\nSEND-PR:\n"; }' >> $file
302 cat >> $file << __EOF__
308 X-send-pr-version: $VERSION
312 >Submitter-Id: $SUBMITTER
313 >Originator: $ORIGINATOR
314 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
316 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
317 >Synopsis: $SYNOPSIS_C
318 >Severity: $SEVERITY_C
319 SEND-PR: critical GCC is completely not operational; no work-around known.
320 SEND-PR: serious GCC is not working properly; a work-around is possible.
321 SEND-PR: non-critical Report indicates minor problem.
322 >Priority: $PRIORITY_C
323 SEND-PR: medium The problem should be solved in the next release.
324 SEND-PR: low The problem should be solve in a future release.
325 >Category: $CATEGORY_C
326 >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)>
327 SEND-PR: doc-bug The documentation is incorrect.
328 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
329 SEND-PR: rejects-legal GCC gives an error message for correct code.
330 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
331 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
332 SEND-PR: for correct code
333 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
334 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
335 SEND-PR: sw-bug Software bug of some other class than above
336 SEND-PR: change-request A feature in GCC is missing.
337 SEND-PR: support I need help with gcc.
338 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
340 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
341 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
342 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
347 configured with: @gcc_config_arguments@
358 if [ "$PRINT" = true
-o "$PRINT_INTERN" = true
]; then
364 if [ -z "$REQUEST_ID" ]; then
367 ed
-s $TEMP << '__EOF__'
368 /^Subject
/s
/^Subject
:.
*/Subject
: request
for a customer id
/
369 /^
>Category
/s
/^
>Category
:.
*/>Category
: send-pr
/
375 if cmp -s $REF $TEMP ; then
376 echo "$COMMAND: problem report not filled out, therefore not sent"
382 # Check the enumeration fields
384 # This is a "sed-subroutine" with one keyword parameter
385 # (with workaround for Sun sed bug)
398 while [ -z "$REQUEST_ID" ]; do
403 PATTERN
=">Confidential:"
404 CONFIDENTIAL
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
405 case "$CONFIDENTIAL" in
406 no
) CNT
=`expr $CNT + 1` ;;
407 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
413 SEVERITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
415 ""|non-critical|serious|critical
) CNT
=`expr $CNT + 1` ;;
416 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
422 PRIORITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
424 ""|low|medium
) CNT
=`expr $CNT + 1` ;;
425 high
) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
426 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
432 CATEGORY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
436 if [ "$C" = "$CATEGORY" ]; then FOUND
=true
; break ; fi
438 if [ -n "$FOUND" ]; then
441 if [ -z "$CATEGORY" ]; then
442 echo "$COMMAND: you must include a Category: field in your report."
444 echo "$COMMAND: \`$CATEGORY' is not a known category."
451 CLASS
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
453 ""|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` ;;
454 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
457 # 6) Check that synopsis is not empty
459 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev
/null
461 echo "$COMMAND: Synopsis must not be empty."
466 [ $CNT -lt 6 -a -z "$BATCH" ] &&
467 echo "Errors were found with the problem report."
470 if [ -z "$BATCH" ]; then
471 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
474 if [ $CNT -eq 6 ]; then
482 if [ -z "$BATCH" ]; then
483 echo "$COMMAND: the problem report remains in $BAD and is not sent."
484 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
487 echo "$COMMAND: the problem report is not sent."
503 # Make sure the mail has got a Subject. If not, use the same as
507 if grep '^Subject:[ ]*$' $TEMP > /dev
/null
509 SYNOPSIS
=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
510 ed
-s $TEMP << __EOF__
511 /^Subject:/s/:.*\$/: $SYNOPSIS/
518 # Remove comments and send the problem report
519 # (we have to use patterns, where the comment contains regex chars)
521 # /^>Originator:/s;$ORIGINATOR;;
524 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
525 /^>Confidential:/s;<.*>;;
526 /^>Synopsis:/s;$SYNOPSIS_C;;
527 /^>Severity:/s;<.*>;;
528 /^>Priority:/s;<.*>;;
529 /^>Category:/s;$CATEGORY_C;;
531 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
532 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
533 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
534 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
535 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
538 if $MAIL_AGENT < $REF; then
539 echo "$COMMAND: problem report sent"
542 echo "$COMMAND: mysterious mail failure."
543 if [ -z "$BATCH" ]; then
544 echo "$COMMAND: the problem report remains in $BAD and is not sent."
545 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
548 echo "$COMMAND: the problem report is not sent."