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