[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#645521: debian package for owx, and wrapper script



Hi,

I have packaged your owx utility to Debian. It is not yet in the main
archive as I do not have full rights there yet, but I have published it
in Koumbit's debian archive:

http://debian.koumbit.net/debian/pool/main/o/owx/

I have done a few patches to the makefile so it installs cleanly
(according to the FHS) on Debian.

I have also added a custom wrapper script of my own that makes the
operation of my radio much more easy and reliable.

I hope those patches can be factored into your code. I have attached
them to this message in the hope you can review and approve them, or
comment on them if you see any problems.

Also, it would be useful for packaging to have clear releases, if not
only release dates. I have named the package version after the last
commit date.

Let me know what you think,

A.

Attachment: pgpYmcRrTkF0z.pgp
Description: PGP signature

Description: support DESTDIR variable
 This patch adds support for the PREFIX and DESTDIR variable in the
 main makefile.
---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: debian
Forwarded: no
Reviewed-By: Antoine Beaupré <anarcat@koumbit.org>
Last-Update: 2011-10-26

--- owx-0~20110415.orig/src/Makefile
+++ owx-0~20110415/src/Makefile
@@ -7,8 +7,11 @@ RM	= rm -f
 INSTALL	= install
 LN	= ln
 
-LIBXDIR	= /usr/local/libexec/
-BINDIR	= /usr/local/bin/
+PREFIX?= /usr/local
+DESTDIR?=
+
+LIBXDIR	= $(DESTDIR)/$(PREFIX)/libexec/
+BINDIR	= $(DESTDIR)/$(PREFIX)/bin/
 
 CXXFLAGS= -pipe -Wall -Wextra -O2 -g
 LDFLAGS	= 
Description: install owx in sbin
 libexec is not supported by the FHS, install owx in /usr/sbin instead.

--- owx-0~20110415.orig/src/Makefile
+++ owx-0~20110415/src/Makefile
@@ -10,7 +10,7 @@ LN	= ln
 PREFIX?= /usr/local
 DESTDIR?=
 
-LIBXDIR	= $(DESTDIR)/$(PREFIX)/libexec/
+LIBXDIR	= $(DESTDIR)/$(PREFIX)/sbin/
 BINDIR	= $(DESTDIR)/$(PREFIX)/bin/
 
 CXXFLAGS= -pipe -Wall -Wextra -O2 -g
Description: simple wrapper script
 This script makes the operation on the .csv files more intuitive and
 reliable.

--- /dev/null
+++ owx-0~20110415/src/wouxun
@@ -0,0 +1,136 @@
+#! /bin/sh -e
+
+# simple wrapper script around the owx utility
+
+device=/dev/ttyUSB0
+delay=10
+
+usage() {
+    cat <<EOF
+$0 ( -i | -x ) [ <csvfile> ]
+
+-r reload pl2313 kernel module before doing anything (requires sudo)
+-i import csv into device
+-x export device into csv
+-f overwrite existing csv file during export
+-n simulate, don't do anything but checks
+-h this help
+
+<csvfile> defaults to wouxun.csv and must exist for import
+EOF
+    trap "" 0
+    exit 1
+}
+
+fail() {
+    cat <<EOF
+this thing is not working. try this:
+ 1. plug the damn thing in dude
+ 2. turn it off, unplug the dongle, plug it back in and turn it back on
+
+if all else fails: try turning it off and on again.
+
+if you already tried that, smartass, try reloading the pl2303 driver
+
+and if that fails too, try again tomorrow
+EOF
+    trap "" 0
+    exit 1
+}
+
+do_export() {
+    if [ -e "$csv" -a -z $force ]; then
+        while true; do
+            printf "file $csv already exists, overwrite? [y/N] "
+            read ans
+            case "$ans" in
+                [Yy]|[Yy][Ee][Ss]) break;;
+                ""|[Nn]|[Nn][Oo]) trap "" 0; exit 1;;
+                *) echo "uh? try again.";;
+            esac
+        done
+    fi
+        
+    if owx-check -p ${device}; then
+        echo "device detected on ${device}, letting it rest $delay seconds"
+        $simulate sleep $delay
+        echo "fetching the current image in file.bin"
+        $simulate owx-get ${force} -p ${device} -o file.bin
+        echo "converted to CSV file ${csv}"
+        $simulate owx-export -i file.bin -o "${csv}"
+        echo "converting back to unix file format"
+        $simulate sed -i "s/\r//" "${csv}"
+    fi
+}
+
+do_import() {
+
+    if [ ! -r "$csv" ]; then
+        echo "file $csv not readable"
+        usage
+    fi
+
+    if owx-check -p ${device}; then
+        echo "device detected on ${device}, letting it rest $delay seconds"
+        $simulate sleep $delay
+        echo "fetching the current image in file.bin"
+        $simulate owx-get ${force} -p ${device} -o file.bin
+        echo "backing up to backup.bin"
+        $simulate cp -f file.bin backup.bin
+        echo "patching image with $csv"
+        $simulate owx-import -i "$csv" -o file.bin
+        echo "sleeping $delay more"
+        $simulate sleep $delay
+        echo "loading image based on backup"
+        $simulate owx-put -p ${device}  -i file.bin -r backup.bin
+        echo "letting the device rest $delay more seconds"
+        $simulate sleep $delay
+        echo "okidou, all seems to have worked all great"
+        echo "please unplug that proprietary crap out of this box now"
+    else
+        fail
+    fi
+}
+
+do_reload_module() {
+	$simulate sudo modprobe -r pl2303
+	$simulate sleep 1
+	$simulate sudo modprobe pl2303
+	$simulate sleep $delay
+}
+
+set -- `getopt hxinfr $*`
+
+for i; do
+        case "$i" in
+              -h) shift; usage;;
+              -r) shift; reload="yes";;
+              -n) shift; simulate="echo > ";;
+              -x) shift; dothis="do_export";;
+              -i) shift; dothis="do_import";;
+              -f) shift; force="-f";;
+              --) shift; break;;
+        esac
+done
+
+csv=${@:-wouxun.csv}
+
+if [ -z "$dothis" ]; then
+    usage
+fi
+
+if [ ! -z "$simulate" ]; then
+    echo "*** SIMULATION: ECHOING COMMANDS ***"
+fi
+
+trap fail 0
+
+if [ ! -z "$reload" ]; then
+	echo "Reloading pl2313 kernel module..."
+	do_reload_module
+fi
+
+echo "preparing to $dothis on device..."
+$dothis
+
+trap "" 0
--- owx-0~20110415.orig/src/Makefile
+++ owx-0~20110415/src/Makefile
@@ -41,6 +41,7 @@ install: all
 	$(LN) -f -s $(LIBXDIR)$(NAME) $(BINDIR)$(NAME)-put
 	$(LN) -f -s $(LIBXDIR)$(NAME) $(BINDIR)$(NAME)-export
 	$(LN) -f -s $(LIBXDIR)$(NAME) $(BINDIR)$(NAME)-import
