Renamed to e_exp2.
[glibc.git] / glibcbug.in
blobc47a7720775e50eee0207961b834fd43c6f443a9
1 #! /bin/sh
3 # glibcbug - create a bug report and mail it to the bug address.
5 # configuration section:
6 # these variables are filled in by configure
8 VERSION="@VERSION@"
9 RELEASE="@RELEASE@"
10 ADDONS="@subdirs@"
11 HOST="@host@"
12 CC='@CC@'
13 CCVERSION='@CCVERSION@'
14 CFLAGS="@CFLAGS@"
15 SYSINCLUDES="@SYSINCLUDES@"
16 VERSIONING="@VERSIONING@"
17 BUILD_STATIC="@static@"
18 BUILD_SHARED="@shared@"
19 BUILD_PIC_DEFAULT="@pic_default@"
20 BUILD_PROFILE="@profile@"
21 BUILD_OMITFP="@omitfp@"
22 BUILD_BOUNDED="@bounded@"
23 BUILD_STATIC_NSS="@static_nss@"
24 STDIO="@stdio@"
26 TEMP=`mktemp -q /tmp/glibcbugXXXXXX 2>/dev/null`
27 if test $? -ne 0; then
28 TEMP=/tmp/glibcbug.$$
29 echo > $TEMP
30 chmod 600 $TEMP
32 TEMPx=`mktemp -q /tmp/glibcbugXXXXXX 2>/dev/null`
33 if test $? -ne 0; then
34 TEMPx=/tmp/glibcbug.$$.x
35 echo > $TEMPx
36 chmod 600 $TEMPx
39 if test "$RELEASE" = "stable"; then
40 BUGGLIBC="bugs@gnu.org"
41 else
42 BUGGLIBC="libc-alpha@sourceware.cygnus.com"
45 BUGADDR=${1-$BUGGLIBC}
47 : ${EDITOR=emacs}
49 : ${USER=${LOGNAME-`whoami`}}
51 trap 'rm -f $TEMP $TEMPx; exit 1' 1 2 3 13 15
52 trap 'rm -f $TEMP $TEMPx' 0
55 # How to read the passwd database.
56 PASSWD="cat /etc/passwd"
58 if [ -f /usr/lib/sendmail ] ; then
59 MAIL_AGENT="/usr/lib/sendmail -oi -t"
60 elif [ -f /usr/sbin/sendmail ] ; then
61 MAIL_AGENT="/usr/sbin/sendmail -oi -t"
62 else
63 MAIL_AGENT=rmail
66 # Figure out how to echo a string without a trailing newline
67 N=`echo 'hi there\c'`
68 case "$N" in
69 *c) ECHON1='echo -n' ECHON2= ;;
70 *) ECHON1=echo ECHON2='\c' ;;
71 esac
73 # Find out the name of the originator of this PR.
74 if [ -n "$NAME" ]; then
75 ORIGINATOR="$NAME"
76 elif [ -f $HOME/.fullname ]; then
77 ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
78 else
79 # Must use temp file due to incompatibilities in quoting behavior
80 # and to protect shell metacharacters in the expansion of $LOGNAME
81 $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
82 ORIGINATOR="`cat $TEMP`"
85 if [ -n "$ORGANIZATION" ]; then
86 if [ -f "$ORGANIZATION" ]; then
87 ORGANIZATION="`cat $ORGANIZATION`"
89 else
90 if [ -f $HOME/.organization ]; then
91 ORGANIZATION="`cat $HOME/.organization`"
92 elif [ -f $HOME/.signature ]; then
93 ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"`
97 # If they don't have a preferred editor set, then use
98 if [ -z "$VISUAL" ]; then
99 if [ -z "$EDITOR" ]; then
100 EDIT=vi
101 else
102 EDIT="$EDITOR"
104 else
105 EDIT="$VISUAL"
108 # Find out some information.
109 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
110 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
111 ARCH=`[ -f /bin/arch ] && /bin/arch`
112 MACHINE=`[ -f /bin/machine ] && /bin/machine`
114 case $HOST in *linux*)
115 KHDRS=`(echo '#include <linux/version.h>'
116 echo '! UTS_RELEASE' ) |
117 $CC $SYSINCLUDES -E - | sed -n '/!/s/[! "]//gp'`;;
118 esac
120 ORGANIZATION_C='<organization of PR author (multiple lines)>'
121 SYNOPSIS_C='<synopsis of the problem (one line)>'
122 SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
123 PRIORITY_C='<[ low | medium | high ] (one line)>'
124 CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
125 RELEASE_C='<release number or tag (one line)>'
126 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
127 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
128 HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
129 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
132 cat > $TEMP <<EOF
133 SEND-PR: -*- send-pr -*-
134 SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
135 SEND-PR: will all comments (text enclosed in \`<' and \`>').
136 SEND-PR:
137 From: ${USER}
138 To: ${BUGADDR}
139 Subject: [50 character or so descriptive subject here (for reference)]
141 >Submitter-Id: net
142 >Originator: ${ORIGINATOR}
143 >Organization:
144 ${ORGANIZATION- $ORGANIZATION_C}
145 >Confidential: no
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:
153 $ENVIRONMENT_C
154 `[ -n "$HOST" ] && echo Host type: $HOST`
155 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
156 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
157 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
158 `[ -n "$ADDONS" ] && echo Addons: $ADDONS`
159 `[ -n "$CFLAGS" ] && echo Build CFLAGS: $CFLAGS`
160 `[ -n "$CC" ] && echo Build CC: $CC`
161 `[ -n "$CCVERSION" ] && echo Compiler version: $CCVERSION`
162 `[ -n "$KHDRS" ] && echo Kernel headers: $KHDRS`
163 `[ -n "$VERSIONING" ] && echo Symbol versioning: $VERSIONING`
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`
173 >Description:
174 $DESCRIPTION_C
175 >How-To-Repeat:
176 $HOW_TO_REPEAT_C
177 >Fix:
178 $FIX_C
181 chmod u+w $TEMP
182 cp $TEMP $TEMPx
184 eval $EDIT $TEMP
186 if cmp -s $TEMP $TEMPx; then
187 echo "File not changed, no bug report submitted."
188 exit 1
192 # Check the enumeration fields
194 # This is a "sed-subroutine" with one keyword parameter
195 # (with workaround for Sun sed bug)
197 SED_CMD='
198 /$PATTERN/{
199 s|||
200 s|<.*>||
201 s|^[ ]*||
202 s|[ ]*$||
208 while :; do
209 CNT=0
212 # 1) Severity
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
221 # 2) Priority
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
230 # 3) Class
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
239 [ $CNT -lt 3 ] &&
240 echo "Errors were found with the problem report."
242 while :; do
243 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
244 read input
245 case "$input" in
247 echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
248 cat $TEMP >> $HOME/dead.glibcbug
249 xs=1; exit
252 eval $EDIT $TEMP
253 continue 2
256 break 2
258 esac
259 done
260 done
262 # Remove comments and send the problem report
263 # (we have to use patterns, where the comment contains regex chars)
265 # /^>Originator:/s;$ORIGINATOR;;
266 sed -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;;
279 " $TEMP > $TEMPx
281 if $MAIL_AGENT < $TEMPx; then
282 echo "$COMMAND: problem report sent"
283 xs=0; exit
284 else
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
290 exit 0