📄 send-pr.in
字号:
else # Use the file they named. cat $IN_FILE > $TEMP fielse if [ -n "$TEMPLATE" -a -z "$PRINT_INTERN" ]; then # If their TEMPLATE points to a bogus entry, then bail. if [ ! -f "$TEMPLATE" -o ! -r "$TEMPLATE" -o ! -s "$TEMPLATE" ]; then echo "$COMMAND: can't seem to read your template file (\`$TEMPLATE'), ignoring TEMPLATE" sleep 1 PRINT_INTERN=bad_prform fi fi if [ -n "$TEMPLATE" -a -z "$PRINT_INTERN" ]; then sed "s/<FROM>/$FROM/;s/<REPLYTO>/$REPLYTO/;s/<DEFAULT_ORIGINATOR>/$DEFAULT_ORIGINATOR/;s/<SUBMITTER>/$DEFAULT_SUBMITTERID/;s|<DEFAULT_ENVIRONMENT>|$DEFAULT_ENVIRONMENT|;s/<DEFAULT_BARF>/$DEFAULT_BARF/;s/<DEFAULT_VERSION>/$DEFAULT_VERSION/;" < $TEMPLATE > $TEMP || ( echo "$COMMAND: could not copy $TEMPLATE" ; xs=1; exit ) else # Which genius thought of iterating through this loop twice, when the # cp command would suffice? for file in $TEMP ; do cat > $file << '__EOF__'SEND-PR: -*- send-pr -*-SEND-PR: Lines starting with `SEND-PR' will be removed automatically, asSEND-PR: will all comments (text enclosed in `<' and `>').SEND-PR: SEND-PR: Please consult the send-pr man page `send-pr(1)' or the TexinfoSEND-PR: manual if you are not sure how to fill out a problem report.SEND-PR: Note that the Synopsis field is mandatory. The Subject (forSEND-PR: the mail) will be made the same as Synopsis unless explicitlySEND-PR: changed.SEND-PR:SEND-PR: Choose from the following categories:SEND-PR:__EOF__ # Format the categories so they fit onto lines. CATEGORIES=`${BINDIR}/query-pr --valid-values Category`; l=`echo "$CATEGORIES" | \ awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } } END {print max + 1;}'` c=`expr 61 / $l` if [ $c -eq 0 ]; then c=1; fi echo "$CATEGORIES" | \ awk 'BEGIN {printf "SEND-PR: "; i = 0 } { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { printf "\nSEND-PR: " } } END { printf "\nSEND-PR:\n"; }' >> $file cat >> $file << __EOF__To: $MAILADDRSubject: From: $FROMReply-To: $REPLYTOCc: $CCX-send-pr-version: $VERSIONX-GNATS-Notify: __EOF__ # # Iterate through the list of input fields. fieldname is the # name of the field. fmtname is the formatted name of the field, # with >, : and extra spaces to cause the field contents to be # aligned. # ${BINDIR}/query-pr --list-input-fields | awk '{a[NR]=$1""; mnr = NR+1; len = length($1) + 2; if (mlen < len) mlen = len; } END { for (x = 1; x < mnr; x++) { b = ">"a[x]":"; printf ("%s %-"mlen"s&\n", a[x], b); } }' | while read fieldname fmtname do fmtname="`echo "$fmtname" | sed 's/[&]$//;'`" upname="`echo $fieldname | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;s/-//g;'`" # Grab the default value for this field. eval 'default_val="$DEFAULT_'${upname}'"' # What's stored in the field? type=`${BINDIR}/query-pr --field-type $fieldname | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` case $type in enum) if [ "$default_val" != "" ] then desc=$default_val; else if [ "$fieldname" != "Category" ] then values=`${BINDIR}/query-pr --valid-values $fieldname | tr '\n' ' ' | sed 's/ *$//g;s/ / | /g;s/^/[ /;s/$/ ]/;'` valslen=`echo "$values" | wc -c` else values="choose from a category listed above" valslen=1; fi if [ "$valslen" -gt 160 ] then desc="<`${BINDIR}/query-pr --field-description $fieldname` (one line)>"; else desc="<${values} (one line)>"; fi dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'` echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL fi echo "${fmtname}${desc}" >> $file ;; multitext) if [ "$default_val" != "" ] then desc=" $default_val"; else desc=" <`${BINDIR}/query-pr --field-description $fieldname` (multiple lines)>"; dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'` echo "s/^${dpat}//" >> $FIXFIL fi echo "${fmtname}" >> $file; echo "$desc" >> $file; ;; *) if [ "$default_val" != "" ] then desc="${default_val}" else desc="<`${BINDIR}/query-pr --field-description $fieldname` (one line)>" dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'` echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL fi echo "${fmtname}${desc}" >> $file ;; esac done done fi if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then cat $TEMP xs=0; exit fi if $BARF then ipsec barf >>$TEMP else ipsec look >>$TEMP fi cp $TEMP $REF chmod u+w $TEMP if [ -z "$REQUEST_ID" ]; then eval $EDIT $TEMP else ed -s $TEMP << '__EOF__'/^Subject/s/^Subject:.*/Subject: request for a customer id//^>Category/s/^>Category:.*/>Category: send-pr/wq__EOF__ fi if cmp -s $REF $TEMP ; then echo "$COMMAND: problem report not filled out, therefore not sent" xs=1; exit fifi# TEMP is the PR that we are editing. When we're done, REF will contain# the final PR to be sent.while [ -z "$REQUEST_ID" ]; do CNT=0 # # Remove comments. # echo '/^SEND-PR:/d' >> $FIXFIL sed -f $FIXFIL $TEMP > $REF # REF now has the actual PR that we want to send. # # Check that synopsis is not empty. # if grep "^>Synopsis:[ ]*$" $REF > /dev/null then echo "$COMMAND: Synopsis must not be empty." CNT=`expr $CNT + 1` fi if [ "x$MAILPROG" = "x" ] then # Since we're not using mail, use pr-edit to check the PR. We can't # do much checking otherwise, sorry. $LIBEXECDIR/pr-edit --check-initial < $REF || CNT=`expr $CNT + 1` fi [ $CNT -gt 0 -a -z "$BATCH" ] && echo "Errors were found with the problem report." while true; do if [ -z "$BATCH" ]; then $ECHON1 "a)bort, e)dit or s)end? $ECHON2" read input else if [ $CNT -eq 0 ]; then input=s else input=a fi fi case "$input" in a*) if [ -z "$BATCH" ]; then echo "$COMMAND: the problem report remains in $BAD and is not sent." mv $TEMP $BAD else echo "$COMMAND: the problem report is not sent." fi xs=1; exit ;; e*) eval $EDIT $TEMP continue 2 ;; s*) break 2 ;; esac donedone## Make sure the mail has got a Subject. If not, use the same as# in Synopsis.#if grep '^Subject:[ ]*$' $REF > /dev/nullthen SYNOPSIS=`grep '^>Synopsis:' $REF | sed -e 's/^>Synopsis:[ ]*//'` ed -s $REF << __EOF__/^Subject:/s/:.*\$/: $SYNOPSIS/wq__EOF__fiwhile :do if [ "x$MAILPROG" != "x" ] then # Use mail to send the PR. if $MAILPROG < $REF then echo "$COMMAND: problem report mailed" xs=0; exit else echo "$MAILPROG failed!" fi else if $LIBEXECDIR/pr-edit --submit < $REF; then echo "$COMMAND: problem report filed" xs=0; exit else echo "$COMMAND: the problem report is not sent." fi fi while true do if [ -z "$BATCH" ]; then $ECHON1 "a)bort or s)end? (file=$REF) $ECHON2" read input case "$input" in a*) break 2 ;; s*) break ;; esac else break 2; fi donedoneif [ -z "$BATCH" ]; then echo "$COMMAND: the problem report remains in $BAD and is not sent." mv $TEMP $BADelse echo "$COMMAND: the problem report is not sent, is in $REF."fixs=1; exit;## $Log: send-pr.in,v $# Revision 1.10 2003/07/14 12:26:17 mcr# use | as delimitor for $DEFAULT_ENVIRONMENT.# switch | to \\| when in $DEFAULT_ENVIRONMENT.# this is due to PR#236 where the "uname" output# says GNU/Linux, screwing up sed.## Revision 1.9 2003/02/03 21:51:06 mcr# if MAILPROG fails, then offer to try again.## Revision 1.8 2002/12/10 02:28:13 mcr# adjusted template to use gnats-bugs@freeswan.org# fix sed script to deal with version sanitizer.## Revision 1.7 2002/12/10 02:17:34 mcr# need to init variables first## Revision 1.6 2002/12/10 02:16:23 mcr# adjusted send-pr to look at LIBDIR, not LIBEXECDIR## Revision 1.5 2002/09/30 16:04:05 mcr# fix for sed bug in "send-pr"## Revision 1.4 2002/04/24 07:36:10 mcr# Moved from ./utils/send-pr.sh,v## Revision 1.3 2001/11/27 15:02:55 mcr# added rcsids.# fixed submission address to be freeswan-bugs@freeswan.org# use new ipsec --versioncode to get version info.##
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -