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