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