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
85 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $BAD $REF"
92 mkdir
$TEMPD ||
exit 1
93 REMOVE_TEMP
="rm -rf $TEMPD"
97 if [ "$LOGNAME" = "" ]; then
98 if [ "$USER" != "" ]; then
106 REPLY_TO
="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
108 # Find out the name of the originator of this PR.
109 if [ -n "$NAME" ]; then
111 elif [ -f $HOME/.fullname
]; then
112 ORIGINATOR
="`sed -e '1q' $HOME/.fullname`"
114 # Must use temp file due to incompatibilities in quoting behavior
115 # and to protect shell metacharacters in the expansion of $LOGNAME
116 $PASSWD |
grep "^$LOGNAME:" |
awk -F: '{print $5}' |
sed -e 's/,.*//' > $TEMP0
117 ORIGINATOR
="`cat $TEMP0`"
121 if [ -n "$ORGANIZATION" ]; then
122 if [ -f "$ORGANIZATION" ]; then
123 ORGANIZATION
="`cat $ORGANIZATION`"
126 if [ -n "$DEFAULT_ORGANIZATION" ]; then
127 ORGANIZATION
="$DEFAULT_ORGANIZATION"
128 elif [ -f $HOME/.organization
]; then
129 ORGANIZATION
="`cat $HOME/.organization`"
133 # If they don't have a preferred editor set, then use
134 if [ -z "$VISUAL" ]; then
135 if [ -z "$EDITOR" ]; then
144 # Find out some information.
145 SYSTEM
=`( [ -f /bin/uname ] && /bin/uname -a ) || \
146 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
147 ARCH
=`[ -f /bin/arch ] && /bin/arch`
148 MACHINE
=`[ -f /bin/machine ] && /bin/machine`
150 COMMAND
=`echo $0 | sed -e 's,.*/,,'`
151 USAGE
="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
152 [-c address] [--request-id] [--version]"
158 while [ $# -gt 0 ]; do
160 -r) ;; # Ignore for backward compat.
161 -t |
--to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
162 shift ; GNATS_ADDR
="$1"
163 EXPLICIT_GNATS_ADDR
=true
165 -f |
--file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
167 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
168 echo "$COMMAND: cannot read $IN_FILE"
173 -b |
--batch) BATCH
=true
;;
174 -c |
--cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
177 -s |
--severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
178 shift ; SEVERITY_C
="$1"
180 -p |
-P |
--print) PRINT
=true
;;
181 -L |
--list) FORMAT
=norm
;;
182 -l |
-CL |
--lisp) FORMAT
=lisp
;;
183 --request-id) REQUEST_ID
=true
;;
184 -h |
--help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
185 -V |
--version) echo "$VERSION"; $REMOVE_TEMP; exit 0 ;;
186 -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
187 *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
192 # spam does not need to be listed here
193 CATEGORIES
="bootstrap c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
196 lisp
) echo "$CATEGORIES" | \
197 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
201 norm
) l
=`echo "$CATEGORIES" | \
202 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
203 END {print max + 1;}'`
205 if [ $c -eq 0 ]; then c
=1; fi
206 echo "$CATEGORIES" | \
207 awk 'BEGIN {print "Known categories:"; i = 0 }
208 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
215 ORIGINATOR_C
='<name of the PR author (one line)>'
216 ORGANIZATION_C
='<organization of PR author (multiple lines)>'
217 SYNOPSIS_C
='<synopsis of the problem (one line)>'
218 if [ -z "$SEVERITY_C" ]; then
219 SEVERITY_C
='<[ non-critical | serious | critical ] (one line)>'
221 PRIORITY_C
='<[ low | medium ] (one line)>'
222 CATEGORY_C
='<choose from the top of this file (one line)>'
223 RELEASE_C
='<release number or tag (one line)>'
224 ENVIRONMENT_C
='<machine, os, target, libraries (multiple lines)>'
225 DESCRIPTION_C
='<precise description of the problem (multiple lines)>'
226 HOW_TO_REPEAT_C
='<When reporting a compiler error, preprocessor output must be included>'
227 FIX_C
='<how to correct or work around the problem, if known (multiple lines)>'
229 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
231 trap '$REMOVE_TEMP; exit $xs' 0
232 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
234 # If they told us to use a specific file, then do so.
235 if [ -n "$IN_FILE" ]; then
236 if [ "$IN_FILE" = "-" ]; then
237 # The PR is coming from the standard input.
238 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
239 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
244 # Use the file they named.
245 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
246 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
253 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
254 # If their PR_FORM points to a bogus entry, then bail.
255 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
256 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
258 PRINT_INTERN
=bad_prform
262 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
264 ( echo "$COMMAND: could not copy $PR_FORM" ; xs
=1; exit )
266 for file in $TEMP $REF ; do
267 cat > $file << '__EOF__'
268 SEND-PR
: -*- send-pr
-*-
269 SEND-PR
: Lines starting with
`SEND-PR' will be removed automatically, as
270 SEND-PR: will all comments (text enclosed in `<' and `>').
272 SEND-PR
: Please consult the GCC manual
if you are not sure how to
273 SEND-PR
: fill out a problem report.
274 SEND-PR
: Note that the Synopsis field is mandatory. The Subject
(for
275 SEND-PR
: the
mail) will be made the same as Synopsis unless explicitly
278 SEND-PR
: Choose from the following categories
:
282 # Format the categories so they fit onto lines.
283 l
=`echo "$CATEGORIES" | \
284 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
285 END {print max + 1;}'`
287 if [ $c -eq 0 ]; then c
=1; fi
288 echo "$CATEGORIES" | \
289 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
290 { printf ("%-'$l'.'$l's", $0);
291 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
292 END { printf "\nSEND-PR:\n"; }' >> $file
294 cat >> $file << __EOF__
300 X-send-pr-version: $VERSION
304 >Submitter-Id: $SUBMITTER
305 >Originator: $ORIGINATOR
306 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
308 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
309 >Synopsis: $SYNOPSIS_C
310 >Severity: $SEVERITY_C
311 SEND-PR: critical GCC is completely not operational; no work-around known.
312 SEND-PR: serious GCC is not working properly; a work-around is possible.
313 SEND-PR: non-critical Report indicates minor problem.
314 >Priority: $PRIORITY_C
315 SEND-PR: medium The problem should be solved in the next release.
316 SEND-PR: low The problem should be solve in a future release.
317 >Category: $CATEGORY_C
318 >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)>
319 SEND-PR: doc-bug The documentation is incorrect.
320 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
321 SEND-PR: rejects-legal GCC gives an error message for correct code.
322 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
323 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
324 SEND-PR: for correct code
325 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
326 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
327 SEND-PR: sw-bug Software bug of some other class than above
328 SEND-PR: change-request A feature in GCC is missing.
329 SEND-PR: support I need help with gcc.
330 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
332 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
333 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
334 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
339 configured with: @gcc_config_arguments@
350 if [ "$PRINT" = true
-o "$PRINT_INTERN" = true
]; then
356 if [ -z "$REQUEST_ID" ]; then
359 ed
-s $TEMP << '__EOF__'
360 /^Subject
/s
/^Subject
:.
*/Subject
: request
for a customer id
/
361 /^
>Category
/s
/^
>Category
:.
*/>Category
: send-pr
/
367 if cmp -s $REF $TEMP ; then
368 echo "$COMMAND: problem report not filled out, therefore not sent"
374 # Check the enumeration fields
376 # This is a "sed-subroutine" with one keyword parameter
377 # (with workaround for Sun sed bug)
390 while [ -z "$REQUEST_ID" ]; do
395 PATTERN
=">Confidential:"
396 CONFIDENTIAL
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
397 case "$CONFIDENTIAL" in
398 no
) CNT
=`expr $CNT + 1` ;;
399 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
405 SEVERITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
407 ""|non-critical|serious|critical
) CNT
=`expr $CNT + 1` ;;
408 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
414 PRIORITY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
416 ""|low|medium
) CNT
=`expr $CNT + 1` ;;
417 high
) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
418 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
424 CATEGORY
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
428 if [ "$C" = "$CATEGORY" ]; then FOUND
=true
; break ; fi
430 if [ -n "$FOUND" ]; then
433 if [ -z "$CATEGORY" ]; then
434 echo "$COMMAND: you must include a Category: field in your report."
436 echo "$COMMAND: \`$CATEGORY' is not a known category."
443 CLASS
=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
445 ""|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` ;;
446 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
449 # 6) Check that synopsis is not empty
451 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev
/null
453 echo "$COMMAND: Synopsis must not be empty."
458 [ $CNT -lt 6 -a -z "$BATCH" ] &&
459 echo "Errors were found with the problem report."
462 if [ -z "$BATCH" ]; then
463 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
466 if [ $CNT -eq 6 ]; then
474 if [ -z "$BATCH" ]; then
475 echo "$COMMAND: the problem report remains in $BAD and is not sent."
476 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
479 echo "$COMMAND: the problem report is not sent."
495 # Make sure the mail has got a Subject. If not, use the same as
499 if grep '^Subject:[ ]*$' $TEMP > /dev
/null
501 SYNOPSIS
=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
502 ed
-s $TEMP << __EOF__
503 /^Subject:/s/:.*\$/: $SYNOPSIS/
510 # Remove comments and send the problem report
511 # (we have to use patterns, where the comment contains regex chars)
513 # /^>Originator:/s;$ORIGINATOR;;
516 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
517 /^>Confidential:/s;<.*>;;
518 /^>Synopsis:/s;$SYNOPSIS_C;;
519 /^>Severity:/s;<.*>;;
520 /^>Priority:/s;<.*>;;
521 /^>Category:/s;$CATEGORY_C;;
523 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
524 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
525 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
526 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
527 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
530 if $MAIL_AGENT < $REF; then
531 echo "$COMMAND: problem report sent"
534 echo "$COMMAND: mysterious mail failure."
535 if [ -z "$BATCH" ]; then
536 echo "$COMMAND: the problem report remains in $BAD and is not sent."
537 REMOVE_TEMP
="rm -f $TEMP0 $TEMP $REF"
540 echo "$COMMAND: the problem report is not sent."