]> pd.if.org Git - zpackage/blob - zpm-bug
fix segfault reading statically linked executables
[zpackage] / zpm-bug
1 #!/bin/sh
2
3 # program to submit a bug report
4
5 # TODO
6 # gpg encrypt the report.  this will require that
7 # the submitter have gpg set up, we might be able
8 # to use a system one
9 #
10 # allow a bug report from stdin
11
12 set -e
13
14 [ -f /etc/rc.conf ] && . /etc/rc.conf
15 [ -f /etc/zoranix.conf ] && . /etc/zoranix.conf
16
17 name=$(logname)
18 host=$(hostname)
19 from=${REPLYTO:-${name}@${host}}
20
21 signature=
22 if [ -r $HOME/.signature ]; then
23         signature=$(cat $HOME/.signature)
24 else
25         signature=$(printf '-- \n%s\n' $name)
26 fi
27
28 # -n <note> -- make a bug report out of a note
29 file=$(mktemp ${TMPDIR:-/tmp}/bugreport-XXXXXX)
30
31 note=
32 package=${1:-general}
33 subject='zoranix bug report'
34
35 if [ "$1" = "-n" ]; then
36         shift
37         if [ $# -eq 0 ]; then
38                 rm $file
39                 usage
40         fi
41         note=$1
42         package=$(zpm note category $1)
43         subject=$(zpm note show $1 | head -1)
44         if [ $subject = "" ]; then
45                 subject='zoranix bug report'
46         fi
47 fi
48
49 cat >$file <<EOR
50 Subject: $subject
51 X-Package: $package
52 X-SupportId: $SUPPORTID
53 From: $from
54 To: ${BUGREPORTEMAIL:-bugreport@zoranix.net}
55
56 EOR
57
58 if [ -n "$note" ]; then
59         zpm note show $note > $file
60 elif [ -f /etc/zpm/bugtemplate ]; then
61         cat /etc/zpm/bugtemplate >> $file
62 else
63 cat >>$file <<EOR
64 Please write your bug report here.  This note will be submitted via
65 ${BUGSUBMITVIA:-https}.
66 EOR
67 fi
68
69 cat >>$file <<EOR
70
71 -- 
72 $signature
73 EOR
74
75 ${EDITOR:-vi} $file
76
77 # TODO gpg encrypt the file
78 # gpg -ea -r bugreport@zoranix.net
79
80 # submit the file to the bug destination
81
82 case ${BUGSUBMITVIA:-https} in
83         mail)
84                 mail -s 'zoranix bug report' ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
85                 rm $file
86                 ;;
87         sendmail)
88                 sendmail ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
89                 rm $file
90                 ;;
91         https)
92                 curl -F bug=@$file ${BUGREPORTDEST:-https://zoranix.net/bugreport.cgi}
93                 rm $file
94                 ;;
95         *)
96                 echo "zpm-bug: unknown submission method '${BUGSUBMITVIA:-smtp}'" 1>&2
97                 echo "a copy of your report is in $file" 1>&2
98                 exit 1;
99 esac