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