/[gnats]/gnats/send-pr/send-pr.sh
ViewVC logotype

Diff of /gnats/send-pr/send-pr.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by andrewg, Sat Aug 30 07:59:04 2003 UTC revision 1.25 by chewie, Tue Nov 2 23:10:32 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    # @configure_input@
3    #
4  # Submit a problem report to a GNATS site.  # Submit a problem report to a GNATS site.
5  # Copyright (C) 2001, 2002 Milan Zamazal  # Copyright (C) 2001, 2002 Milan Zamazal
6  # Copyright (C) 1993, 2001 Free Software Foundation, Inc.  # Copyright (C) 1993, 2001 Free Software Foundation, Inc.
# Line 23  Line 25 
25  # along with GNU GNATS; see the file COPYING.  If not, write to  # along with GNU GNATS; see the file COPYING.  If not, write to
26  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27    
28    ################################################################################
29    # Default values -- You may override these in your configuration file
30    ################################################################################
31  # The version of this send-pr.  # The version of this send-pr.
32  VERSION=xVERSIONx  VERSION="@PACKAGE_VERSION@"
33    
34  # The submitter-id for your site.  # The submitter-id for your site.
35  SUBMITTER=xSUBMITTERx  SUBMITTER="@SUBMITTER@"
36    
37  # The place where our usual binaries live.  # The place where our usual binaries live.
38  BINDIR=xBINDIRx  prefix="@prefix@"
39    exec_prefix="@exec_prefix@"
40  # The place where the builtin binaries are located.  bindir="@bindir@"
41  LIBEXECDIR=xLIBEXECDIRx/gnats  sbindir="@bindir@"
42    sysconfdir="@sysconfdir@"
43    libexecdir="@libexecdir@/gnats"
44    
45  # The default release for this host.  # The default release for this host.
46  DEFAULT_RELEASE="xDEFAULT_RELEASEx"  DEFAULT_RELEASE="@DEFAULT_RELEASE@"
47    
48  # The default organization.  # The default organization.
49  DEFAULT_ORGANIZATION="xDEFAULT_ORGANIZATIONx"  DEFAULT_ORGANIZATION="@DEFAULT_ORGANIZATION@"
50    
51  # How to read the passwd database.  # How to read the passwd database.
52  PASSWD="xPASSWDx"  PASSWD="@PASSWD@"
53    
54  # Is the mktemp command available?  # Is the mktemp command available?
55  MKTEMP="xMKTEMPx"  MKTEMP="@MKTEMP@"
56    
57  ECHON=xECHONx  ECHON=@ECHON@
58    
59  # By default send-pr connects directly to the database.  However, it  # By default send-pr connects directly to the database.  However, it
60  # can be configured to use an existing template file by setting the  # can be configured to use an existing template file by setting the
# Line 63  TEMPLATE="" Line 70  TEMPLATE=""
70  # MAILPROG="mail bugs@foo.bar.com"  # MAILPROG="mail bugs@foo.bar.com"
71  # should work).  If sendmail is used, this should be set to  # should work).  If sendmail is used, this should be set to
72  # MAILPROG="/usr/lib/sendmail -oi -t"  # MAILPROG="/usr/lib/sendmail -oi -t"
73  MAILPROG=""  MAILPROG="@DEFAULT_MAIL_AGENT@"
74    
75  # The address that PRs are sent to.  Normally this can be left as "bugs";  # The address that PRs are sent to.  Normally this can be left as "bugs";
76  # however, if using mail to submit PRs, this should be set to the address  # however, if using mail to submit PRs, this should be set to the address
77  # where PRs should be sent.  # where PRs should be sent.
78  MAILADDR="bugs"  MAILADDR="bugs"
79    
 if [ $ECHON = bsd ] ; then  
   ECHON1="echo -n"  
   ECHON2=  
 elif [ $ECHON = sysv ] ; then  
   ECHON1=echo  
   ECHON2='\c'  
 else  
   ECHON1=echo  
   ECHON2=  
 fi  
   
