File: send-pr.sh

package info (click to toggle)
dosemu 0.66.7-13
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,672 kB
  • ctags: 7,566
  • sloc: ansic: 60,209; sh: 3,965; asm: 2,219; yacc: 1,980; makefile: 831; perl: 598; lex: 506; awk: 398
file content (341 lines) | stat: -rwxr-xr-x 6,475 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/sh
#
# This program sends a bug report
#
# This script is (c) Copyright 1996 Alistair MacDonald 
#                                   <alistair@slitesys.demon.co.uk>
#
# It is made available to the DOSEmu project under the GPL Version 2, or at
# your option any later version. Details of this Licence can be found in the
# file 'COPYING' in the distribution's top level directory.
#
# Version 0.1
#  Initial Version.
#

# A Few settings
TEMP="/tmp/$0.$$"
EXEC_PREFIX="../setup/"
REPORT_FILE="/tmp/dosemu-bug-report.$$"

. ${EXEC_PREFIX}/select-dialog

clean_up() {
  rm -f ${TEMP}*
  exit
}

get_value() {
  local TMP

  eval "TMP=\"\$$2\""

  if [ "@$TMP" != "@" ]
  then
    eval "$1=\"$TMP\""
  fi
}

set_value() {
  eval "$1=\"$2\""
}

set_editor() {
  if [ "@$EDITOR" != "@" ]
  then
    set_value editor $EDITOR
  elif [ "@$VISUAL" != "@" ]
  then
    set_value editor $VISUAL
  else
    set_value editor vi
  fi
}

set_email() {
    set_value from `sh get-email.sh`
}


set_defaults() {
  set_editor
  set_email
  set_value sendreport on
  set_value severity non-critical
  set_value category misc
   touch "$TEMP.description"
  touch "$TEMP.repeat"
  touch "$TEMP.fix"
}

handle_response_value() {
  if [ "$1" = "*\"$2\"*" ]
  then
    set_value "$3" "on"
  else
    set_value "$3" "off"
  fi
}

MainMenu_End() {
  local value
  local reportaction
  local STRING=""

  handle_Report_Action
}

handle_Save_Report() {
  set_value action "save"
  process_report

  # Force an exit!
  clean_up
}

handle_Email_Report() {
  set_value action "email"
  process_report

  # Force an exit!
  clean_up
}

handle_Cancel_Report() {
  set_value action "cancel"
  process_report

  # Force an exit!
  clean_up
}

process_report() {
  reportaction=""
  get_value reportaction action
  if [ "@$reportaction" = "@email" -o "@$reportaction" = "@save" ]
  then

    $DIALOG --backtitle "DOSEmu Bug Reporting." \
      --infobox "Building Bug Report ..." 3 50 2> /dev/null

    value=""
    get_value value debug_filename
    if [ "@$value" != "@" ]
    then
      DEBUG_STRING="-d $value"
    fi

    # Check the FROM address. If this is blank then we let send-pr decide.
    value=""
    get_value value from
    if [ "@$value" != "@" ]
    then
      LOGNAME=$value
      export LOGNAME
    fi

    (cd ..; gnats/send-pr -P $DEBUG_STRING > "$TEMP.pr")

    echo > $TEMP

    value=""
    get_value value synopsis
    if [ "@$value" != "@" ]
    then
      insert_value synopsis "$value"
    fi

    # Use the synopsis for a subject - since it defaults to ""
    echo "tolower(\$1) == \"subject:\" {" >> $TEMP
    echo "print \$1,\"[DOSEMU BUG] $value\"" >> $TEMP
    echo "next" >> $TEMP
    echo "}" >> $TEMP

    value=""
    get_value value severity
    if [ "@$value" != "@" ]
    then
      insert_value severity "$value"
    fi

    value=""
    get_value value category
    if [ "@$value" != "@" ]
    then
      insert_value category "$value"
    fi

    value=""
    get_value value class
    if [ "@$value" != "@" ]
    then
      insert_value class "$value"
    fi

    insert_value confidential "no"

    insert_file description description
    insert_file "how-to-repeat" repeat
    insert_file "fix" fix

    echo "{ print \$0 }" >> $TEMP

    awk -f $TEMP $TEMP.pr > $TEMP.pr.ready

    clear
    echo "Please Wait: Final Processing ...."

    if [ "@$reportaction" = "@email" ]
    then
      (cd ..; echo "s" | gnats/send-pr --file "$TEMP.pr.ready" | grep -v "a)bort" )
      return 0
    else
      awk  '/SEND-PR:/ { next } { gsub(/<.*>/, ""); print }' "$TEMP.pr.ready" > $REPORT_FILE
      echo "Bug report left in $REPORT_FILE"
      return 0
    fi      
  else
    clear
  fi
}

