📄 send-pr.in
字号:
#!/bin/sh# Submit a problem report to a GNATS site.# Copyright (C) 2001 Milan Zamazal# Copyright (C) 1993, 2001 Free Software Foundation, Inc.# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a# version written by Heinz G. Seidl (hgs@cygnus.com).# Further edited by Milan Zamazal (pdm@zamazal.org).# mktemp support by Yngve Svendsen (yngve.svendsen@clustra.com).## This file is part of GNU GNATS.## 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.## You should have received a copy of the GNU General Public License# along with GNU GNATS; see the file COPYING. If not, write to# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.## $Id: send-pr.in,v 1.10 2003/07/14 12:26:17 mcr Exp $## The version of this send-pr.VERSION=4.0-alpha#SWAN_VERSION=# The submitter-id for your site.SUBMITTER=net# The place where our usual binaries live.BINDIR=@IPSEC_DIR@# The place where the builtin binaries are located.LIBDIR=@IPSEC_LIBDIR@LIBEXECDIR=@IPSEC_EXECDIR@# The default release for this host.DEFAULT_RELEASE="gnats-4.0-alpha"# The default organization.DEFAULT_ORGANIZATION="net"# How to read the passwd database.PASSWD="cat /etc/passwd"# Is the mktemp command available?MKTEMP="yes"ECHON=bsd# By default send-pr connects directly to the database. However, it# can be configured to use an existing template file by setting the# TEMPLATE variable below to point to a PR template generated from# "send-pr -P".TEMPLATE="$LIBDIR/ipsec_pr.template"# send-pr can use mail to submit PRs, instead of connecting to the# database directly. MAILPROG needs to point to a compatible mailer# (sendmail will work). If MAILPROG needs to have the address that# the mail is being sent to specified on the command line, it should# be specified here as well (for example, the command# MAILPROG="mail bugs@foo.bar.com"# should work). If sendmail is used, this should be set to# MAILPROG="/usr/lib/sendmail -oi -t"MAILPROG="/usr/sbin/sendmail -oi -t"# The address that PRs are sent to. Normally this can be left as "bugs";# however, if using mail to submit PRs, this should be set to the address# where PRs should be sent.MAILADDR="freeswan-bugs@freeswan.org"if [ $ECHON = bsd ] ; then ECHON1="echo -n" ECHON2=elif [ $ECHON = sysv ] ; then ECHON1=echo ECHON2='\c'else ECHON1=echo ECHON2=fi# Configuration file to be read. It must be a shell script that can redefine# the variables above to fit a local configuration.CONFIGFILE=@IPSEC_DIR@/send-pr.confif [ -r $CONFIGFILE ]; then . $CONFIGFILEfi#if [ -z "$TMPDIR" ]; then TMPDIR=/tmpelse if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`" fifi# TEMP: Temporary copy of the PR, to be edited by the user.# BAD: The PR will end up here if the user aborts.# REF: The 'reference' copy of the PR template, used to verify that the user# actually did edit the template.# FIXFIL: A sed script used to remove comments from the template before# processing.if [ $MKTEMP = yes ]; then TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1 BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1 REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1 FIXFIL=`mktemp $TMPDIR/fixXXXXXX` || exit 1else TEMP=$TMPDIR/p$$ BAD=$TMPDIR/pbad$$ REF=$TMPDIR/pf$$ FIXFIL=$TMPDIR/fix$$ bad_temp=0 : > $TEMP || bad_temp=1 : > $BAD || bad_temp=1 : > $REF || bad_temp=1 : > $FIXFIL || bad_temp=1 if [ $bad_temp = 1 ]; then rm -f $TEMP $BAD $REF $FIXFIL exit 1; fifiREMOVE_TEMP="rm -f $TEMP $BAD $REF"# find a user nameif [ "$LOGNAME" = "" ]; then if [ "$USER" != "" ]; then LOGNAME="$USER" else LOGNAME="UNKNOWN" fifiFROM="$LOGNAME"REPLYTO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"if [ "x$MAILPROG" != "x" ]then RESP_ALIAS="`query-pr --adm-field responsible --adm-key $LOGNAME --adm-subfield alias 2>/dev/null`"else RESP_ALIAS=""fi# Find out the name of the originator of this PR.if [ -n "$NAME" ]; then DEFAULT_ORIGINATOR="$NAME"elif [ -f $HOME/.fullname ]; then DEFAULT_ORIGINATOR="`sed -e '1q' $HOME/.fullname`"else # Must use temp file due to incompatibilities in quoting behavior # and to protect shell metacharacters in the expansion of $LOGNAME $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP if [ "x$RESP_ALIAS" != "x" ] then DEFAULT_ORIGINATOR="$RESP_ALIAS (`cat $TEMP`)" else DEFAULT_ORIGINATOR="$FROM (`cat $TEMP`)" fi rm -f $TEMPfiif [ -z "$ORGANIZATION" ]then ORGANIZATION="$DEFAULT_ORGANIZATION";fiif [ -n "$ORGANIZATION" -a "x$ORGANIZATION" != "xunknown" ]; then if [ -f "$ORGANIZATION" ]; then ORGANIZATION="`cat $ORGANIZATION`" fi if [ -n "$ORGANIZATION" ]; then ORGANIZATION="$ORGANIZATION" elif [ -f $HOME/.organization ]; then ORGANIZATION="`cat $HOME/.organization`" fifiif [ "x$ORGANIZATION" = "xunknown" ]; then cat <<__EOF__It seems that send-pr is not installed with your organization set to a usefulvalue. To fix this, you need to edit the configuration file$CONFIGFILEand fill in the organization with the correct value.__EOF__ ORGANIZATION="";fi 1>&2# If they don't have a preferred editor set, then useif [ -z "$VISUAL" ]; then if [ -z "$EDITOR" ]; then EDIT=vi else EDIT="$EDITOR" fielse EDIT="$VISUAL"fi# Find out some information.SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \ ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo "" | sed -e 's,|,\\|,'`# Our base command name.COMMAND=`echo $0 | sed -e 's,.*/,,'`USAGE="Usage: $COMMAND [OPTION]... -b --batch run without printing most messages --barf include a full barf inline rather than just look -c --cc=LINE put LINE to the CC header -d --database=DATABASE submit PR to DATABASE -f --file=FILE read the PR template from FILE (\`-' for stdin) -p --print just print the template and exit --request-id send a request for a user id -s --severity=SEVERITY PR severity -h --help display this help and exit -V --version output version information and exit"REMOVE=BATCH=CC=DEFAULT_SEVERITY=BARF=${BARF-false}if [ "$SYSTEM" != "" ]then DEFAULT_ENVIRONMENT="System: $SYSTEM"fiif [ "$SWAN_VERSION" != "" ]then DEFAULT_VERSION="$SWAN_VERSION";else DEFAULT_VERSION=`ipsec --versioncode`fiDEFAULT_VERSION=`echo $DEFAULT_VERSION | sed -e 's,\/,\\\/,'`while [ $# -gt 0 ]; do case "$1" in -r) ;; # Ignore for backward compat. -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 ;; --barf) BARF=true ;; -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi shift ; CC="$1" ;; -d | --database) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi shift; GNATSDB="$1"; export GNATSDB ;; -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi shift ; DEFAULT_SEVERITY="$1" ;; -p | -P | --print) PRINT=true ;; --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 ;; esac shiftdoneif [ "x$SUBMITTER" = "x" ]then SUBMITTER="unknown"fiif [ "x$SUBMITTER" = "xunknown" -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-SIDwhere 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 1fi# So the template generation code finds it.DEFAULT_SUBMITTERID=${SUBMITTER}# Catch some signals. ($xs kludge needed by Sun /bin/sh)xs=0trap 'rm -f $REF $TEMP $FIXFIL; exit $xs' 0trap 'echo "$COMMAND: Aborting ..."; rm -f $REF $TEMP $FIXFIL; xs=1; exit' 1 3 13 15if [ "x$PRINT" = "xtrue" ]; then FROM="<FROM>" REPLYTO="<REPLYTO>" DEFAULT_ORIGINATOR="<DEFAULT_ORIGINATOR>" DEFAULT_SUBMITTERID="<SUBMITTER>"fi# If they told us to use a specific file, then do so.if [ -n "$IN_FILE" ]; then if [ "$IN_FILE" = "-" ]; then # The PR is coming from the standard input. cat > $TEMP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -