]> pd.if.org Git - zpackage/commitdiff
initial implementation of zpm-bug
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 1 Mar 2015 15:08:41 +0000 (15:08 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 1 Mar 2015 15:09:35 +0000 (15:09 +0000)
Makefile
zpm-bug [new file with mode: 0755]
zpm-note

index fb3494ed7d3b0ef98be93f0445304574bdf79924..195aca3a7faf0495c5f0fc6abf86f16410d1b363 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ elftype: elf/elftype.c
 install: elftype
        install -D zpm $(DESTDIR)/bin/zpm
        install -D zpm-note $(DESTDIR)/bin/zpm-note
+       install -D zpm-bug $(DESTDIR)/bin/zpm-bug
        install -D zpm-sequence $(DESTDIR)/bin/zpm-sequence
        install -d -m2770 -o root -g adm $(DESTDIR)/var/lib/admin
        install -d -m2770 -o root -g adm $(DESTDIR)/var/lib/admin/notes
diff --git a/zpm-bug b/zpm-bug
new file mode 100755 (executable)
index 0000000..892e60f
--- /dev/null
+++ b/zpm-bug
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+# program to submit a bug report
+
+# TODO
+# gpg encrypt the report.  this will require that
+# the submitter have gpg set up, we might be able
+# to use a system one
+#
+# 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 gpg encrypt the file
+# gpg -ea -r bugreport@zoranix.net
+
+# 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
index e9115440fd74d7bc1791cdca78c1ee560734cbe2..72f5f401a9d8c2c514a7868c98af78dabcf74580 100755 (executable)
--- a/zpm-note
+++ b/zpm-note
@@ -37,7 +37,7 @@ shift
 findnote() {
        file=$(find $SPOOL -type f -name "$1")
        if [ -z "$file" ] ; then
-               [ -z "$quiet" ] || printf "no such note $1\n"
+               [ -z "$quiet" ] || printf "no such note $1\n" 1>&2
                exit 1
        fi
        echo $file
@@ -46,13 +46,17 @@ findnote() {
 findopen() {
        file=$(find $SPOOL/open -type f -name "$1")
        if [ -z "$file" ] ; then
-               [ -z "$quiet" ] || printf "no such open note $1\n"
+               [ -z "$quiet" ] || printf "no such open note $1\n" 1>&2
                exit 1
        fi
        echo $file
 }
 
 case $cmd in
+       category)
+               notefile=$(findnote $1)
+               printf "%s\n" $(basename $(dirname $notefile))
+               ;;
        list)
                case $1 in
                        -a) find $SPOOL/ack -type f -printf '%P\n' | sort -n