#! /bin/sh
# Submit a problem report to a GNATS site.
# Copyright (C) 1993 Free Software Foundation, Inc.
# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
# version written by Heinz G. Seidl (hgs@ide.com).
#
# This file is part of GNU GNATS.
# Modified by Berliner for CVS.
#
# GNU GNATS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU GNATS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# The version of this send-pr.
VERSION=3.2
# The submitter-id for your site.
SUBMITTER=net
## # Where the GNATS directory lives, if at all.
## [ -z "$GNATS_ROOT" ] &&
## GNATS_ROOT=/usr/local/lib/gnats/gnats-db
# The default mail address for PR submissions.
GNATS_ADDR=bug-cvs@nongnu.org
## # Where the gnats category tree lives.
## DATADIR=/usr/local/lib
## # If we've been moved around, try using GCC_EXEC_PREFIX.
## [ ! -d $DATADIR/gnats -a -d "$GCC_EXEC_PREFIX" ] && DATADIR=${GCC_EXEC_PREFIX}..
# The default release for this host.
DEFAULT_RELEASE="1.11.23"
# The default organization.
DEFAULT_ORGANIZATION="net"
## # The default site to look for.
## GNATS_SITE=unknown
## # Newer config information?
## [ -f ${GNATS_ROOT}/gnats-adm/config ] && . ${GNATS_ROOT}/gnats-adm/config
# Hack mktemp on systems that don't have it.
MKTEMP="/bin/mktemp"
# What mailer to use. This must come after the config file, since it is
# host-dependent.
SENDMAIL="no"
MAIL_AGENT="$SENDMAIL -oi -t"
MAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
if [ ! -f "$MAILER" ] ; then
echo "$COMMAND: Cannot find mail program \"$MAILER\"."
echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
exit 1
fi
if test "`echo -n foo`" = foo ; then
ECHON=bsd
elif test "`echo 'foo\c'`" = foo ; then
ECHON=sysv
else
ECHON=none
fi
if [ $ECHON = bsd ] ; then
ECHON1="echo -n"
ECHON2=
elif [ $ECHON = sysv ] ; then
ECHON1=echo
ECHON2='\c'
else
ECHON1=echo
ECHON2=
fi
#
[ -z "$TMPDIR" ] && TMPDIR=/tmp
TEMP="`$MKTEMP $TMPDIR/p.XXXXXX`"
BAD="`$MKTEMP $TMPDIR/pbad.XXXXXX`"
REF="`$MKTEMP $TMPDIR/pf.XXXXXX`"
if [ -z "$LOGNAME" -a -n "$USER" ]; then
LOGNAME=$USER
fi
FROM="$LOGNAME"
REPLY_TO="$LOGNAME"
# Find out the name of the originator of this PR.
if [ -n "$NAME" ]; then
ORIGINATOR="$NAME"
elif [ -f $HOME/.fullname ]; then
ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
elif [ -f /bin/domainname ]; then
if [ "`/bin/domainname`" != "" -a -f /usr/bin/ypcat ]; then
# Must use temp file due to incompatibilities in quoting behavior
# and to protect shell metacharacters in the expansion of $LOGNAME
/usr/bin/ypcat passwd 2>/dev/null | cat - /etc/passwd | grep "^$LOGNAME:" |
cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
ORIGINATOR="`cat $TEMP`"
> $TEMP
fi
fi
if [ "$ORIGINATOR" = "" ]; then
grep "^$LOGNAME:" /etc/passwd | cut -f5 -d':' | sed -e 's/,.*//' > $TEMP
ORIGINATOR="`cat $TEMP`"
> $TEMP
fi
if [ -n "$ORGANIZATION" ]; then
if [ -f "$ORGANIZATION" ]; then
ORGANIZATION="`cat $ORGANIZATION`"
fi
else
if [ -n "$DEFAULT_ORGANIZATION" ]; then
ORGANIZATION="$DEFAULT_ORGANIZATION"
elif [ -f $HOME/.organization ]; then
ORGANIZATION="`cat $HOME/.organization`"
elif [ -f $HOME/.signature ]; then
ORGANIZATION="`cat $HOME/.signature`"
fi
fi
# If they don't have a preferred editor set, then use
if [ -z "$VISUAL" ]; then
if [ -z "$EDITOR" ]; then
EDIT=vi
else
EDIT="$EDITOR"
fi
else
EDIT="$VISUAL"
fi
# Find out some information.
SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
ARCH=`[ -f /bin/arch ] && /bin/arch`
MACHINE=`[ -f /bin/machine ] && /bin/machine`
COMMAND=`echo $0 | sed -e 's,.*/,,'`
## USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [--request-id]
USAGE="Usage: $COMMAND [-PVL]
[--version]"
REMOVE=
BATCH=
while [ $# -gt 0 ]; do
case "$1" in
-r) ;; # Ignore for backward compat.
## -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
## shift ; GNATS_ADDR="$1"
## EXPLICIT_GNATS_ADDR=true
## ;;
## -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
## shift ; IN_FILE="$1"
## if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
## echo "$COMMAND: cannot read $IN_FILE"
## exit 1
## fi
## ;;
-b | --batch) BATCH=true ;;
-p | -P | --print) PRINT=true ;;
-L | --list) FORMAT=norm ;;
-l | -CL | --lisp) FORMAT=lisp ;;
## --request-id) REQUEST_ID=true ;;
-h | --help) echo "$USAGE"; exit 0 ;;
-V | --version) echo "$VERSION"; exit 0 ;;
-*) echo "$USAGE" ; exit 1 ;;
*) echo "$USAGE" ; exit 1
## if [ -z "$USER_GNATS_SITE" ]; then
## if [ ! -r "$DATADIR/gnats/$1" ]; then
## echo "$COMMAND: the GNATS site $1 does not have a categories list."
## exit 1
## else
## # The site name is the alias they'll have to have created.
## USER_GNATS_SITE=$1
## fi
## else
## echo "$USAGE" ; exit 1
## fi
;;
esac
shift
done
if [ -n "$USER_GNATS_SITE" ]; then
GNATS_SITE=$USER_GNATS_SITE
GNATS_ADDR=$USER_GNATS_SITE-gnats
fi
if [ "$SUBMITTER" = "unknown" -a -z "$REQUEST_ID" -a -z "$IN_FILE" ]; then
cat << '__EOF__'
It seems that send-pr is not installed with your unique submitter-id.
You need to run
install-sid YOUR-SID
where YOUR-SID is the identification code you received with `send-pr'.
`send-pr' will automatically insert this value into the template field
`>Submitter-Id'. If you've downloaded `send-pr' from the Net, use `net'
for this value. If you do not know your id, run `send-pr --request-id' to
get one from your support site.
__EOF__
exit 1
fi
## if [ -r "$DATADIR/gnats/$GNATS_SITE" ]; then
## CATEGORIES=`grep -v '^#' $DATADIR/gnats/$GNATS_SITE | sort`
## else
## echo "$COMMAND: could not read $DATADIR/gnats/$GNATS_SITE for categories list."
## exit 1
## fi
CATEGORIES="contrib cvs doc pcl-cvs portability"
if [ -z "$CATEGORIES" ]; then
echo "$COMMAND: the categories list for $GNATS_SITE was empty!"
exit 1
fi
case "$FORMAT" in
lisp) echo "$CATEGORIES" | \
awk 'BEGIN {printf "( "}
{printf "(\"%s\") ",$0}
END {printf ")\n"}'
exit 0
;;
norm) l=`echo "$CATEGORIES" | \
awk 'BEGIN {max = 0; }
{ if (length($0) > max) { max = length($0); } }
END {print max + 1;}'`
c=`expr 70 / $l`
if [ $c -eq 0 ]; then c=1; fi
echo "$CATEGORIES" | \
awk 'BEGIN {print "Known categories:"; i = 0 }
{ printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
END { print ""; }'
exit 0
;;
esac
ORIGINATOR_C=''
FIX_C='