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

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

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

revision 1.1.1.1 by brendan, Thu Nov 5 19:54:07 1998 UTC revision 1.2 by chewie, Tue Nov 2 23:10:17 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2  # Drop in the SUBMITTER id into a site's installed send-pr script.  # @configure_input@
3  # Copyright (C) 1993 Free Software Foundation, Inc.  #
4    # Update the SUBMITTER variable in the site or personal send-pr config file
5    # Copyright (C) 1993,2004 Free Software Foundation, Inc.
6  # Contributed by Brendan Kehoe (brendan@cygnus.com), based on a  # Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
7  # version written by Heinz G. Seidl (hgs@ide.com).  # version written by Heinz G. Seidl (hgs@ide.com).
8  #  #
# Line 20  Line 22 
22  # along with GNU GNATS; see the file COPYING.  If not, write to  # along with GNU GNATS; see the file COPYING.  If not, write to
23  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24    
25  COMMAND=`echo $0 | sed -e 's,.*/,,g'`  VERSION="@PACKAGE_VERSION@"
 USAGE="Usage: $COMMAND [--install-dir=prefix] [--help] [--version] submitter-id"  
   
 VERSION=xVERSIONx  
26    
27  BINDIR=xBINDIRx  COMMAND=`echo $0 | sed -e 's,.*/,,g'`
28    function usage() {
29            cat << __EOF__ >&2
30    Usage: $COMMAND [OPTIONS] submitter-id
31    
32    OPTION          DESCRIPTION
33    --help          This message
34    --version       Print version and exit
35    --site-config   Update the site configuration file
36    
37    $COMMAND updates the SUBMITTER variable with 'submitter-id' in the site or
38    personal send-pr config file.  You may need to have root permissions in order
39    to update the site configuration file.  This application requires the sed script to work.
40    __EOF__
41    }
42    
43    # Is the mktemp command available?
44    MKTEMP="@MKTEMP@"
45    
46    # TEMP: Temporary copy of the config file, to be edited by the user.
47    if [ -z "$TMPDIR" ]; then
48      TMPDIR=/tmp
49    else
50      if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
51        TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
52      fi
53    fi
54    
55  SUBMITTER=  if [ $MKTEMP = yes ]; then
56  TEMP=/tmp/sp$$    TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1
57    else
58      TEMP=$TMPDIR/p$$
59      : > $TEMP || exit 1
60    fi
61    
62  if [ $# -eq 0 ]; then  if [ $# -eq 0 ]; then
63    echo "$USAGE"    usage
64    exit 1    exit 1
65  fi  fi
66    
67    # Default configuration file
68    CONFIGFILE="$HOME/.send-pr.conf"
69    
70    # Leave this blank
71    SUBMITTER=
72    
73    # Process the commandline
74  while [ $# -gt 0 ]; do  while [ $# -gt 0 ]; do
75    case "$1" in    case "$1" in
76      -install-dir=*|--install-dir=*|--install-di=*|--install-d=*|--install-=*|--install=*|--instal=*|--insta=*|--inst=*|--ins=*|--in=*|--i=*)      --site-config) CONFIGFILE="xSYSCONFDIRx/gnats/send-pr.conf" ;;
     I=`echo "$1" | sed 's/-*i[a-z\-]*=//'`  
     BINDIR=$I/bin ;;  
77      --version) echo $COMMAND version $VERSION ; exit 1 ;;      --version) echo $COMMAND version $VERSION ; exit 1 ;;
78      -*) echo "$USAGE" ; exit 1 ;;      -*) usage; exit 1 ;;
79      *) SUBMITTER=$1 ;;      *) SUBMITTER=$1 ;;
80    esac    esac
81    shift    shift
82  done  done
83    
 path=`echo $0 | sed -e "s;${COMMAND};;"`  
   
 [ -z "$path" ] && path=.  
   
 examinebindir=yes  
   
 if [ "$examinebindir" = yes ] && [ -f $BINDIR/send-pr ]; then  
   SPPATHLIST=$BINDIR/send-pr  
 else  
       if [ -f $path/send-pr ]; then  
          SPPATHLIST=$path/send-pr  
       else  
          echo "$COMMAND: cannot find \`$BINDIR/send-pr' or \`$path/send-pr'" >&2  
          exit 1  
       fi  
 fi  
   
84  trap 'rm -f $TEMP ; exit 0' 0  trap 'rm -f $TEMP ; exit 0' 0
85  trap 'echo "$COM: Aborting ..."; rm -f $TEMP ; exit 1' 1 2 3 13 15  trap 'echo "$COMMAND: Aborting ..."; rm -f $TEMP ; exit 1' 1 2 3 13 15
86    
87  for SPPATH in $SPPATHLIST; do  if [ `echo ${SUBMITTER}| \
88     sed -e "s/^SUBMITTER=.*/SUBMITTER=${SUBMITTER}/" $SPPATH > $TEMP          sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` = "unknown" ] ;
89    then
90            echo "$COMMAND: SUBMITTER cannot be 'unknown'" >&2
91            exit 1
92    fi
93    
94     if grep $SUBMITTER $TEMP > /dev/null; then  if [ ! -e $CONFIGFILE ] ; then
95        cp $SPPATH $SPPATH.orig &&          echo "$COMMAND: No configuration file was found.  Creating." >&2
96        rm -f $SPPATH &&          cat << __EOF__ > $CONFIGFILE
97        cp $TEMP $SPPATH &&  # Configuration file for send-pr
98        chmod a+rx $SPPATH &&  # ** CREATED BY $COMMAND **
99        rm -f $TEMP $SPPATH.orig ||  SUBMITTER="$SUBMITTER"
100        { echo "$COMMAND: unable to replace send-pr" >&2 ; exit 1; }    __EOF__
101     else          if [ $? -ne 0 ] ; then
102        echo "$COMMAND: something went wrong when sed-ing the submitter into send-pr" >&2                  echo "$COMMAND: Error in creating $CONFIGFILE" >&2
103        exit 1                  exit 1
104     fi          fi
105  done  else
106            sed -e "s/^#?SUBMITTER=.*/SUBMITTER=${SUBMITTER}/" $CONFIGFILE > $TEMP
107            if ! ( grep $SUBMITTER $TEMP > /dev/null ) ; then
108                    echo "$COMMAND: Error in updating $SUBMITTER to $TEMP" >&2
109                    exit 1
110            fi
111            if ! ( cat $TEMP > $CONFIGFILE ) ; then
112                    echo "$COMMAND: Error in updating $CONFIGFILE" >&2
113                    exit 1
114            fi      
115    fi
116    
117  echo "$COMMAND: \`$SUBMITTER' is now the default submitter ID for send-pr"  echo "$COMMAND: \`$SUBMITTER' has been updated in $CONFIGFILE for send-pr" >&2
118    
119  exit 0  exit 0

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

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