80  # Configuration file to be read.  It must be a shell script that can redefine  # Configuration file to be read.  It must be a shell script that can redefine
81  # the variables above to fit a local configuration.  # the variables above to fit a local configuration.  It reads the system config
82  CONFIGFILE=xSYSCONFDIRx/gnats/send-pr.conf  # file first, then the personal config file.
83    CONFIGFILES="@sysconfdir@/gnats/send-pr.conf ${HOME}/.send-pr.conf"
84  if [ -r $CONFIGFILE ]; then  for CONFIGFILE in ${CONFIGFILES}; do
85    . $CONFIGFILE    if [ -r ${CONFIGFILE} ]; then
86  fi      . ${CONFIGFILE}
87      fi
88    done
89    
90  #  #
91    
# Line 168  then Line 166  then
166    ORGANIZATION="$DEFAULT_ORGANIZATION";    ORGANIZATION="$DEFAULT_ORGANIZATION";
167  fi  fi
168    
169  if [ -n "$ORGANIZATION" -a "x$ORGANIZATION" != "xDEFAULT_ORGANIZATIONx" ]; then  if [ -n "$ORGANIZATION" -a "x$ORGANIZATION" != "@DEFAULT_ORGANIZATION@" ]; then
170    if [ `echo $ORGANIZATION | fgrep -c /` -gt 0 -a -f "$ORGANIZATION" ]; then    if [ `echo $ORGANIZATION | fgrep -c /` -gt 0 -a -f "$ORGANIZATION" ]; then
171      ORGANIZATION="`cat $ORGANIZATION`"      ORGANIZATION="`cat $ORGANIZATION`"
172    fi    fi
# Line 176  elif [ -f $HOME/.organization ]; then Line 174  elif [ -f $HOME/.organization ]; then
174    ORGANIZATION="`cat $HOME/.organization`"    ORGANIZATION="`cat $HOME/.organization`"
175  fi  fi
176    
177  if [ "x$ORGANIZATION" = "xDEFAULT_ORGANIZATIONx" ]; then  if [ "x$ORGANIZATION" = "@DEFAULT_ORGANIZATION@" ]; then
178    cat <<__EOF__    cat <<__EOF__
179  It seems that send-pr is not installed with your organization set to a useful  It seems that send-pr is not installed with your organization set to a useful
180  value.  To fix this, you need to edit the configuration file  value.  To fix this, you need to edit the configuration file
# Line 262  fi Line 260  fi
260    
261  if [ "x$SUBMITTER" = "xunknown" -a -z "$REQUEST_ID" -a -z "$IN_FILE" ]; then  if [ "x$SUBMITTER" = "xunknown" -a -z "$REQUEST_ID" -a -z "$IN_FILE" ]; then
262    cat << '__EOF__'    cat << '__EOF__'
263  It seems that send-pr is not installed with your unique submitter-id.  It seems that send-pr is not installed with your unique submitter-id, or that
264  You need to run  "unknown" has been specified.  You need to run:
265    
266            install-sid YOUR-SID            install-sid YOUR-SID
267    
# Line 333  SEND-PR: Line 331  SEND-PR:
331  __EOF__  __EOF__
332    
333        # Format the categories so they fit onto lines.        # Format the categories so they fit onto lines.
334          CATEGORIES=`${BINDIR}/query-pr --valid-values Category`;          CATEGORIES=`${bindir}/query-pr --valid-values Category`;
335          l=`echo "$CATEGORIES" | \          l=`echo "$CATEGORIES" | \
336          awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }          awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
337               END {print max + 1;}'`               END {print max + 1;}'`
# Line 361  __EOF__ Line 359  __EOF__
359          # with >, : and extra spaces to cause the field contents to be          # with >, : and extra spaces to cause the field contents to be
360          # aligned.          # aligned.
361          #          #
362          ${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          ${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
363          do          do
364              fmtname="`echo "$fmtname" | sed 's/[&]$//;'`"              fmtname="`echo "$fmtname" | sed 's/[&]$//;'`"
365              upname="`echo $fieldname | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;s/-//g;'`"              upname="`echo $fieldname | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;s/-//g;'`"
366              # Grab the default value for this field.              # Grab the default value for this field.
367              eval 'default_val="$DEFAULT_'${upname}'"'              eval 'default_val="$DEFAULT_'${upname}'"'
368              # What's stored in the field?              # What's stored in the field?
369              type=`${BINDIR}/query-pr --field-type $fieldname | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`              type=`${bindir}/query-pr --field-type $fieldname | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
370              case $type in              case $type in
371                  enum)                  enum)
372                      if [ "$default_val" != "" ]                      if [ "$default_val" != "" ]
# Line 377  __EOF__ Line 375  __EOF__
375                      else                      else
376                          if [ "$fieldname" != "Category" ]                          if [ "$fieldname" != "Category" ]
377                          then                          then
378                              values=`${BINDIR}/query-pr --valid-values $fieldname | tr '\n' ' ' | sed 's/ *$//g; s/ / | /g;s/^/[ /;s/$/ ]/;'`                              values=`${bindir}/query-pr --valid-values $fieldname | tr '\n' ' ' | sed 's/ *$//g; s/ / | /g;s/^/[ /;s/$/ ]/;'`
379                              valslen=`echo "$values" | wc -c`                              valslen=`echo "$values" | wc -c`
380                          else                          else
381                              values="choose from a category listed above"                              values="choose from a category listed above"
# Line 385  __EOF__ Line 383  __EOF__
383                          fi                          fi
384                          if [ "$valslen" -gt 160 ]                          if [ "$valslen" -gt 160 ]
385                          then                          then
386                                  desc="<`${BINDIR}/query-pr --field-description $fieldname` (one line)>";                                  desc="<`${bindir}/query-pr --field-description $fieldname` (one line)>";
387                          else                          else
388                                  desc="<${values} (one line)>";                                  desc="<${values} (one line)>";
389                          fi                          fi
# Line 399  __EOF__ Line 397  __EOF__
397                      then                      then
398                          desc="  $default_val";                          desc="  $default_val";
399                      else                      else
400                          desc="  <`${BINDIR}/query-pr --field-description $fieldname` (multiple lines)>";                          desc="  <`${bindir}/query-pr --field-description $fieldname` (multiple lines)>";
401                          dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`                          dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`
402                          echo "s/^${dpat}//" >> $FIXFIL                          echo "s/^${dpat}//" >> $FIXFIL
403                      fi                      fi
# Line 411  __EOF__ Line 409  __EOF__
409                      then                      then
410                          desc="${default_val}"                          desc="${default_val}"
411                      else                      else
412                          desc="<`${BINDIR}/query-pr --field-description $fieldname` (one line)>"                          desc="<`${bindir}/query-pr --field-description $fieldname` (one line)>"
413                          dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`                          dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`
414                          echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL                          echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL
415                      fi                      fi
# Line 474  while [ -z "$REQUEST_ID" ]; do Line 472  while [ -z "$REQUEST_ID" ]; do
472    then    then
473      # Since we're not using mail, use pr-edit to check the PR.  We can't      # Since we're not using mail, use pr-edit to check the PR.  We can't
474      # do much checking otherwise, sorry.      # do much checking otherwise, sorry.
475      $LIBEXECDIR/pr-edit --check-initial < $REF || CNT=`expr $CNT + 1`      $libexecdir/pr-edit --check-initial < $REF || CNT=`expr $CNT + 1`
476    fi    fi
477    
478    [ $CNT -gt 0 -a -z "$BATCH" ] &&    [ $CNT -gt 0 -a -z "$BATCH" ] &&
# Line 482  while [ -z "$REQUEST_ID" ]; do Line 480  while [ -z "$REQUEST_ID" ]; do
480    
481    while true; do    while true; do
482      if [ -z "$BATCH" ]; then      if [ -z "$BATCH" ]; then
483        $ECHON1 "a)bort, e)dit or s)end? $ECHON2"        @ECHO_N@ "a)bort, e)dit or s)end? @ECHO_C@"
484        read input        read input
485      else      else
486        if [ $CNT -eq 0 ]; then        if [ $CNT -eq 0 ]; then
# Line 536  do Line 534  do
534      echo "$COMMAND: problem report mailed"      echo "$COMMAND: problem report mailed"
535      xs=0; exit      xs=0; exit
536    else    else
537      if pr_num=`$LIBEXECDIR/pr-edit --submit --show-prnum < $REF` ; then      if pr_num=`$libexecdir/pr-edit --submit --show-prnum < $REF` ; then
538        echo "$COMMAND: problem report $pr_num filed"        echo "$COMMAND: problem report $pr_num filed"
539        xs=0; exit        xs=0; exit
540      else      else
# Line 546  do Line 544  do
544    while true    while true
545    do    do
546      if [ -z "$BATCH" ]; then      if [ -z "$BATCH" ]; then
547        $ECHON1 "a)bort or s)end? $ECHON2"        @ECHO_N@ "a)bort or s)end? @ECHO_C@"
548        read input        read input
549        case "$input" in        case "$input" in
550          a*)          a*)

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26