]> pd.if.org Git - zpackage/blobdiff - bin/zpm-bug
move programs to bin for build
[zpackage] / bin / zpm-bug
diff --git a/bin/zpm-bug b/bin/zpm-bug
new file mode 100755 (executable)
index 0000000..9b933ba
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# program to submit a bug report
+
+# TODO
+# encrypt the report.  Use chacha20 and a public key
+# for bug submissions.  This key will need to be set up
+# for zoranix.  Should probably use the packager's public
+# key as well.
+#
+# allow a bug report from stdin
+
+set -e
+
+[ -f /etc/rc.conf ] && . /etc/rc.conf
+[ -f /etc/zoranix.conf ] && . /etc/zoranix.conf
+
+name=$(logname)
+host=$(hostname)
+from=${REPLYTO:-${name}@${host}}
+
+signature=
+if [ -r $HOME/.signature ]; then
+       signature=$(cat $HOME/.signature)
+else
+       signature=$(printf '-- \n%s\n' $name)
+fi
+
+# -n <note> -- make a bug report out of a note
+file=$(mktemp ${TMPDIR:-/tmp}/bugreport-XXXXXX)
+
+note=
+package=${1:-general}
+subject='zoranix bug report'
+
+if [ "$1" = "-n" ]; then
+       shift
+       if [ $# -eq 0 ]; then
+               rm $file
+               usage
+       fi
+       note=$1
+       package=$(zpm note category $1)
+       subject=$(zpm note show $1 | head -1)
+       if [ $subject = "" ]; then
+               subject='zoranix bug report'
+       fi
+fi
+
+cat >$file <<EOR
+Subject: $subject
+X-Package: $package
+X-SupportId: $SUPPORTID
+From: $from
+To: ${BUGREPORTEMAIL:-bugreport@zoranix.net}
+
+EOR
+
+if [ -n "$note" ]; then
+       zpm note show $note > $file
+elif [ -f /etc/zpm/bugtemplate ]; then
+       cat /etc/zpm/bugtemplate >> $file
+else
+cat >>$file <<EOR
+Please write your bug report here.  This note will be submitted via
+${BUGSUBMITVIA:-https}.
+EOR
+fi
+
+cat >>$file <<EOR
+
+-- 
+$signature
+EOR
+
+${EDITOR:-vi} $file
+
+# TODO encrypt the file, possibly sign
+# if encrypted, should uuencode the lot
+
+# submit the file to the bug destination
+
+case ${BUGSUBMITVIA:-https} in
+       mail)
+               mail -s 'zoranix bug report' ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
+               rm $file
+               ;;
+       sendmail)
+               sendmail ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
+               rm $file
+               ;;
+       https)
+               curl -F bug=@$file ${BUGREPORTDEST:-https://zoranix.net/bugreport.cgi}
+               rm $file
+               ;;
+       *)
+               echo "zpm-bug: unknown submission method '${BUGSUBMITVIA:-smtp}'" 1>&2
+               echo "a copy of your report is in $file" 1>&2
+               exit 1;
+esac