]>
Commit | Line | Data |
---|---|---|
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 | # | |
8 | VERSION="@VERSION@" | |
f2ea0f5b | 9 | BUGGLIBC="bugs@gnu.org" |
df4ef2ab | 10 | ADDONS="@subdirs@" |
1618c590 | 11 | HOST="@host@" |
f4017d20 UD |
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@" | |
df4ef2ab UD |
23 | |
24 | PATH=/bin:/usr/bin:/usr/local/bin:$PATH | |
25 | export PATH | |
26 | ||
27 | TEMP=/tmp/glibcbug.$$ | |
28 | ||
29 | BUGADDR=${1-$BUGGLIBC} | |
30 | ENVIRONMENT=`uname -a` | |
31 | ||
32 | : ${EDITOR=emacs} | |
33 | ||
34 | : ${USER=${LOGNAME-`whoami`}} | |
35 | ||
36 | trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15 | |
37 | trap 'rm -f $TEMP $TEMP.x' 0 | |
38 | ||
39 | ||
40 | # How to read the passwd database. | |
41 | PASSWD="cat /etc/passwd" | |
42 | ||
43 | if [ -f /usr/lib/sendmail ] ; then | |
5290baf0 | 44 | MAIL_AGENT="/usr/lib/sendmail -oi -t" |
df4ef2ab | 45 | elif [ -f /usr/sbin/sendmail ] ; then |
5290baf0 | 46 | MAIL_AGENT="/usr/sbin/sendmail -oi -t" |
df4ef2ab | 47 | else |
5290baf0 | 48 | MAIL_AGENT=rmail |
df4ef2ab UD |
49 | fi |
50 | ||
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 | |
57 | ||
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 | |
69 | fi | |
70 | ||
71 | if [ -n "$ORGANIZATION" ]; then | |
72 | if [ -f "$ORGANIZATION" ]; then | |
73 | ORGANIZATION="`cat $ORGANIZATION`" | |
74 | fi | |
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 ">"` | |
80 | fi | |
81 | fi | |
82 | ||
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" | |
89 | fi | |
90 | else | |
91 | EDIT="$VISUAL" | |
92 | fi | |
93 | ||
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` | |
99 | ||
100 | ORGANIZATION_C='<organization of PR author (multiple lines)>' | |
df4ef2ab UD |
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)>' | |
110 | ||
111 | ||
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)] | |
120 | ||
831372e7 | 121 | >Submitter-Id: net |
df4ef2ab UD |
122 | >Originator: ${ORIGINATOR} |
123 | >Organization: | |
124 | ${ORGANIZATION- $ORGANIZATION_C} | |
831372e7 | 125 | >Confidential: no |
df4ef2ab UD |
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: | |
0c5ecdc4 | 133 | $ENVIRONMENT_C |
1618c590 | 134 | `[ -n "$HOST" ] && echo Host type: $HOST` |
df4ef2ab UD |
135 | `[ -n "$SYSTEM" ] && echo System: $SYSTEM` |
136 | `[ -n "$ARCH" ] && echo Architecture: $ARCH` | |
137 | `[ -n "$MACHINE" ] && echo Machine: $MACHINE` | |
138 | `[ -n "$ADDONS" ] && echo Addons: $ADDONS` | |
f4017d20 UD |
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` | |
df4ef2ab UD |
150 | |
151 | >Description: | |
152 | $DESCRIPTION_C | |
153 | >How-To-Repeat: | |
154 | $HOW_TO_REPEAT_C | |
155 | >Fix: | |
156 | $FIX_C | |
157 | EOF | |
158 | ||
159 | chmod u+w $TEMP | |
160 | cp $TEMP $TEMP.x | |
161 | ||
162 | eval $EDIT $TEMP | |
163 | ||
164 | if cmp -s $TEMP $TEMP.x; then | |
165 | echo "File not changed, no bug report submitted." | |
166 | exit 1 | |
167 | fi | |
168 | ||
169 | #\f | |
170 | # Check the enumeration fields | |
171 | ||
172 | # This is a "sed-subroutine" with one keyword parameter | |
173 | # (with workaround for Sun sed bug) | |
174 | # | |
175 | SED_CMD=' | |
176 | /$PATTERN/{ | |
177 | s||| | |
178 | s|<.*>|| | |
5290baf0 UD |
179 | s|^[ ]*|| |
180 | s|[ ]*$|| | |
df4ef2ab UD |
181 | p |
182 | q | |
183 | }' | |
184 | ||
185 | ||
186 | while :; do | |
187 | CNT=0 | |
188 | ||
df4ef2ab | 189 | # |
0c5ecdc4 | 190 | # 1) Severity |
df4ef2ab UD |
191 | # |
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 | |
198 | # | |
0c5ecdc4 | 199 | # 2) Priority |
df4ef2ab UD |
200 | # |
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 | |
207 | # | |
0c5ecdc4 | 208 | # 3) Class |
df4ef2ab UD |
209 | # |
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 | |
216 | ||
0c5ecdc4 | 217 | [ $CNT -lt 3 ] && |
df4ef2ab UD |
218 | echo "Errors were found with the problem report." |
219 | ||
220 | while :; do | |
221 | $ECHON1 "a)bort, e)dit or s)end? $ECHON2" | |
222 | read input | |
223 | case "$input" in | |
224 | a*) | |
225 | echo "$COMMAND: problem report saved in $HOME/dead.glibcbug." | |
226 | cat $TEMP >> $HOME/dead.glibcbug | |
227 | xs=1; exit | |
228 | ;; | |
229 | e*) | |
230 | eval $EDIT $TEMP | |
231 | continue 2 | |
232 | ;; | |
233 | s*) | |
234 | break 2 | |
235 | ;; | |
236 | esac | |
237 | done | |
238 | done | |
239 | # | |
240 | # Remove comments and send the problem report | |
241 | # (we have to use patterns, where the comment contains regex chars) | |
242 | # | |
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;; | |
5290baf0 | 257 | " $TEMP > $TEMP.x |
df4ef2ab | 258 | |
2f6d1f1b | 259 | if $MAIL_AGENT < $TEMP.x; then |
df4ef2ab UD |
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 | |
266 | fi | |
267 | ||
268 | exit 0 |