]>
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@" |
df4ef2ab UD |
12 | |
13 | PATH=/bin:/usr/bin:/usr/local/bin:$PATH | |
14 | export PATH | |
15 | ||
16 | TEMP=/tmp/glibcbug.$$ | |
17 | ||
18 | BUGADDR=${1-$BUGGLIBC} | |
19 | ENVIRONMENT=`uname -a` | |
20 | ||
21 | : ${EDITOR=emacs} | |
22 | ||
23 | : ${USER=${LOGNAME-`whoami`}} | |
24 | ||
25 | trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15 | |
26 | trap 'rm -f $TEMP $TEMP.x' 0 | |
27 | ||
28 | ||
29 | # How to read the passwd database. | |
30 | PASSWD="cat /etc/passwd" | |
31 | ||
32 | if [ -f /usr/lib/sendmail ] ; then | |
5290baf0 | 33 | MAIL_AGENT="/usr/lib/sendmail -oi -t" |
df4ef2ab | 34 | elif [ -f /usr/sbin/sendmail ] ; then |
5290baf0 | 35 | MAIL_AGENT="/usr/sbin/sendmail -oi -t" |
df4ef2ab | 36 | else |
5290baf0 | 37 | MAIL_AGENT=rmail |
df4ef2ab UD |
38 | fi |
39 | ||
40 | # Figure out how to echo a string without a trailing newline | |
41 | N=`echo 'hi there\c'` | |
42 | case "$N" in | |
43 | *c) ECHON1='echo -n' ECHON2= ;; | |
44 | *) ECHON1=echo ECHON2='\c' ;; | |
45 | esac | |
46 | ||
47 | # Find out the name of the originator of this PR. | |
48 | if [ -n "$NAME" ]; then | |
49 | ORIGINATOR="$NAME" | |
50 | elif [ -f $HOME/.fullname ]; then | |
51 | ORIGINATOR="`sed -e '1q' $HOME/.fullname`" | |
52 | else | |
53 | # Must use temp file due to incompatibilities in quoting behavior | |
54 | # and to protect shell metacharacters in the expansion of $LOGNAME | |
55 | $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP | |
56 | ORIGINATOR="`cat $TEMP`" | |
57 | rm -f $TEMP | |
58 | fi | |
59 | ||
60 | if [ -n "$ORGANIZATION" ]; then | |
61 | if [ -f "$ORGANIZATION" ]; then | |
62 | ORGANIZATION="`cat $ORGANIZATION`" | |
63 | fi | |
64 | else | |
65 | if [ -f $HOME/.organization ]; then | |
66 | ORGANIZATION="`cat $HOME/.organization`" | |
67 | elif [ -f $HOME/.signature ]; then | |
68 | ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"` | |
69 | fi | |
70 | fi | |
71 | ||
72 | # If they don't have a preferred editor set, then use | |
73 | if [ -z "$VISUAL" ]; then | |
74 | if [ -z "$EDITOR" ]; then | |
75 | EDIT=vi | |
76 | else | |
77 | EDIT="$EDITOR" | |
78 | fi | |
79 | else | |
80 | EDIT="$VISUAL" | |
81 | fi | |
82 | ||
83 | # Find out some information. | |
84 | SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \ | |
85 | ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""` | |
86 | ARCH=`[ -f /bin/arch ] && /bin/arch` | |
87 | MACHINE=`[ -f /bin/machine ] && /bin/machine` | |
88 | ||
89 | ORGANIZATION_C='<organization of PR author (multiple lines)>' | |
df4ef2ab UD |
90 | SYNOPSIS_C='<synopsis of the problem (one line)>' |
91 | SEVERITY_C='<[ non-critical | serious | critical ] (one line)>' | |
92 | PRIORITY_C='<[ low | medium | high ] (one line)>' | |
93 | CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>' | |
94 | RELEASE_C='<release number or tag (one line)>' | |
95 | ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>' | |
96 | DESCRIPTION_C='<precise description of the problem (multiple lines)>' | |
97 | HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>' | |
98 | FIX_C='<how to correct or work around the problem, if known (multiple lines)>' | |
99 | ||
100 | ||
101 | cat > $TEMP <<EOF | |
102 | SEND-PR: -*- send-pr -*- | |
103 | SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as | |
104 | SEND-PR: will all comments (text enclosed in \`<' and \`>'). | |
105 | SEND-PR: | |
106 | From: ${USER} | |
107 | To: ${BUGADDR} | |
108 | Subject: [50 character or so descriptive subject here (for reference)] | |
109 | ||
831372e7 | 110 | >Submitter-Id: net |
df4ef2ab UD |
111 | >Originator: ${ORIGINATOR} |
112 | >Organization: | |
113 | ${ORGANIZATION- $ORGANIZATION_C} | |
831372e7 | 114 | >Confidential: no |
df4ef2ab UD |
115 | >Synopsis: $SYNOPSIS_C |
116 | >Severity: $SEVERITY_C | |
117 | >Priority: $PRIORITY_C | |
118 | >Category: libc | |
119 | >Class: $CLASS_C | |
120 | >Release: libc-${VERSION} | |
121 | >Environment: | |
0c5ecdc4 | 122 | $ENVIRONMENT_C |
1618c590 | 123 | `[ -n "$HOST" ] && echo Host type: $HOST` |
df4ef2ab UD |
124 | `[ -n "$SYSTEM" ] && echo System: $SYSTEM` |
125 | `[ -n "$ARCH" ] && echo Architecture: $ARCH` | |
126 | `[ -n "$MACHINE" ] && echo Machine: $MACHINE` | |
127 | `[ -n "$ADDONS" ] && echo Addons: $ADDONS` | |
128 | ||
129 | >Description: | |
130 | $DESCRIPTION_C | |
131 | >How-To-Repeat: | |
132 | $HOW_TO_REPEAT_C | |
133 | >Fix: | |
134 | $FIX_C | |
135 | EOF | |
136 | ||
137 | chmod u+w $TEMP | |
138 | cp $TEMP $TEMP.x | |
139 | ||
140 | eval $EDIT $TEMP | |
141 | ||
142 | if cmp -s $TEMP $TEMP.x; then | |
143 | echo "File not changed, no bug report submitted." | |
144 | exit 1 | |
145 | fi | |
146 | ||
147 | #\f | |
148 | # Check the enumeration fields | |
149 | ||
150 | # This is a "sed-subroutine" with one keyword parameter | |
151 | # (with workaround for Sun sed bug) | |
152 | # | |
153 | SED_CMD=' | |
154 | /$PATTERN/{ | |
155 | s||| | |
156 | s|<.*>|| | |
5290baf0 UD |
157 | s|^[ ]*|| |
158 | s|[ ]*$|| | |
df4ef2ab UD |
159 | p |
160 | q | |
161 | }' | |
162 | ||
163 | ||
164 | while :; do | |
165 | CNT=0 | |
166 | ||
df4ef2ab | 167 | # |
0c5ecdc4 | 168 | # 1) Severity |
df4ef2ab UD |
169 | # |
170 | PATTERN=">Severity:" | |
171 | SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` | |
172 | case "$SEVERITY" in | |
173 | ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;; | |
174 | *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'." | |
175 | esac | |
176 | # | |
0c5ecdc4 | 177 | # 2) Priority |
df4ef2ab UD |
178 | # |
179 | PATTERN=">Priority:" | |
180 | PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` | |
181 | case "$PRIORITY" in | |
182 | ""|low|medium|high) CNT=`expr $CNT + 1` ;; | |
183 | *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'." | |
184 | esac | |
185 | # | |
0c5ecdc4 | 186 | # 3) Class |
df4ef2ab UD |
187 | # |
188 | PATTERN=">Class:" | |
189 | CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP` | |
190 | case "$CLASS" in | |
191 | ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;; | |
192 | *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'." | |
193 | esac | |
194 | ||
0c5ecdc4 | 195 | [ $CNT -lt 3 ] && |
df4ef2ab UD |
196 | echo "Errors were found with the problem report." |
197 | ||
198 | while :; do | |
199 | $ECHON1 "a)bort, e)dit or s)end? $ECHON2" | |
200 | read input | |
201 | case "$input" in | |
202 | a*) | |
203 | echo "$COMMAND: problem report saved in $HOME/dead.glibcbug." | |
204 | cat $TEMP >> $HOME/dead.glibcbug | |
205 | xs=1; exit | |
206 | ;; | |
207 | e*) | |
208 | eval $EDIT $TEMP | |
209 | continue 2 | |
210 | ;; | |
211 | s*) | |
212 | break 2 | |
213 | ;; | |
214 | esac | |
215 | done | |
216 | done | |
217 | # | |
218 | # Remove comments and send the problem report | |
219 | # (we have to use patterns, where the comment contains regex chars) | |
220 | # | |
221 | # /^>Originator:/s;$ORIGINATOR;; | |
222 | sed -e " | |
223 | /^SEND-PR:/d | |
224 | /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;; | |
225 | /^>Confidential:/s;<.*>;; | |
226 | /^>Synopsis:/s;$SYNOPSIS_C;; | |
227 | /^>Severity:/s;<.*>;; | |
228 | /^>Priority:/s;<.*>;; | |
229 | /^>Class:/s;<.*>;; | |
230 | /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;; | |
231 | /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;; | |
232 | /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;; | |
233 | /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;; | |
234 | /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;; | |
5290baf0 | 235 | " $TEMP > $TEMP.x |
df4ef2ab | 236 | |
2f6d1f1b | 237 | if $MAIL_AGENT < $TEMP.x; then |
df4ef2ab UD |
238 | echo "$COMMAND: problem report sent" |
239 | xs=0; exit | |
240 | else | |
241 | echo "$COMMAND: mysterious mail failure, report not sent." | |
242 | echo "$COMMAND: problem report saved in $HOME/dead.glibcbug." | |
243 | cat $TEMP >> $HOME/dead.glibcbug | |
244 | fi | |
245 | ||
246 | exit 0 |