summaryrefslogtreecommitdiffstats
path: root/scripts/gnupgbug
blob: 7cde6aa16ec563af703d10cdc65611ec55a3f843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/sh

#
#     File a bug against the GNU Privacy Guard.
#

#
#     Copyright (c) 2000 Thomas Roessler <roessler@guug.de>
#
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

SUBMIT="submit@bugs.guug.de"
DEBIAN_SUBMIT="submit@bugs.debian.org"


include_file ()
{
	echo
	echo "--- Begin $1"
	sed -e 's/^-/- -/' $1 | egrep -v '^[    ]*(#|$)'
	echo "--- End $1"
	echo
}

case `echo -n` in
"") n=-n; c=   ;;
 *) n=; c='\c' ;;
esac


exec > /dev/tty
exec < /dev/tty

SCRATCH=${TMPDIR-/tmp}/`basename $0`.`hostname`.$$

mkdir ${SCRATCH} || \
{
	echo "`basename $0`: Can't create temporary directory." >& 2 ;
	exit 1 ;
}

trap "rm -r -f ${SCRATCH} ; trap '' 0 ; exit" 0 1 2

TEMPLATE=${SCRATCH}/template.txt

echo "Please enter a one-line description of the problem you experience:"
echo $n "> $c"
read SUBJECT

echo $n "Do you want to include your personal GnuPG configuration files? [Y|n]$c"
read personal
case "$personal" in
[nN]*)	personal=no  ;;
    *)	personal=yes ;;
esac

if test -f /etc/debian_version ; then
	DEBIAN=yes
	echo $n "Checking whether GnuPG has been installed as a package... $c"
	GNUPGVERSION="`dpkg -l gnupg | grep ^i | awk '{print $3}'`" 2> /dev/null
	if test "$GNUPGVERSION" ; then
		DPKG=yes
	else
		DPKG=no
	fi
	echo "$DPKG"
	if test "$DPKG" = "no" ; then
		echo $n "File this bug with Debian? [Y|n]$c"
		read $DPKG
		case "$DPKG" in
		[nN])	DPKG=no ;;
		*)	DPKG=yes ;;
		esac
	fi
else
	DEBIAN=no
	DPKG=no
fi

test "$MUTTVERSION"  || MUTTVERSION="`mutt -v | head -1 | awk '{print $2}' | tr -d i`"
test "$DPKG" = "yes" && SUBMIT="$SUBMIT, $DEBIAN_SUBMIT"


exec > ${TEMPLATE}

echo "Subject: mutt-$MUTTVERSION: $SUBJECT"
echo "To: $SUBMIT"
echo "Cc: $LOGNAME"
echo
echo "Package: mutt"
echo "Version: $MUTTVERSION"
echo
echo "-- Please type your report below this line"
echo
echo
echo

if test "$DEBIAN" = "yes" ; then
	echo "Obtaining Debian-specific information..." > /dev/tty
	bug -p -s dummy mutt |				       \
		sed -n -e "/^-- System Information/,/^---/p" | \
		grep -v '^---'
fi

echo
echo "-- Mutt Version Information"
echo
mutt -v

if test "$personal" = "yes" ; then
	CANDIDATES=".muttrc-${MUTTVERSION} .muttrc .mutt/muttrc-${MUTTVERSION} .mutt/muttrc"
	MATCHED="none"
	for f in $CANDIDATES; do
		if test -f "${HOME}/$f" ; then
			MATCHED="${HOME}/$f"
			break
		fi
	done

	if test "$MATCHED" = "none" ; then
		echo "Warning: Can't find your personal .muttrc." >&2
	else
		include_file $MATCHED
	fi
fi

if test "$global" = "yes" ; then
	CANDIDATES="Muttrc-${MUTTVERSION} Muttrc"
	DIRECTORIES="/etc /usr/local/share/mutt"
	MATCHED="none"
	for d in $DIRECTORIES ; do
		for f in $CANDIDATES; do
			if test -f $d/$f ; then
				MATCHED="$d/$f"
				break
			fi
		done
		test "$MATCHED" = "none" || break
	done

	if test "$MATCHED" = "none" ; then
		echo "Warning: Can't find global Muttrc." >&2
	else
		include_file $MATCHED
	fi
fi

exec > /dev/tty

cp $TEMPLATE $SCRATCH/mutt-bug.txt

input="e"
while : ; do
	if test "$input" = "e" ; then
		${VISUAL-vi} $SCRATCH/mutt-bug.txt
		if cmp $SCRATCH/mutt-bug.txt ${TEMPLATE} > /dev/null ; then
			echo "Warning: Bug report was not modified!"
		fi
	fi

	echo $n "Submit, Edit, Print, Quit? [S|e|p|q]$c"
	read _input
	input="`echo $_input | tr EPSQ epsq`"
	case $input in
	e*)	;;
	p*)	${PAGER-more} $SCRATCH/mutt-bug.txt ;;
	s*|"")  /usr/sbin/sendmail -t < $SCRATCH/mutt-bug.txt ; exit ;;
	q*)	exit
	esac
done