File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / lrzsz / src / lrzszbug.in
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Thu Oct 24 15:49:50 2019 UTC (4 years, 11 months ago) by misho
Branches: lrzsz, MAIN
CVS tags: v0_12_20p5, HEAD
lrzsz ver 0.12.20

    1: #! /bin/sh
    2: #
    3: # lrzszbug - create a bug report and mail it to the bug address.
    4: #
    5: # configuration section:
    6: #       these variables are filled in by configure
    7: #
    8: VERSION="@VERSION@"
    9: BUGGLIBC="bugs@bulkmail.ohse.de"
   10: 
   11: PATH=$PATH:/bin:/usr/bin:/usr/local/bin
   12: export PATH
   13: 
   14: TEMP=/tmp/lrzszbug.$$
   15: 
   16: BUGADDR=${1-$BUGGLIBC}
   17: ENVIRONMENT=`uname -a`
   18: 
   19: : ${EDITOR=emacs}
   20: 
   21: : ${USER=${LOGNAME-`whoami`}}
   22: 
   23: trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
   24: trap 'rm -f $TEMP $TEMP.x' 0
   25: 
   26: 
   27: # How to read the passwd database.
   28: PASSWD="cat /etc/passwd"
   29: 
   30: if [ -f /usr/lib/sendmail ] ; then
   31:         MAIL_AGENT="/usr/lib/sendmail -oi -t"
   32: elif [ -f /usr/sbin/sendmail ] ; then
   33:         MAIL_AGENT="/usr/sbin/sendmail -oi -t"
   34: else
   35:         MAIL_AGENT=rmail
   36: fi
   37: 
   38: # Figure out how to echo a string without a trailing newline
   39: N=`echo 'hi there\c'`
   40: case "$N" in
   41: *c)	ECHON1='echo -n' ECHON2= ;;
   42: *)	ECHON1=echo ECHON2='\c' ;;
   43: esac
   44: 
   45: # Find out the name of the originator of this PR.
   46: if [ -n "$NAME" ]; then
   47:   ORIGINATOR="$NAME"
   48: elif [ -f $HOME/.fullname ]; then
   49:   ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
   50: else
   51:   # Must use temp file due to incompatibilities in quoting behavior
   52:   # and to protect shell metacharacters in the expansion of $LOGNAME
   53:   $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
   54:   ORIGINATOR="`cat $TEMP`"
   55:   rm -f $TEMP
   56: fi
   57: 
   58: if [ -n "$ORGANIZATION" ]; then
   59:   if [ -f "$ORGANIZATION" ]; then
   60:     ORGANIZATION="`cat $ORGANIZATION`"
   61:   fi
   62: else
   63:   if [ -f $HOME/.organization ]; then
   64:     ORGANIZATION="`cat $HOME/.organization`"
   65:   elif [ -f $HOME/.signature ]; then
   66:     ORGANIZATION=`sed -e "s/^/  /" $HOME/.signature; echo ">"`
   67:   fi
   68: fi
   69: 
   70: # If they don't have a preferred editor set, then use
   71: if [ -z "$VISUAL" ]; then
   72:   if [ -z "$EDITOR" ]; then
   73:     EDIT=vi
   74:   else
   75:     EDIT="$EDITOR"
   76:   fi
   77: else
   78:   EDIT="$VISUAL"
   79: fi
   80: 
   81: # Find out some information.
   82: SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
   83:         ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
   84: ARCH=`[ -f /bin/arch ] && /bin/arch`
   85: MACHINE=`[ -f /bin/machine ] && /bin/machine`
   86: 
   87: ORGANIZATION_C='<organization of PR author (multiple lines)>'
   88: SYNOPSIS_C='<synopsis of the problem (one line)>'
   89: SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
   90: PRIORITY_C='<[ low | medium | high ] (one line)>'
   91: CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
   92: RELEASE_C='<release number or tag (one line)>'
   93: ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
   94: DESCRIPTION_C='<precise description of the problem (multiple lines)>'
   95: HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
   96: FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
   97: 
   98: 
   99: cat > $TEMP <<EOF
  100: SEND-PR: -*- send-pr -*-
  101: SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
  102: SEND-PR: will all comments (text enclosed in \`<' and \`>').
  103: SEND-PR:
  104: From: ${USER}
  105: To: ${BUGADDR}
  106: Subject: lrzsz: [50 character or so descriptive subject here (for reference)]
  107: 
  108: >Submitter-Id:	net
  109: >Originator:	${ORIGINATOR}
  110: >Organization:
  111: ${ORGANIZATION- $ORGANIZATION_C}
  112: >Confidential:	no
  113: >Synopsis:	$SYNOPSIS_C
  114: >Severity:	$SEVERITY_C
  115: >Priority:	$PRIORITY_C
  116: >Category:	lrzsz
  117: >Class:		$CLASS_C
  118: >Release:	lrzsz-${VERSION}
  119: >Environment:
  120: 	$ENVIRONMENT_C
  121: `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
  122: `[ -n "$ARCH" ] && echo Architecture: $ARCH`
  123: `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
  124: `[ -f "lrz" ] && echo " include, if possible, the output of 'ldd lrz'"`
  125: `[ -f "src/lrz" ] && echo " include, if possible, the output of 'ldd src/lrz'"`
  126: `[ -f "lrzsz-@VERSION@/src/lrz" ] && echo " include, if possible, the output of 'ldd lrzsz-@VERSION@/src/lrz'"`
  127: 
  128: >Description:
  129: 	$DESCRIPTION_C
  130: >How-To-Repeat:
  131: 	$HOW_TO_REPEAT_C
  132: >Fix:
  133: 	$FIX_C
  134: EOF
  135: 
  136: chmod u+w $TEMP
  137: cp $TEMP $TEMP.x
  138: 
  139: eval $EDIT $TEMP
  140: 
  141: if cmp -s $TEMP $TEMP.x; then
  142: 	echo "File not changed, no bug report submitted."
  143: 	exit 1
  144: fi
  145: 
  146: #
  147: #       Check the enumeration fields
  148: 
  149: # This is a "sed-subroutine" with one keyword parameter
  150: # (with workaround for Sun sed bug)
  151: #
  152: SED_CMD='
  153: /$PATTERN/{
  154: s|||
  155: s|<.*>||
  156: s|^[ 	]*||
  157: s|[ 	]*$||
  158: p
  159: q
  160: }'
  161: 
  162: 
  163: while :; do
  164:   CNT=0
  165: 
  166:   #
  167:   # 1) Severity
  168:   #
  169:   PATTERN=">Severity:"
  170:   SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  171:   case "$SEVERITY" in
  172:     ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
  173:     *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
  174:   esac
  175:   #
  176:   # 2) Priority
  177:   #
  178:   PATTERN=">Priority:"
  179:   PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  180:   case "$PRIORITY" in
  181:     ""|low|medium|high) CNT=`expr $CNT + 1` ;;
  182:     *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
  183:   esac
  184:   #
  185:   # 3) Class
  186:   #
  187:   PATTERN=">Class:"
  188:   CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  189:   case "$CLASS" in
  190:     ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
  191:     *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
  192:   esac
  193: 
  194:   [ $CNT -lt 3 ] &&
  195:     echo "Errors were found with the problem report."
  196: 
  197:   while :; do
  198:     $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
  199:     read input
  200:     case "$input" in
  201:       a*)
  202: 	echo "$COMMAND: problem report saved in $HOME/dead.lrzszbug."
  203: 	cat $TEMP >> $HOME/dead.lrzszbug
  204:         xs=1; exit
  205:         ;;
  206:       e*)
  207:         eval $EDIT $TEMP
  208:         continue 2
  209:         ;;
  210:       s*)
  211:         break 2
  212:         ;;
  213:     esac
  214:   done
  215: done
  216: #
  217: #       Remove comments and send the problem report
  218: #       (we have to use patterns, where the comment contains regex chars)
  219: #
  220: # /^>Originator:/s;$ORIGINATOR;;
  221: sed  -e "
  222: /^SEND-PR:/d
  223: /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
  224: /^>Confidential:/s;<.*>;;
  225: /^>Synopsis:/s;$SYNOPSIS_C;;
  226: /^>Severity:/s;<.*>;;
  227: /^>Priority:/s;<.*>;;
  228: /^>Class:/s;<.*>;;
  229: /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
  230: /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
  231: /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
  232: /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
  233: /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
  234: " $TEMP > $TEMP.x
  235: 
  236: if $MAIL_AGENT < $TEMP.x; then
  237:   echo "$COMMAND: problem report sent"
  238:   xs=0; exit
  239: else
  240:   echo "$COMMAND: mysterious mail failure, report not sent."
  241:   echo "$COMMAND: problem report saved in $HOME/dead.lrzszbug."
  242:   cat $TEMP >> $HOME/dead.lrzszbug
  243: fi
  244: 
  245: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>