xref: /netbsd-src/external/gpl2/xcvs/dist/src/cvsbug.in (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847Schristos#! /bin/sh
2*a7c91847Schristos# Submit a problem report to a GNATS site.
3*a7c91847Schristos# Copyright (C) 1993 Free Software Foundation, Inc.
4*a7c91847Schristos# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5*a7c91847Schristos# version written by Heinz G. Seidl (hgs@ide.com).
6*a7c91847Schristos#
7*a7c91847Schristos# This file is part of GNU GNATS.
8*a7c91847Schristos# Modified by Berliner for CVS.
9*a7c91847Schristos#
10*a7c91847Schristos# GNU GNATS is free software; you can redistribute it and/or modify
11*a7c91847Schristos# it under the terms of the GNU General Public License as published by
12*a7c91847Schristos# the Free Software Foundation; either version 2, or (at your option)
13*a7c91847Schristos# any later version.
14*a7c91847Schristos#
15*a7c91847Schristos# GNU GNATS is distributed in the hope that it will be useful,
16*a7c91847Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*a7c91847Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*a7c91847Schristos# GNU General Public License for more details.
19*a7c91847Schristos
20*a7c91847Schristos# The version of this send-pr.
21*a7c91847SchristosVERSION=3.2
22*a7c91847Schristos
23*a7c91847Schristos# The submitter-id for your site.
24*a7c91847SchristosSUBMITTER=net
25*a7c91847Schristos
26*a7c91847Schristos## # Where the GNATS directory lives, if at all.
27*a7c91847Schristos## [ -z "$GNATS_ROOT" ] &&
28*a7c91847Schristos## GNATS_ROOT=/usr/local/lib/gnats/gnats-db
29*a7c91847Schristos
30*a7c91847Schristos# The default mail address for PR submissions.
31*a7c91847SchristosGNATS_ADDR=@PACKAGE_BUGREPORT@
32*a7c91847Schristos
33*a7c91847Schristos## # Where the gnats category tree lives.
34*a7c91847Schristos## DATADIR=/usr/local/lib
35*a7c91847Schristos
36*a7c91847Schristos## # If we've been moved around, try using GCC_EXEC_PREFIX.
37*a7c91847Schristos## [ ! -d $DATADIR/gnats -a -d "$GCC_EXEC_PREFIX" ] && DATADIR=${GCC_EXEC_PREFIX}..
38*a7c91847Schristos
39*a7c91847Schristos# The default release for this host.
40*a7c91847SchristosDEFAULT_RELEASE="@VERSION@"
41*a7c91847Schristos
42*a7c91847Schristos# The default organization.
43*a7c91847SchristosDEFAULT_ORGANIZATION="net"
44*a7c91847Schristos
45*a7c91847Schristos## # The default site to look for.
46*a7c91847Schristos## GNATS_SITE=unknown
47*a7c91847Schristos
48*a7c91847Schristos## # Newer config information?
49*a7c91847Schristos## [ -f ${GNATS_ROOT}/gnats-adm/config ] && . ${GNATS_ROOT}/gnats-adm/config
50*a7c91847Schristos
51*a7c91847Schristos# Hack mktemp on systems that don't have it.
52*a7c91847Schristos@MKTEMP_SH_FUNCTION@
53*a7c91847SchristosMKTEMP="@MKTEMP@"
54*a7c91847Schristos
55*a7c91847Schristos# What mailer to use.  This must come after the config file, since it is
56*a7c91847Schristos# host-dependent.
57*a7c91847SchristosSENDMAIL="@SENDMAIL@"
58*a7c91847SchristosMAIL_AGENT="$SENDMAIL -oi -t"
59*a7c91847SchristosMAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
60*a7c91847Schristosif [ ! -f "$MAILER" ] ; then
61*a7c91847Schristos	echo "$COMMAND: Cannot find mail program \"$MAILER\"."
62*a7c91847Schristos	echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
63*a7c91847Schristos	exit 1
64*a7c91847Schristosfi
65*a7c91847Schristos
66*a7c91847Schristosif test "`echo -n foo`" = foo ; then
67*a7c91847Schristos  ECHON=bsd
68*a7c91847Schristoselif test "`echo 'foo\c'`" = foo ; then
69*a7c91847Schristos  ECHON=sysv
70*a7c91847Schristoselse
71*a7c91847Schristos  ECHON=none
72*a7c91847Schristosfi
73*a7c91847Schristos
74*a7c91847Schristosif [ $ECHON = bsd ] ; then
75*a7c91847Schristos  ECHON1="echo -n"
76*a7c91847Schristos  ECHON2=
77*a7c91847Schristoselif [ $ECHON = sysv ] ; then
78*a7c91847Schristos  ECHON1=echo
79*a7c91847Schristos  ECHON2='\c'
80*a7c91847Schristoselse
81*a7c91847Schristos  ECHON1=echo
82*a7c91847Schristos  ECHON2=
83*a7c91847Schristosfi
84*a7c91847Schristos
85*a7c91847Schristos#
86*a7c91847Schristos
87*a7c91847Schristos[ -z "$TMPDIR" ] && TMPDIR=/tmp
88*a7c91847Schristos
89*a7c91847SchristosTEMP="`$MKTEMP $TMPDIR/p.XXXXXX`"
90*a7c91847SchristosBAD="`$MKTEMP $TMPDIR/pbad.XXXXXX`"
91*a7c91847SchristosREF="`$MKTEMP $TMPDIR/pf.XXXXXX`"
92*a7c91847Schristos
93*a7c91847Schristosif [ -z "$LOGNAME" -a -n "$USER" ]; then
94*a7c91847Schristos  LOGNAME=$USER
95*a7c91847Schristosfi
96*a7c91847Schristos
97*a7c91847SchristosFROM="$LOGNAME"
98*a7c91847SchristosREPLY_TO="$LOGNAME"
99*a7c91847Schristos
100*a7c91847Schristos# Find out the name of the originator of this PR.
101*a7c91847Schristosif [ -n "$NAME" ]; then
102*a7c91847Schristos  ORIGINATOR="$NAME"
103*a7c91847Schristoselif [ -f $HOME/.fullname ]; then
104*a7c91847Schristos  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
105*a7c91847Schristoselif [ -f /bin/domainname ]; then
106*a7c91847Schristos  if [ "`/bin/domainname`" != "" -a -f /usr/bin/ypcat ]; then
107*a7c91847Schristos    # Must use temp file due to incompatibilities in quoting behavior
108*a7c91847Schristos    # and to protect shell metacharacters in the expansion of $LOGNAME
109*a7c91847Schristos    /usr/bin/ypcat passwd 2>/dev/null | cat - /etc/passwd | grep "^$LOGNAME:" |
110*a7c91847Schristos      cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
111*a7c91847Schristos    ORIGINATOR="`cat $TEMP`"
112*a7c91847Schristos    rm -f $TEMP
113*a7c91847Schristos  fi
114*a7c91847Schristosfi
115*a7c91847Schristos
116*a7c91847Schristosif [ "$ORIGINATOR" = "" ]; then
117*a7c91847Schristos  grep "^$LOGNAME:" /etc/passwd | cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
118*a7c91847Schristos  ORIGINATOR="`cat $TEMP`"
119*a7c91847Schristos  rm -f $TEMP
120*a7c91847Schristosfi
121*a7c91847Schristos
122*a7c91847Schristosif [ -n "$ORGANIZATION" ]; then
123*a7c91847Schristos  if [ -f "$ORGANIZATION" ]; then
124*a7c91847Schristos    ORGANIZATION="`cat $ORGANIZATION`"
125*a7c91847Schristos  fi
126*a7c91847Schristoselse
127*a7c91847Schristos  if [ -n "$DEFAULT_ORGANIZATION" ]; then
128*a7c91847Schristos    ORGANIZATION="$DEFAULT_ORGANIZATION"
129*a7c91847Schristos  elif [ -f $HOME/.organization ]; then
130*a7c91847Schristos    ORGANIZATION="`cat $HOME/.organization`"
131*a7c91847Schristos  elif [ -f $HOME/.signature ]; then
132*a7c91847Schristos    ORGANIZATION="`cat $HOME/.signature`"
133*a7c91847Schristos  fi
134*a7c91847Schristosfi
135*a7c91847Schristos
136*a7c91847Schristos# If they don't have a preferred editor set, then use
137*a7c91847Schristosif [ -z "$VISUAL" ]; then
138*a7c91847Schristos  if [ -z "$EDITOR" ]; then
139*a7c91847Schristos    EDIT=vi
140*a7c91847Schristos  else
141*a7c91847Schristos    EDIT="$EDITOR"
142*a7c91847Schristos  fi
143*a7c91847Schristoselse
144*a7c91847Schristos  EDIT="$VISUAL"
145*a7c91847Schristosfi
146*a7c91847Schristos
147*a7c91847Schristos# Find out some information.
148*a7c91847SchristosSYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
149*a7c91847Schristos        ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
150*a7c91847SchristosARCH=`[ -f /bin/arch ] && /bin/arch`
151*a7c91847SchristosMACHINE=`[ -f /bin/machine ] && /bin/machine`
152*a7c91847Schristos
153*a7c91847SchristosCOMMAND=`echo $0 | sed -e 's,.*/,,'`
154*a7c91847Schristos## USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [--request-id]
155*a7c91847SchristosUSAGE="Usage: $COMMAND [-PVL]
156*a7c91847Schristos[--version]"
157*a7c91847SchristosREMOVE=
158*a7c91847SchristosBATCH=
159*a7c91847Schristos
160*a7c91847Schristoswhile [ $# -gt 0 ]; do
161*a7c91847Schristos  case "$1" in
162*a7c91847Schristos    -r) ;; 		# Ignore for backward compat.
163*a7c91847Schristos##     -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
164*a7c91847Schristos## 	shift ; GNATS_ADDR="$1"
165*a7c91847Schristos## 	EXPLICIT_GNATS_ADDR=true
166*a7c91847Schristos##         ;;
167*a7c91847Schristos##     -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
168*a7c91847Schristos## 	shift ; IN_FILE="$1"
169*a7c91847Schristos## 	if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
170*a7c91847Schristos## 	  echo "$COMMAND: cannot read $IN_FILE"
171*a7c91847Schristos## 	  exit 1
172*a7c91847Schristos## 	fi
173*a7c91847Schristos## 	;;
174*a7c91847Schristos    -b | --batch) BATCH=true ;;
175*a7c91847Schristos    -p | -P | --print) PRINT=true ;;
176*a7c91847Schristos    -L | --list) FORMAT=norm ;;
177*a7c91847Schristos    -l | -CL | --lisp) FORMAT=lisp ;;
178*a7c91847Schristos##     --request-id) REQUEST_ID=true ;;
179*a7c91847Schristos    -h | --help) echo "$USAGE"; exit 0 ;;
180*a7c91847Schristos    -V | --version) echo "$VERSION"; exit 0 ;;
181*a7c91847Schristos    -*) echo "$USAGE" ; exit 1 ;;
182*a7c91847Schristos    *) echo "$USAGE" ; exit 1
183*a7c91847Schristos##        if [ -z "$USER_GNATS_SITE" ]; then
184*a7c91847Schristos## 	 if [ ! -r "$DATADIR/gnats/$1" ]; then
185*a7c91847Schristos## 	   echo "$COMMAND: the GNATS site $1 does not have a categories list."
186*a7c91847Schristos## 	   exit 1
187*a7c91847Schristos## 	 else
188*a7c91847Schristos## 	   # The site name is the alias they'll have to have created.
189*a7c91847Schristos## 	   USER_GNATS_SITE=$1
190*a7c91847Schristos## 	 fi
191*a7c91847Schristos##        else
192*a7c91847Schristos## 	 echo "$USAGE" ; exit 1
193*a7c91847Schristos##        fi
194*a7c91847Schristos       ;;
195*a7c91847Schristos esac
196*a7c91847Schristos shift
197*a7c91847Schristosdone
198*a7c91847Schristos
199*a7c91847Schristosif [ -n "$USER_GNATS_SITE" ]; then
200*a7c91847Schristos  GNATS_SITE=$USER_GNATS_SITE
201*a7c91847Schristos  GNATS_ADDR=$USER_GNATS_SITE-gnats
202*a7c91847Schristosfi
203*a7c91847Schristos
204*a7c91847Schristosif [ "$SUBMITTER" = "unknown" -a -z "$REQUEST_ID" -a -z "$IN_FILE" ]; then
205*a7c91847Schristos  cat << '__EOF__'
206*a7c91847SchristosIt seems that send-pr is not installed with your unique submitter-id.
207*a7c91847SchristosYou need to run
208*a7c91847Schristos
209*a7c91847Schristos          install-sid YOUR-SID
210*a7c91847Schristos
211*a7c91847Schristoswhere YOUR-SID is the identification code you received with `send-pr'.
212*a7c91847Schristos`send-pr' will automatically insert this value into the template field
213*a7c91847Schristos`>Submitter-Id'.  If you've downloaded `send-pr' from the Net, use `net'
214*a7c91847Schristosfor this value.  If you do not know your id, run `send-pr --request-id' to
215*a7c91847Schristosget one from your support site.
216*a7c91847Schristos__EOF__
217*a7c91847Schristos  exit 1
218*a7c91847Schristosfi
219*a7c91847Schristos
220*a7c91847Schristos## if [ -r "$DATADIR/gnats/$GNATS_SITE" ]; then
221*a7c91847Schristos##   CATEGORIES=`grep -v '^#' $DATADIR/gnats/$GNATS_SITE | sort`
222*a7c91847Schristos## else
223*a7c91847Schristos##   echo "$COMMAND: could not read $DATADIR/gnats/$GNATS_SITE for categories list."
224*a7c91847Schristos##   exit 1
225*a7c91847Schristos## fi
226*a7c91847SchristosCATEGORIES="contrib cvs doc pcl-cvs portability"
227*a7c91847Schristos
228*a7c91847Schristosif [ -z "$CATEGORIES" ]; then
229*a7c91847Schristos  echo "$COMMAND: the categories list for $GNATS_SITE was empty!"
230*a7c91847Schristos  exit 1
231*a7c91847Schristosfi
232*a7c91847Schristos
233*a7c91847Schristoscase "$FORMAT" in
234*a7c91847Schristos  lisp) echo "$CATEGORIES" | \
235*a7c91847Schristos        awk 'BEGIN {printf "( "}
236*a7c91847Schristos	     {printf "(\"%s\") ",$0}
237*a7c91847Schristos	     END {printf ")\n"}'
238*a7c91847Schristos        exit 0
239*a7c91847Schristos        ;;
240*a7c91847Schristos  norm) l=`echo "$CATEGORIES" | \
241*a7c91847Schristos	awk 'BEGIN {max = 0; }
242*a7c91847Schristos	     { if (length($0) > max) { max = length($0); } }
243*a7c91847Schristos	     END {print max + 1;}'`
244*a7c91847Schristos	c=`expr 70 / $l`
245*a7c91847Schristos	if [ $c -eq 0 ]; then c=1; fi
246*a7c91847Schristos	echo "$CATEGORIES" | \
247*a7c91847Schristos        awk 'BEGIN {print "Known categories:"; i = 0 }
248*a7c91847Schristos          { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
249*a7c91847Schristos            END { print ""; }'
250*a7c91847Schristos        exit 0
251*a7c91847Schristos        ;;
252*a7c91847Schristosesac
253*a7c91847Schristos
254*a7c91847SchristosORIGINATOR_C='<name of the PR author (one line)>'
255*a7c91847SchristosORGANIZATION_C='<organization of PR author (multiple lines)>'
256*a7c91847SchristosCONFIDENTIAL_C='<[ yes | no ] (one line)>'
257*a7c91847SchristosSYNOPSIS_C='<synopsis of the problem (one line)>'
258*a7c91847SchristosSEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
259*a7c91847SchristosPRIORITY_C='<[ low | medium | high ] (one line)>'
260*a7c91847SchristosCATEGORY_C='<name of the product (one line)>'
261*a7c91847SchristosCLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
262*a7c91847SchristosRELEASE_C='<release number or tag (one line)>'
263*a7c91847SchristosENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
264*a7c91847SchristosDESCRIPTION_C='<precise description of the problem (multiple lines)>'
265*a7c91847SchristosHOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
266*a7c91847SchristosFIX_C='<how to correct or work around the problem, if known (multiple lines)>'
267*a7c91847Schristos
268*a7c91847Schristos# Catch some signals. ($xs kludge needed by Sun /bin/sh)
269*a7c91847Schristosxs=0
270*a7c91847Schristostrap 'rm -f $REF $TEMP; exit $xs' 0
271*a7c91847Schristostrap 'echo "$COMMAND: Aborting ..."; rm -f $REF $TEMP; xs=1; exit' 1 2 3 13 15
272*a7c91847Schristos
273*a7c91847Schristos# If they told us to use a specific file, then do so.
274*a7c91847Schristosif [ -n "$IN_FILE" ]; then
275*a7c91847Schristos  if [ "$IN_FILE" = "-" ]; then
276*a7c91847Schristos    # The PR is coming from the standard input.
277*a7c91847Schristos    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
278*a7c91847Schristos      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
279*a7c91847Schristos    else
280*a7c91847Schristos      cat > $TEMP
281*a7c91847Schristos    fi
282*a7c91847Schristos  else
283*a7c91847Schristos    # Use the file they named.
284*a7c91847Schristos    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
285*a7c91847Schristos      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
286*a7c91847Schristos    else
287*a7c91847Schristos      cat $IN_FILE > $TEMP
288*a7c91847Schristos    fi
289*a7c91847Schristos  fi
290*a7c91847Schristoselse
291*a7c91847Schristos
292*a7c91847Schristos  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
293*a7c91847Schristos    # If their PR_FORM points to a bogus entry, then bail.
294*a7c91847Schristos    if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
295*a7c91847Schristos      echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
296*a7c91847Schristos      sleep 1
297*a7c91847Schristos      PRINT_INTERN=bad_prform
298*a7c91847Schristos    fi
299*a7c91847Schristos  fi
300*a7c91847Schristos
301*a7c91847Schristos  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
302*a7c91847Schristos    cp $PR_FORM $TEMP ||
303*a7c91847Schristos      ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
304*a7c91847Schristos  else
305*a7c91847Schristos    for file in $TEMP $REF ; do
306*a7c91847Schristos      cat  > $file << '__EOF__'
307*a7c91847SchristosSEND-PR: -*- send-pr -*-
308*a7c91847SchristosSEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
309*a7c91847SchristosSEND-PR: will all comments (text enclosed in `<' and `>').
310*a7c91847SchristosSEND-PR:
311*a7c91847SchristosSEND-PR: Choose from the following categories:
312*a7c91847SchristosSEND-PR:
313*a7c91847Schristos__EOF__
314*a7c91847Schristos
315*a7c91847Schristos      # Format the categories so they fit onto lines.
316*a7c91847Schristos	l=`echo "$CATEGORIES" | \
317*a7c91847Schristos	awk 'BEGIN {max = 0; }
318*a7c91847Schristos	     { if (length($0) > max) { max = length($0); } }
319*a7c91847Schristos	     END {print max + 1;}'`
320*a7c91847Schristos	c=`expr 61 / $l`
321*a7c91847Schristos	if [ $c -eq 0 ]; then c=1; fi
322*a7c91847Schristos	echo "$CATEGORIES" | \
323*a7c91847Schristos        awk 'BEGIN {printf "SEND-PR: "; i = 0 }
324*a7c91847Schristos          { printf ("%-'$l'.'$l's", $0);
325*a7c91847Schristos	    if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
326*a7c91847Schristos            END { printf "\nSEND-PR:\n"; }' >> $file
327*a7c91847Schristos
328*a7c91847Schristos      cat >> $file << __EOF__
329*a7c91847SchristosTo: $GNATS_ADDR
330*a7c91847SchristosSubject:
331*a7c91847SchristosFrom: $FROM
332*a7c91847SchristosReply-To: $REPLY_TO
333*a7c91847SchristosX-send-pr-version: $VERSION
334*a7c91847Schristos
335*a7c91847Schristos
336*a7c91847Schristos>Submitter-Id:   $SUBMITTER
337*a7c91847Schristos>Originator: 	 $ORIGINATOR
338*a7c91847Schristos>Organization:
339*a7c91847Schristos${ORGANIZATION-$ORGANIZATION_C}
340*a7c91847Schristos>Confidential:  $CONFIDENTIAL_C
341*a7c91847Schristos>Synopsis:	$SYNOPSIS_C
342*a7c91847Schristos>Severity:	$SEVERITY_C
343*a7c91847Schristos>Priority:	$PRIORITY_C
344*a7c91847Schristos>Category: 	$CATEGORY_C
345*a7c91847Schristos>Class:		$CLASS_C
346*a7c91847Schristos>Release:	${DEFAULT_RELEASE-$RELEASE_C}
347*a7c91847Schristos>Environment:
348*a7c91847Schristos    	$ENVIRONMENT_C
349*a7c91847Schristos`[ -n "$SYSTEM" ] && echo System: $SYSTEM`
350*a7c91847Schristos`[ -n "$ARCH" ] && echo Architecture: $ARCH`
351*a7c91847Schristos`[ -n "$MACHINE" ] && echo Machine: $MACHINE`
352*a7c91847Schristos>Description:
353*a7c91847Schristos	$DESCRIPTION_C
354*a7c91847Schristos>How-To-Repeat:
355*a7c91847Schristos	$HOW_TO_REPEAT_C
356*a7c91847Schristos>Fix:
357*a7c91847Schristos	$FIX_C
358*a7c91847Schristos__EOF__
359*a7c91847Schristos    done
360*a7c91847Schristos  fi
361*a7c91847Schristos
362*a7c91847Schristos  if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
363*a7c91847Schristos    cat $TEMP
364*a7c91847Schristos    xs=0; exit
365*a7c91847Schristos  fi
366*a7c91847Schristos
367*a7c91847Schristos  chmod u+w $TEMP
368*a7c91847Schristos  if [ -z "$REQUEST_ID" ]; then
369*a7c91847Schristos    eval $EDIT $TEMP
370*a7c91847Schristos  else
371*a7c91847Schristos    ed -s $TEMP << '__EOF__'
372*a7c91847Schristos/^Subject/s/^Subject:.*/Subject: request for a customer id/
373*a7c91847Schristos/^>Category/s/^>Category:.*/>Category: send-pr/
374*a7c91847Schristosw
375*a7c91847Schristosq
376*a7c91847Schristos__EOF__
377*a7c91847Schristos  fi
378*a7c91847Schristos
379*a7c91847Schristos  if cmp -s $REF $TEMP ; then
380*a7c91847Schristos    echo "$COMMAND: problem report not filled out, therefore not sent"
381*a7c91847Schristos    xs=1; exit
382*a7c91847Schristos  fi
383*a7c91847Schristosfi
384*a7c91847Schristos
385*a7c91847Schristos#
386*a7c91847Schristos#	Check the enumeration fields
387*a7c91847Schristos
388*a7c91847Schristos# This is a "sed-subroutine" with one keyword parameter
389*a7c91847Schristos# (with workaround for Sun sed bug)
390*a7c91847Schristos#
391*a7c91847SchristosSED_CMD='
392*a7c91847Schristos/$PATTERN/{
393*a7c91847Schristoss|||
394*a7c91847Schristoss|<.*>||
395*a7c91847Schristoss|^[ 	]*||
396*a7c91847Schristoss|[ 	]*$||
397*a7c91847Schristosp
398*a7c91847Schristosq
399*a7c91847Schristos}'
400*a7c91847Schristos
401*a7c91847Schristos
402*a7c91847Schristoswhile [ -z "$REQUEST_ID" ]; do
403*a7c91847Schristos  CNT=0
404*a7c91847Schristos
405*a7c91847Schristos  # 1) Confidential
406*a7c91847Schristos  #
407*a7c91847Schristos  PATTERN=">Confidential:"
408*a7c91847Schristos  CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
409*a7c91847Schristos  case "$CONFIDENTIAL" in
410*a7c91847Schristos    ""|yes|no) CNT=`expr $CNT + 1` ;;
411*a7c91847Schristos    *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
412*a7c91847Schristos  esac
413*a7c91847Schristos  #
414*a7c91847Schristos  # 2) Severity
415*a7c91847Schristos  #
416*a7c91847Schristos  PATTERN=">Severity:"
417*a7c91847Schristos  SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
418*a7c91847Schristos  case "$SEVERITY" in
419*a7c91847Schristos    ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
420*a7c91847Schristos    *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
421*a7c91847Schristos  esac
422*a7c91847Schristos  #
423*a7c91847Schristos  # 3) Priority
424*a7c91847Schristos  #
425*a7c91847Schristos  PATTERN=">Priority:"
426*a7c91847Schristos  PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
427*a7c91847Schristos  case "$PRIORITY" in
428*a7c91847Schristos    ""|low|medium|high) CNT=`expr $CNT + 1` ;;
429*a7c91847Schristos    *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
430*a7c91847Schristos  esac
431*a7c91847Schristos  #
432*a7c91847Schristos  # 4) Category
433*a7c91847Schristos  #
434*a7c91847Schristos  PATTERN=">Category:"
435*a7c91847Schristos  CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
436*a7c91847Schristos  FOUND=
437*a7c91847Schristos  for C in $CATEGORIES
438*a7c91847Schristos  do
439*a7c91847Schristos    if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
440*a7c91847Schristos  done
441*a7c91847Schristos  if [ -n "$FOUND" ]; then
442*a7c91847Schristos    CNT=`expr $CNT + 1`
443*a7c91847Schristos  else
444*a7c91847Schristos    if [ -z "$CATEGORY" ]; then
445*a7c91847Schristos      echo "$COMMAND: you must include a Category: field in your report."
446*a7c91847Schristos    else
447*a7c91847Schristos      echo "$COMMAND: \`$CATEGORY' is not a known category."
448*a7c91847Schristos    fi
449*a7c91847Schristos  fi
450*a7c91847Schristos  #
451*a7c91847Schristos  # 5) Class
452*a7c91847Schristos  #
453*a7c91847Schristos  PATTERN=">Class:"
454*a7c91847Schristos  CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
455*a7c91847Schristos  case "$CLASS" in
456*a7c91847Schristos    ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
457*a7c91847Schristos    *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
458*a7c91847Schristos  esac
459*a7c91847Schristos
460*a7c91847Schristos  [ $CNT -lt 5 -a -z "$BATCH" ] &&
461*a7c91847Schristos    echo "Errors were found with the problem report."
462*a7c91847Schristos
463*a7c91847Schristos  while true; do
464*a7c91847Schristos    if [ -z "$BATCH" ]; then
465*a7c91847Schristos      $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
466*a7c91847Schristos      read input
467*a7c91847Schristos    else
468*a7c91847Schristos      if [ $CNT -eq 5 ]; then
469*a7c91847Schristos        input=s
470*a7c91847Schristos      else
471*a7c91847Schristos        input=a
472*a7c91847Schristos      fi
473*a7c91847Schristos    fi
474*a7c91847Schristos    case "$input" in
475*a7c91847Schristos      a*)
476*a7c91847Schristos	if [ -z "$BATCH" ]; then
477*a7c91847Schristos	  echo "$COMMAND: the problem report remains in $BAD and is not sent."
478*a7c91847Schristos	  mv $TEMP $BAD
479*a7c91847Schristos        else
480*a7c91847Schristos	  echo "$COMMAND: the problem report is not sent."
481*a7c91847Schristos	fi
482*a7c91847Schristos	xs=1; exit
483*a7c91847Schristos	;;
484*a7c91847Schristos      e*)
485*a7c91847Schristos        eval $EDIT $TEMP
486*a7c91847Schristos	continue 2
487*a7c91847Schristos	;;
488*a7c91847Schristos      s*)
489*a7c91847Schristos	break 2
490*a7c91847Schristos	;;
491*a7c91847Schristos    esac
492*a7c91847Schristos  done
493*a7c91847Schristosdone
494*a7c91847Schristos#
495*a7c91847Schristos#	Remove comments and send the problem report
496*a7c91847Schristos#	(we have to use patterns, where the comment contains regex chars)
497*a7c91847Schristos#
498*a7c91847Schristos# /^>Originator:/s;$ORIGINATOR;;
499*a7c91847Schristossed  -e "
500*a7c91847Schristos/^SEND-PR:/d
501*a7c91847Schristos/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
502*a7c91847Schristos/^>Confidential:/s;<.*>;;
503*a7c91847Schristos/^>Synopsis:/s;$SYNOPSIS_C;;
504*a7c91847Schristos/^>Severity:/s;<.*>;;
505*a7c91847Schristos/^>Priority:/s;<.*>;;
506*a7c91847Schristos/^>Category:/s;$CATEGORY_C;;
507*a7c91847Schristos/^>Class:/s;<.*>;;
508*a7c91847Schristos/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
509*a7c91847Schristos/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
510*a7c91847Schristos/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
511*a7c91847Schristos/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
512*a7c91847Schristos/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
513*a7c91847Schristos" $TEMP > $REF
514*a7c91847Schristos
515*a7c91847Schristosif $MAIL_AGENT < $REF; then
516*a7c91847Schristos  echo "$COMMAND: problem report sent"
517*a7c91847Schristos  xs=0; exit
518*a7c91847Schristoselse
519*a7c91847Schristos  echo "$COMMAND: mysterious mail failure."
520*a7c91847Schristos  if [ -z "$BATCH" ]; then
521*a7c91847Schristos    echo "$COMMAND: the problem report remains in $BAD and is not sent."
522*a7c91847Schristos    mv $REF $BAD
523*a7c91847Schristos  else
524*a7c91847Schristos    echo "$COMMAND: the problem report is not sent."
525*a7c91847Schristos  fi
526*a7c91847Schristos  xs=1; exit
527*a7c91847Schristosfi
528