3 # glibcbug - create a bug report and mail it to the bug address.
5 # configuration section:
6 # these variables are filled in by configure
13 CCVERSION='@CCVERSION@'
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.$$
31 TEMPx=`mktemp -q ${TMPDIR-/tmp}/glibcbugXXXXXX 2>/dev/null`
32 if test $? -ne 0; then
33 TEMPx=${TMPDIR-/tmp}/glibcbug.$$.x
38 BUGGLIBC="glibc-bug-reports-${RELEASE}@gnu.org"
39 BUGADDR=${1-$BUGGLIBC}
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"
60 # Figure out how to echo a string without a trailing newline
63 *c) ECHON1='echo -n' ECHON2= ;;
64 *) ECHON1=echo ECHON2='\c' ;;
67 # Find out the name of the originator of this PR.
68 if [ -n "$NAME" ]; then
70 elif [ -f $HOME/.fullname ]; then
71 ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
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`"
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
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'`;;
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)>'
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 \`>').
133 Subject: [50 character or so descriptive subject here (for reference)]
136 >Originator: ${ORIGINATOR}
138 ${ORGANIZATION- $ORGANIZATION_C}
140 >Synopsis: $SYNOPSIS_C
141 >Severity: $SEVERITY_C
142 >Priority: $PRIORITY_C
145 >Release: libc-${VERSION}
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`
179 if cmp -s $TEMP $TEMPx; then
180 echo "File not changed, no bug report submitted."
185 # Check the enumeration fields
187 # This is a "sed-subroutine" with one keyword parameter
188 # (with workaround for Sun sed bug)
208 SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
210 ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
211 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
217 PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
219 ""|low|medium|high) CNT=`expr $CNT + 1` ;;
220 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
226 CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
228 ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
229 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
233 echo "Errors were found with the problem report."
236 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
240 echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
241 cat $TEMP >> $HOME/dead.glibcbug
255 # Remove comments and send the problem report
256 # (we have to use patterns, where the comment contains regex chars)
258 # /^>Originator:/s;$ORIGINATOR;;
261 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
262 /^>Confidential:/s;<.*>;;
263 /^>Synopsis:/s;$SYNOPSIS_C;;
264 /^>Severity:/s;<.*>;;
265 /^>Priority:/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;;
274 if $MAIL_AGENT < $TEMPx; then
275 echo "$COMMAND: problem report sent"
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