2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000 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, 675 Mass Ave, Cambridge, MA 02139, USA.
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 DEFAULT_RELEASE
="@gcc_version@"
35 # The default organization.
38 # What mailer to use. This must come after the config file, since it is
41 if [ -f /usr
/sbin
/sendmail
]; then
42 MAIL_AGENT
="/usr/sbin/sendmail -oi -t"
44 MAIL_AGENT
="/usr/lib/sendmail -oi -t"
46 MAILER
=`echo $MAIL_AGENT | sed -e 's, .*,,'`
47 if [ ! -f "$MAILER" ] ; then
48 echo "$COMMAND: Cannot file mail program \"$MAILER\"."
49 echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
54 # How to read the passwd database.
55 PASSWD
="cat /etc/passwd"
59 if [ $ECHON = bsd
] ; then
62 elif [ $ECHON = sysv
] ; then
72 if [ -z "$TMPDIR" ]; then
75 if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
76 TMPDIR
="`echo $TMPDIR | sed -e 's,/$,,'`"
85 if [ "$LOGNAME" = "" ]; then
86 if [ "$USER" != "" ]; then
94 REPLY_TO
="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
96 # Find out the name of the originator of this PR.
97 if [ -n "$NAME" ]; then
99 elif [ -f $HOME/.fullname
]; then
100 ORIGINATOR
="`sed -e '1q' $HOME/.fullname`"
102 # Must use temp file due to incompatibilities in quoting behavior
103 # and to protect shell metacharacters in the expansion of $LOGNAME
104 $PASSWD |
grep "^$LOGNAME:" |
awk -F: '{print $5}' |
sed -e 's/,.*//' > $TEMP
105 ORIGINATOR
="`cat $TEMP`"
109 if [ -n "$ORGANIZATION" ]; then
110 if [ -f "$ORGANIZATION" ]; then
111 ORGANIZATION
="`cat $ORGANIZATION`"
114 if [ -n "$DEFAULT_ORGANIZATION" ]; then
115 ORGANIZATION
="$DEFAULT_ORGANIZATION"
116 elif [ -f $HOME/.organization
]; then
117 ORGANIZATION
="`cat $HOME/.organization`"
121 # If they don't have a preferred editor set, then use
122 if [ -z "$VISUAL" ]; then
123 if [ -z "$EDITOR" ]; then
132 # Find out some information.
133 SYSTEM
=`( [ -f /bin/uname ] && /bin/uname -a ) || \
134 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
135 ARCH
=`[ -f /bin/arch ] && /bin/arch`
136 MACHINE
=`[ -f /bin/machine ] && /bin/machine`
138 COMMAND
=`echo $0 | sed -e 's,.*/,,'`
139 USAGE
="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
140 [-c address] [--request-id] [--version]"
146 while [ $# -gt 0 ]; do
148 -r) ;; # Ignore for backward compat.
149 -t |
--to) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
150 shift ; GNATS_ADDR
="$1"
151 EXPLICIT_GNATS_ADDR
=true
153 -f |
--file) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
155 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
156 echo "$COMMAND: cannot read $IN_FILE"
160 -b |
--batch) BATCH
=true
;;
161 -c |
--cc) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
164 -s |
--severity) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
165 shift ; SEVERITY_C
="$1"
167 -p |
-P |
--print) PRINT
=true
;;
168 -L |
--list) FORMAT
=norm
;;
169 -l |
-CL |
--lisp) FORMAT
=lisp
;;
170 --request-id) REQUEST_ID
=true
;;
171 -h |
--help) echo "$USAGE"; exit 0 ;;
172 -V |
--version) echo "$VERSION"; exit 0 ;;
173 -*) echo "$USAGE" ; exit 1 ;;
174 *) echo "$USAGE" ; exit 1
179 # spam does not need to be listed here
180 CATEGORIES
="c++ c debug fortran java libf2c libobjc libstdc++ middle-end objc optimization other target web"
183 lisp
) echo "$CATEGORIES" | \
184 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
187 norm
) l
=`echo "$CATEGORIES" | \
188 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
189 END {print max + 1;}'`
191 if [ $c -eq 0 ]; then c
=1; fi
192 echo "$CATEGORIES" | \
193 awk 'BEGIN {print "Known categories:"; i = 0 }
194 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
200 ORIGINATOR_C
='<name of the PR author (one line)>'
201 ORGANIZATION_C
='<organization of PR author (multiple lines)>'
202 CONFIDENTIAL_C
='<[ yes | no ] (one line)>'
203 SYNOPSIS_C
='<synopsis of the problem (one line)>'
204 if [ -z "$SEVERITY_C" ]; then
205 SEVERITY_C
='<[ non-critical | serious | critical ] (one line)>'
207 PRIORITY_C
='<[ low | medium | high ] (one line)>'
208 CATEGORY_C
='<choose from the top of this file (one line)>'
209 RELEASE_C
='<release number or tag (one line)>'
210 ENVIRONMENT_C
='<machine, os, target, libraries (multiple lines)>'
211 DESCRIPTION_C
='<precise description of the problem (multiple lines)>'
212 HOW_TO_REPEAT_C
='<When reporting a compiler error, preprocessor output must be included>'
213 FIX_C
='<how to correct or work around the problem, if known (multiple lines)>'
215 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
217 trap 'rm -f $REF $TEMP; exit $xs' 0
218 trap 'echo "$COMMAND: Aborting ..."; rm -f $REF $TEMP; xs=1; exit' 1 3 13 15
220 # If they told us to use a specific file, then do so.
221 if [ -n "$IN_FILE" ]; then
222 if [ "$IN_FILE" = "-" ]; then
223 # The PR is coming from the standard input.
224 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
225 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
230 # Use the file they named.
231 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
232 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
239 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
240 # If their PR_FORM points to a bogus entry, then bail.
241 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
242 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
244 PRINT_INTERN
=bad_prform
248 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
250 ( echo "$COMMAND: could not copy $PR_FORM" ; xs
=1; exit )
252 for file in $TEMP $REF ; do
253 cat > $file << '__EOF__'
254 SEND-PR
: -*- send-pr
-*-
255 SEND-PR
: Lines starting with
`SEND-PR' will be removed automatically, as
256 SEND-PR: will all comments (text enclosed in `<' and `>').
258 SEND-PR
: Please consult the GCC manual manual
if you are not sure how to
259 SEND-PR
: fill out a problem report.
260 SEND-PR
: Note that the Synopsis field is mandatory. The Subject
(for
261 SEND-PR
: the
mail) will be made the same as Synopsis unless explicitly
264 SEND-PR
: Choose from the following categories
:
268 # Format the categories so they fit onto lines.
269 l
=`echo "$CATEGORIES" | \
270 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
271 END {print max + 1;}'`
273 if [ $c -eq 0 ]; then c
=1; fi
274 echo "$CATEGORIES" | \
275 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
276 { printf ("%-'$l'.'$l's", $0);
277 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
278 END { printf "\nSEND-PR:\n"; }' >> $file
280 cat >> $file << __EOF__
286 X-send-pr-version: $VERSION
290 >Submitter-Id: $SUBMITTER
291 >Originator: $ORIGINATOR
292 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
293 >Confidential: $CONFIDENTIAL_C
294 >Synopsis: $SYNOPSIS_C
295 >Severity: $SEVERITY_C
296 SEND-PR: critical GCC is completely not operational; no work-around known.
297 SEND-PR: serious GCC is not working properly; a work-around is possible.
298 SEND-PR: non-critical Report indicates minor problem.
299 >Priority: $PRIORITY_C
300 SEND-PR: high A solution is necessary as soon as possible.
301 SEND-PR: medium The problem should be solved in the next release.
302 SEND-PR: low The problem should be solve in a future release.
303 >Category: $CATEGORY_C
304 >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)>
305 SEND-PR: doc-bug The doumentation is incorrect.
306 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
307 SEND-PR: rejects-legal GCC gives an error message for correct code.
308 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
309 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
310 SEND-PR: for correct code
311 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
312 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
313 SEND-PR: sw-bug Software bug of some other class than above
314 SEND-PR: change-request A feature in GCC is missing.
315 SEND-PR: support I need help with gcc.
316 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
318 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
319 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
320 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
335 if [ "$PRINT" = true
-o "$PRINT_INTERN" = true
]; then
341 if [ -z "$REQUEST_ID" ]; then
344 ed
-s $TEMP << '__EOF__'
345 /^Subject
/s
/^Subject
:.
*/Subject
: request
for a customer id
/
346 /^
>Category
/s
/^
>Category
:.
*/>Category
: send-pr
/
352 if cmp -s $REF $TEMP ; then
353 echo "$COMMAND: problem report not filled out, therefore not sent"
359 # Check the enumeration fields
361 # This is a "sed-subroutine" with one keyword parameter
362 # (with workaround for Sun sed bug)
375 while [ -z "$REQUEST_ID" ]; do
380 PATTERN
=">Confidential:"
381 CONFIDENTIAL
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
382 case "$CONFIDENTIAL" in
383 ""|
yes|no
) CNT
=`expr $CNT + 1` ;;
384 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
390 SEVERITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
392 ""|non-critical|serious|critical
) CNT
=`expr $CNT + 1` ;;
393 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
399 PRIORITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
401 ""|low|medium|high
) CNT
=`expr $CNT + 1` ;;
402 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
408 CATEGORY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
412 if [ "$C" = "$CATEGORY" ]; then FOUND
=true
; break ; fi
414 if [ -n "$FOUND" ]; then
417 if [ -z "$CATEGORY" ]; then
418 echo "$COMMAND: you must include a Category: field in your report."
420 echo "$COMMAND: \`$CATEGORY' is not a known category."
427 CLASS
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
429 ""|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` ;;
430 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
433 # 6) Check that synopsis is not empty
435 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev
/null
437 echo "$COMMAND: Synopsis must not be empty."
442 [ $CNT -lt 6 -a -z "$BATCH" ] &&
443 echo "Errors were found with the problem report."
446 if [ -z "$BATCH" ]; then
447 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
450 if [ $CNT -eq 6 ]; then
458 if [ -z "$BATCH" ]; then
459 echo "$COMMAND: the problem report remains in $BAD and is not sent."
462 echo "$COMMAND: the problem report is not sent."
478 # Make sure the mail has got a Subject. If not, use the same as
482 if grep '^Subject:[ ]*$' $TEMP > /dev
/null
484 SYNOPSIS
=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
485 ed
-s $TEMP << __EOF__
486 /^Subject:/s/:.*\$/: $SYNOPSIS/
493 # Remove comments and send the problem report
494 # (we have to use patterns, where the comment contains regex chars)
496 # /^>Originator:/s;$ORIGINATOR;;
499 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
500 /^>Confidential:/s;<.*>;;
501 /^>Synopsis:/s;$SYNOPSIS_C;;
502 /^>Severity:/s;<.*>;;
503 /^>Priority:/s;<.*>;;
504 /^>Category:/s;$CATEGORY_C;;
506 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
507 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
508 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
509 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
510 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
513 if $MAIL_AGENT < $REF; then
514 echo "$COMMAND: problem report sent"
517 echo "$COMMAND: mysterious mail failure."
518 if [ -z "$BATCH" ]; then
519 echo "$COMMAND: the problem report remains in $BAD and is not sent."
522 echo "$COMMAND: the problem report is not sent."