+	$(INSTALL) -m 755 wouxun $(BINDIR)
 
 .PHONY: clean
 clean:
--- /dev/null	2011-10-17 01:04:54.909454458 -0400
+++ owx-0~20110415/src/wouxun.1	2011-10-26 22:22:04.280294824 -0400
@@ -0,0 +1,56 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH WOUXUN 1 "October 26, 2011"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+wouxun \- wrapper around the owx utility to operate CSV files directly
+.SH SYNOPSIS
+.B wouxun ( -i | -x ) [ <csvfile> ]
+.SH DESCRIPTION
+This manual page documents briefly the
+.B wouxun
+command.
+.SH OPTIONS
+These options are common to all commands.
+.TP
+.B \-h
+Show summary of options.
+.TP
+.B \-n
+Simulate, don't do anything but checks.
+.TP
+.B \-r
+Reload the pl2313 kernel module before doing anything (requires sudo).
+.TP
+.B \-i [ <csvfile> ]
+Import the given CSV into the device (defaults to wouxun.csv).
+.TP
+.B \-x [ <csvfile> ]
+Export the device into the given CSV file (defaults to
+wouxun.csv). Will not overwrite the file unless
+.B \-f
+is specified.
+.TP
+.B \-f
+Overwrite any existing .csv file.
+.SH SEE ALSO
+.BR owx (1), chirp (1),
+the README file.
+.SH AUTHOR
+The wouxun wrapper was writte by Antoine Beaupré <anarcat@koumbit.org>.
+.PP
+This manual page was written by Antoine Beaupré <anarcat@koumbit.org>,
+for the Debian project (and may be used by others).

-- 
Ce que les siècles des grands abatoirs nous aura appris
Devrait être inscrit au fond de toutes les écoles;
Voici l'homme: le destructeur des mondes est arrivé.
                        - [no one is innocent]

Reply to: