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