2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000, 2001 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_full@"
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,/$,,'`"
80 if [ @have_mktemp_command@
= yes ]; then
81 TEMP0
=`mktemp $TMPDIR/poXXXXXX` ||
exit 1
82 TEMP
=`mktemp $TMPDIR/pXXXXXX` ||
exit 1
83 BAD
=`mktemp $TMPDIR/pbadXXXXXX` ||
exit 1
84 REF
=`mktemp $TMPDIR/pfXXXXXX` ||
exit 1
90 # set -C _may_ use O_EXCL, but it need not.
93 : > $TEMP0 || bad_temp
=1
94 : > $TEMP || bad_temp
=1
95 : > $BAD || bad_temp
=1
96 : > $REF || bad_temp
=1
97 if [ $bad_temp = 1 ]; then
98 rm -f $TEMP0 $TEMP $BAD $REF
103 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $BAD $REF"
106 if [ "$LOGNAME" = "" ]; then
107 if [ "$USER" != "" ]; then
115 REPLY_TO
="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
117 # Find out the name of the originator of this PR.
118 if [ -n "$NAME" ]; then
120 elif [ -f $HOME/.fullname
]; then
121 ORIGINATOR
="`sed -e '1q' $HOME/.fullname`"
123 # Must use temp file due to incompatibilities in quoting behavior
124 # and to protect shell metacharacters in the expansion of $LOGNAME
125 $PASSWD |
grep "^$LOGNAME:" |
awk -F: '{print $5}' |
sed -e 's/,.*//' > $TEMP0
126 ORIGINATOR
="`cat $TEMP0`"
130 if [ -n "$ORGANIZATION" ]; then
131 if [ -f "$ORGANIZATION" ]; then
132 ORGANIZATION
="`cat $ORGANIZATION`"
135 if [ -n "$DEFAULT_ORGANIZATION" ]; then
136 ORGANIZATION
="$DEFAULT_ORGANIZATION"
137 elif [ -f $HOME/.organization
]; then
138 ORGANIZATION
="`cat $HOME/.organization`"
142 # If they don't have a preferred editor set, then use
143 if [ -z "$VISUAL" ]; then
144 if [ -z "$EDITOR" ]; then
153 # Find out some information.
154 SYSTEM
=`( [ -f /bin/uname ] && /bin/uname -a ) || \
155 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
156 ARCH
=`[ -f /bin/arch ] && /bin/arch`
157 MACHINE
=`[ -f /bin/machine ] && /bin/machine`
159 COMMAND
=`echo $0 | sed -e 's,.*/,,'`
160 USAGE
="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
161 [-c address] [--request-id] [--version]"
167 while [ $# -gt 0 ]; do
169 -r) ;; # Ignore for backward compat.
170 -t |
--to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
171 shift ; GNATS_ADDR
="$1"
172 EXPLICIT_GNATS_ADDR
=true
174 -f |
--file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
176 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
177 echo "$COMMAND: cannot read $IN_FILE"
182 -b |
--batch) BATCH
=true
;;
183 -c |
--cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
186 -s |
--severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
187 shift ; SEVERITY_C
="$1"
189 -p |
-P |
--print) PRINT
=true
;;
190 -L |
--list) FORMAT
=norm
;;
191 -l |
-CL |
--lisp) FORMAT
=lisp
;;
192 --request-id) REQUEST_ID
=true
;;
193 -h |
--help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
194 -V |
--version) echo "$VERSION"; $REMOVE_TEMP; exit 0 ;;
195 -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
196 *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
201 # spam does not need to be listed here
202 CATEGORIES
="c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
205 lisp
) echo "$CATEGORIES" | \
206 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
210 norm
) l
=`echo "$CATEGORIES" | \
211 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
212 END {print max + 1;}'`
214 if [ $c -eq 0 ]; then c
=1; fi
215 echo "$CATEGORIES" | \
216 awk 'BEGIN {print "Known categories:"; i = 0 }
217 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
224 ORIGINATOR_C
='<name of the PR author (one line)>'
225 ORGANIZATION_C
='<organization of PR author (multiple lines)>'
226 SYNOPSIS_C
='<synopsis of the problem (one line)>'
227 if [ -z "$SEVERITY_C" ]; then
228 SEVERITY_C
='<[ non-critical | serious | critical ] (one line)>'
230 PRIORITY_C
='<[ low | medium ] (one line)>'
231 CATEGORY_C
='<choose from the top of this file (one line)>'
232 RELEASE_C
='<release number or tag (one line)>'
233 ENVIRONMENT_C
='<machine, os, target, libraries (multiple lines)>'
234 DESCRIPTION_C
='<precise description of the problem (multiple lines)>'
235 HOW_TO_REPEAT_C
='<When reporting a compiler error, preprocessor output must be included>'
236 FIX_C
='<how to correct or work around the problem, if known (multiple lines)>'
238 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
240 trap '$REMOVE_TEMP; exit $xs' 0
241 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
243 # If they told us to use a specific file, then do so.
244 if [ -n "$IN_FILE" ]; then
245 if [ "$IN_FILE" = "-" ]; then
246 # The PR is coming from the standard input.
247 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
248 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
253 # Use the file they named.
254 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
255 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
262 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
263 # If their PR_FORM points to a bogus entry, then bail.
264 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
265 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
267 PRINT_INTERN
=bad_prform
271 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
273 ( echo "$COMMAND: could not copy $PR_FORM" ; xs
=1; exit )
275 for file in $TEMP $REF ; do
276 cat > $file << '__EOF__'
277 SEND-PR
: -*- send-pr
-*-
278 SEND-PR
: Lines starting with
`SEND-PR' will be removed automatically, as
279 SEND-PR: will all comments (text enclosed in `<' and `>').
281 SEND-PR
: Please consult the GCC manual
if you are not sure how to
282 SEND-PR
: fill out a problem report.
283 SEND-PR
: Note that the Synopsis field is mandatory. The Subject
(for
284 SEND-PR
: the
mail) will be made the same as Synopsis unless explicitly
287 SEND-PR
: Choose from the following categories
:
291 # Format the categories so they fit onto lines.
292 l
=`echo "$CATEGORIES" | \
293 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
294 END {print max + 1;}'`
296 if [ $c -eq 0 ]; then c
=1; fi
297 echo "$CATEGORIES" | \
298 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
299 { printf ("%-'$l'.'$l's", $0);
300 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
301 END { printf "\nSEND-PR:\n"; }' >> $file
303 cat >> $file << __EOF__
309 X-send-pr-version: $VERSION
313 >Submitter-Id: $SUBMITTER
314 >Originator: $ORIGINATOR
315 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
317 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
318 >Synopsis: $SYNOPSIS_C
319 >Severity: $SEVERITY_C
320 SEND-PR: critical GCC is completely not operational; no work-around known.
321 SEND-PR: serious GCC is not working properly; a work-around is possible.
322 SEND-PR: non-critical Report indicates minor problem.
323 >Priority: $PRIORITY_C
324 SEND-PR: medium The problem should be solved in the next release.
325 SEND-PR: low The problem should be solve in a future release.
326 >Category: $CATEGORY_C
327 >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)>
328 SEND-PR: doc-bug The doumentation is incorrect.
329 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
330 SEND-PR: rejects-legal GCC gives an error message for correct code.
331 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
332 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
333 SEND-PR: for correct code
334 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
335 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
336 SEND-PR: sw-bug Software bug of some other class than above
337 SEND-PR: change-request A feature in GCC is missing.
338 SEND-PR: support I need help with gcc.
339 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
341 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
342 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
343 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
348 configured with: @gcc_config_arguments@
359 if [ "$PRINT" = true
-o "$PRINT_INTERN" = true
]; then
365 if [ -z "$REQUEST_ID" ]; then
368 ed
-s $TEMP << '__EOF__'
369 /^Subject
/s
/^Subject
:.
*/Subject
: request
for a customer id
/
370 /^
>Category
/s
/^
>Category
:.
*/>Category
: send-pr
/
376 if cmp -s $REF $TEMP ; then
377 echo "$COMMAND: problem report not filled out, therefore not sent"
383 # Check the enumeration fields
385 # This is a "sed-subroutine" with one keyword parameter
386 # (with workaround for Sun sed bug)
399 while [ -z "$REQUEST_ID" ]; do
404 PATTERN
=">Confidential:"
405 CONFIDENTIAL
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
406 case "$CONFIDENTIAL" in
407 no
) CNT
=`expr $CNT + 1` ;;
408 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
414 SEVERITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
416 ""|non-critical|serious|critical
) CNT
=`expr $CNT + 1` ;;
417 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
423 PRIORITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
425 ""|low|medium
) CNT
=`expr $CNT + 1` ;;
426 high
) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
427 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
433 CATEGORY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
437 if [ "$C" = "$CATEGORY" ]; then FOUND
=true
; break ; fi
439 if [ -n "$FOUND" ]; then
442 if [ -z "$CATEGORY" ]; then
443 echo "$COMMAND: you must include a Category: field in your report."
445 echo "$COMMAND: \`$CATEGORY' is not a known category."
452 CLASS
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
454 ""|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` ;;
455 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
458 # 6) Check that synopsis is not empty
460 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev
/null
462 echo "$COMMAND: Synopsis must not be empty."
467 [ $CNT -lt 6 -a -z "$BATCH" ] &&
468 echo "Errors were found with the problem report."
471 if [ -z "$BATCH" ]; then
472 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
475 if [ $CNT -eq 6 ]; then
483 if [ -z "$BATCH" ]; then
484 echo "$COMMAND: the problem report remains in $BAD and is not sent."
485 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
488 echo "$COMMAND: the problem report is not sent."
504 # Make sure the mail has got a Subject. If not, use the same as
508 if grep '^Subject:[ ]*$' $TEMP > /dev
/null
510 SYNOPSIS
=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
511 ed
-s $TEMP << __EOF__
512 /^Subject:/s/:.*\$/: $SYNOPSIS/
519 # Remove comments and send the problem report
520 # (we have to use patterns, where the comment contains regex chars)
522 # /^>Originator:/s;$ORIGINATOR;;
525 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
526 /^>Confidential:/s;<.*>;;
527 /^>Synopsis:/s;$SYNOPSIS_C;;
528 /^>Severity:/s;<.*>;;
529 /^>Priority:/s;<.*>;;
530 /^>Category:/s;$CATEGORY_C;;
532 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
533 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
534 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
535 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
536 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
539 if $MAIL_AGENT < $REF; then
540 echo "$COMMAND: problem report sent"
543 echo "$COMMAND: mysterious mail failure."
544 if [ -z "$BATCH" ]; then
545 echo "$COMMAND: the problem report remains in $BAD and is not sent."
546 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
549 echo "$COMMAND: the problem report is not sent."