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