Generate correct file which defines FOPEN_MAX also when included by
[glibc/history.git] / glibcbug.in
blobbeb9d07c23f5926df25589eb1ce57a839d5cfd5b
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 BUGGLIBC="bugs@gnu.org"
10 ADDONS="@subdirs@"
11 HOST="@host@"
12 CC='@CC@'
13 CFLAGS="@CFLAGS@"
14 VERSIONING="@VERSIONING@"
15 BUILD_STATIC="@static@"
16 BUILD_SHARED="@shared@"
17 BUILD_PIC_DEFAULT="@pic_default@"
18 BUILD_PROFILE="@profile@"
19 BUILD_OMITFP="@omitfp@"
20 BUILD_BOUNDED="@bounded@"
21 BUILD_STATIC_NSS="@static_nss@"
22 STDIO="@stdio@"
24 PATH=/bin:/usr/bin:/usr/local/bin:$PATH
25 export PATH
27 TEMP=/tmp/glibcbug.$$
29 BUGADDR=${1-$BUGGLIBC}
30 ENVIRONMENT=`uname -a`
32 : ${EDITOR=emacs}
34 : ${USER=${LOGNAME-`whoami`}}
36 trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
37 trap 'rm -f $TEMP $TEMP.x' 0
40 # How to read the passwd database.
41 PASSWD="cat /etc/passwd"
43 if [ -f /usr/lib/sendmail ] ; then
44 MAIL_AGENT="/usr/lib/sendmail -oi -t"
45 elif [ -f /usr/sbin/sendmail ] ; then
46 MAIL_AGENT="/usr/sbin/sendmail -oi -t"
47 else
48 MAIL_AGENT=rmail
51 # Figure out how to echo a string without a trailing newline
52 N=`echo 'hi there\c'`
53 case "$N" in
54 *c) ECHON1='echo -n' ECHON2= ;;
55 *) ECHON1=echo ECHON2='\c' ;;
56 esac
58 # Find out the name of the originator of this PR.
59 if [ -n "$NAME" ]; then
60 ORIGINATOR="$NAME"
61 elif [ -f $HOME/.fullname ]; then
62 ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
63 else
64 # Must use temp file due to incompatibilities in quoting behavior
65 # and to protect shell metacharacters in the expansion of $LOGNAME
66 $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
67 ORIGINATOR="`cat $TEMP`"
68 rm -f $TEMP
71 if [ -n "$ORGANIZATION" ]; then
72 if [ -f "$ORGANIZATION" ]; then
73 ORGANIZATION="`cat $ORGANIZATION`"
75 else
76 if [ -f $HOME/.organization ]; then
77 ORGANIZATION="`cat $HOME/.organization`"
78 elif [ -f $HOME/.signature ]; then
79 ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"`
83 # If they don't have a preferred editor set, then use
84 if [ -z "$VISUAL" ]; then
85 if [ -z "$EDITOR" ]; then
86 EDIT=vi
87 else
88 EDIT="$EDITOR"
90 else
91 EDIT="$VISUAL"
94 # Find out some information.
95 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
96 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
97 ARCH=`[ -f /bin/arch ] && /bin/arch`
98 MACHINE=`[ -f /bin/machine ] && /bin/machine`
100 ORGANIZATION_C='<organization of PR author (multiple lines)>'
101 SYNOPSIS_C='<synopsis of the problem (one line)>'
102 SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
103 PRIORITY_C='<[ low | medium | high ] (one line)>'
104 CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
105 RELEASE_C='<release number or tag (one line)>'
106 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
107 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
108 HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
109 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
112 cat > $TEMP <<EOF
113 SEND-PR: -*- send-pr -*-
114 SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
115 SEND-PR: will all comments (text enclosed in \`<' and \`>').
116 SEND-PR:
117 From: ${USER}
118 To: ${BUGADDR}
119 Subject: [50 character or so descriptive subject here (for reference)]
121 >Submitter-Id: net
122 >Originator: ${ORIGINATOR}
123 >Organization:
124 ${ORGANIZATION- $ORGANIZATION_C}
125 >Confidential: no
126 >Synopsis: $SYNOPSIS_C
127 >Severity: $SEVERITY_C
128 >Priority: $PRIORITY_C
129 >Category: libc
130 >Class: $CLASS_C
131 >Release: libc-${VERSION}
132 >Environment:
133 $ENVIRONMENT_C
134 `[ -n "$HOST" ] && echo Host type: $HOST`
135 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
136 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
137 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
138 `[ -n "$ADDONS" ] && echo Addons: $ADDONS`
139 `[ -n "$CFLAGS" ] && echo Build CFLAGS: $CFLAGS`
140 `[ -n "$CC" ] && echo Build CC: $CC`
141 `[ -n "$VERSIONING" ] && echo Versioning: $VERSIONING`
142 `[ -n "$BUILD_STATIC" ] && echo Build static: $BUILD_STATIC`
143 `[ -n "$BUILD_SHARED" ] && echo Build shared: $BUILD_SHARED`
144 `[ -n "$BUILD_PIC_DEFAULT" ] && echo Build pic-default: $BUILD_PIC_DEFAULT`
145 `[ -n "$BUILD_PROFILE" ] && echo Build profile: $BUILD_PROFILE`
146 `[ -n "$BUILD_OMITFP" ] && echo Build omitfp: $BUILD_OMITFP`
147 `[ -n "$BUILD_BOUNDED" ] && echo Build bounded: $BUILD_BOUNDED`
148 `[ -n "$BUILD_STATIC_NSS" ] && echo Build static-nss: $BUILD_STATIC_NSS`
149 `[ -n "$STDIO" ] && echo Stdio: $STDIO`
151 >Description:
152 $DESCRIPTION_C
153 >How-To-Repeat:
154 $HOW_TO_REPEAT_C
155 >Fix:
156 $FIX_C
159 chmod u+w $TEMP
160 cp $TEMP $TEMP.x
162 eval $EDIT $TEMP
164 if cmp -s $TEMP $TEMP.x; then
165 echo "File not changed, no bug report submitted."
166 exit 1
170 # Check the enumeration fields
172 # This is a "sed-subroutine" with one keyword parameter
173 # (with workaround for Sun sed bug)
175 SED_CMD='
176 /$PATTERN/{
177 s|||
178 s|<.*>||
179 s|^[ ]*||
180 s|[ ]*$||
186 while :; do
187 CNT=0
190 # 1) Severity
192 PATTERN=">Severity:"
193 SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
194 case "$SEVERITY" in
195 ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
196 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
197 esac
199 # 2) Priority
201 PATTERN=">Priority:"
202 PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
203 case "$PRIORITY" in
204 ""|low|medium|high) CNT=`expr $CNT + 1` ;;
205 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
206 esac
208 # 3) Class
210 PATTERN=">Class:"
211 CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
212 case "$CLASS" in
213 ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
214 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
215 esac
217 [ $CNT -lt 3 ] &&
218 echo "Errors were found with the problem report."
220 while :; do
221 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
222 read input
223 case "$input" in
225 echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
226 cat $TEMP >> $HOME/dead.glibcbug
227 xs=1; exit
230 eval $EDIT $TEMP
231 continue 2
234 break 2
236 esac
237 done
238 done
240 # Remove comments and send the problem report
241 # (we have to use patterns, where the comment contains regex chars)
243 # /^>Originator:/s;$ORIGINATOR;;
244 sed -e "
245 /^SEND-PR:/d
246 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
247 /^>Confidential:/s;<.*>;;
248 /^>Synopsis:/s;$SYNOPSIS_C;;
249 /^>Severity:/s;<.*>;;
250 /^>Priority:/s;<.*>;;
251 /^>Class:/s;<.*>;;
252 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
253 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
254 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
255 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
256 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
257 " $TEMP > $TEMP.x
259 if $MAIL_AGENT < $TEMP.x; then
260 echo "$COMMAND: problem report sent"
261 xs=0; exit
262 else
263 echo "$COMMAND: mysterious mail failure, report not sent."
264 echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
265 cat $TEMP >> $HOME/dead.glibcbug
268 exit 0