insert_value() {
      echo "tolower(\$1) == \">$1:\" {" >> $TEMP
      echo "print \$1,\"  $2\"" >> $TEMP
      echo "next" >> $TEMP
      echo "}" >> $TEMP
}

insert_file() {
      echo "tolower(\$1) == \">$1:\" {" >> $TEMP
      echo "print \$1" >> $TEMP
      echo "system(\"cat $TEMP.$2\")" >> $TEMP
      echo "print \"\"" >> $TEMP
      echo "next" >> $TEMP
      echo "}" >> $TEMP
}

load_menus() {
  $DIALOG --backtitle "DOSEmu Bug Reporting." \
    --infobox "Building Menus ..." 3 50 2> /dev/null

  # Create the menus
  awk -f "${EXEC_PREFIX}/parse-menu-sh" -f "${EXEC_PREFIX}/parse-menu" -f "${EXEC_PREFIX}/parse-misc" send-pr.menu > $TEMP
  # Load them up ...
  . $TEMP

}

handle_Show_Description() {
    show_file "$TEMP.description"
}

handle_Append_file_to_Description() {
    append_file "description" "description"
}

handle_Edit_Description() {
    edit_file "$TEMP.description"
}

handle_Show_Duplication_information() {
    show_file "$TEMP.repeat"
}

handle_Append_file_to_Duplication_information() {
    append_file "duplication information" "repeat"
}

handle_Edit_Duplication_information() {
    edit_file "$TEMP.repeat"
}

handle_Show_Fix() {
    show_file "$TEMP.fix"
}

handle_Append_file_to_Fix() {
    append_file "fix" "fix"
}

handle_Edit_Fix() {
    edit_file "$TEMP.fix"
}

show_file() {
  $DIALOG --backtitle "DOSEmu Bug Reporting" \
     --textbox $1 20 80 2> /dev/null

  return 0
}

append_file() {
  local DESCRIPTION
  local FILE_EXTN
  local RESULT
  local FILENAME

  DESCRIPTION=$1
  FILE_EXTN=$2

  while [ $FINISHED -ne 1 ]
  do
    $DIALOG --backtitle "DOSEmu Bug Reporting." \
      --title "Input File for $DESCRIPTION" \
      --inputbox "Please enter the name of the file containing the $DESCRIPTION information:" \
      9 60 2> $TEMP
  
    RESULT=$?

    if [ $RESULT -eq 0 -o $RESULT -eq 3 -o $RESULT -eq 6 ]
    then
      FILENAME=`cat $TEMP`
      FINISHED=1
    elif [ $RESULT -eq 1 ]
    then
      $DIALOG --backtitle "DOSEmu Bug Reporting." \
      --msgbox "Please enter the name of the file containing the $DESCRIPTION information. The file will be looked for relative to the top level DOSEmu directory by your default shell. (Warning - the ~ may not work.)" \
      9 60 2> /dev/null
    else
      FINISHED=1
    fi
  done

  if [ "@$FILENAME" != "@" ]
  then
    (cd ..; cat $FILENAME >> "$TEMP.$FILE_EXTN" ) 2> $TEMP

    RESULT=$?

    if [ $RESULT -ne 0 ]
    then
      $DIALOG --backtitle "DOSEmu Bug Reporting." \
      --msgbox "The following error message was returned by the system: `cat $TEMP`" 9 60
    fi
  fi
}

edit_file() {
  local EDIT

  get_value EDIT editor

  eval $EDIT $1

  return 0
}

main() {

  set_defaults

  load_menus

  start

  clean_up
}


# Start the whole process ...
main