install-sid.sh revision 259065
1262569Simp#!/bin/sh
2262569Simp# Drop in the SUBMITTER id into a site's installed send-pr script.
3262569Simp# Copyright (C) 1993 Free Software Foundation, Inc.
4262569Simp# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5262569Simp# version written by Heinz G. Seidl (hgs@ide.com).
6262569Simp#
7262569Simp# This file is part of GNU GNATS.
8262569Simp#
9262569Simp# GNU GNATS is free software; you can redistribute it and/or modify
10262569Simp# it under the terms of the GNU General Public License as published by
11262569Simp# the Free Software Foundation; either version 2, or (at your option)
12262569Simp# any later version.
13262569Simp#
14262569Simp# GNU GNATS is distributed in the hope that it will be useful,
15262569Simp# but WITHOUT ANY WARRANTY; without even the implied warranty of
16262569Simp# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17262569Simp# GNU General Public License for more details.
18262569Simp#
19262569Simp# You should have received a copy of the GNU General Public License
20262569Simp# along with GNU GNATS; see the file COPYING.  If not, write to
21262569Simp# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22262569Simp
23262569SimpCOMMAND=`echo $0 | sed -e 's,.*/,,g'`
24262569SimpUSAGE="Usage: $COMMAND [--install-dir=prefix] [--help] [--version] submitter-id"
25262569Simp
26262569SimpVERSION=3.2
27262569Simp
28262569SimpBINDIR=@BINDIR@
29262569Simp
30SUBMITTER=
31TEMP=/tmp/sp$$
32
33if [ $# -eq 0 ]; then
34  echo "$USAGE"
35  exit 1
36fi
37
38while [ $# -gt 0 ]; do
39  case "$1" in
40    -install-dir=*|--install-dir=*|--install-di=*|--install-d=*|--install-=*|--install=*|--instal=*|--insta=*|--inst=*|--ins=*|--in=*|--i=*)
41    I=`echo "$1" | sed 's/-*i[a-z\-]*=//'`
42    BINDIR=$I/bin ;;
43    --version) echo $COMMAND version $VERSION ; exit 1 ;;
44    -*) echo "$USAGE" ; exit 1 ;;
45    *) SUBMITTER=$1 ;;
46  esac
47  shift
48done
49
50path=`echo $0 | sed -e "s;${COMMAND};;"`
51
52[ -z "$path" ] && path=.
53
54if [ -f $BINDIR/send-pr ]; then
55  SPPATH=$BINDIR/send-pr
56elif [ -f $path/send-pr ]; then
57  SPPATH=$path/send-pr
58else
59  echo "$COMMAND: cannot find \`$BINDIR/send-pr' or \`$path/send-pr'" >&2
60  exit 1
61fi
62
63trap 'rm -f $TEMP ; exit 0' 0
64trap 'echo "$COM: Aborting ..."; rm -f $TEMP ; exit 1' 1 2 3 13 15
65
66sed -e "s/^SUBMITTER=.*/SUBMITTER=${SUBMITTER}/" $SPPATH > $TEMP
67
68if grep $SUBMITTER $TEMP > /dev/null; then
69  cp $SPPATH $SPPATH.orig &&
70  rm -f $SPPATH &&
71  cp $TEMP $SPPATH &&
72  chmod a+rx $SPPATH &&
73  rm -f $TEMP $SPPATH.orig ||
74  { echo "$COMMAND: unable to replace send-pr" >&2 ; exit 1; }  
75else
76  echo "$COMMAND: something went wrong when sed-ing the submitter into send-pr" >&2
77  exit 1
78fi
79
80echo "$COMMAND: \`$SUBMITTER' is now the default submitter ID for send-pr"
81
82exit 0
83