Skip to content

Commit

Permalink
initial Debian GNU/Linux package
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Jun 29, 2012
1 parent 404bdbd commit 8be4dc8
Show file tree
Hide file tree
Showing 19 changed files with 301 additions and 2 deletions.
5 changes: 5 additions & 0 deletions debian/changelog
@@ -0,0 +1,5 @@
schwinn810 (0.1-1) oneiric; urgency=low

* Initial release

-- Mikhail Titov <mlt@gmx.us> Sun, 24 Jun 2012 01:57:39 -0500
1 change: 1 addition & 0 deletions debian/compat
@@ -0,0 +1 @@
8
16 changes: 16 additions & 0 deletions debian/control
@@ -0,0 +1,16 @@
Source: schwinn810
Section: misc
Priority: extra
Maintainer: Mikhail Titov <mlt@gmx.us>
Build-Depends-Indep: debhelper (>= 8.0.0)
Standards-Version: 3.9.2
Homepage: https://github.com/mlt/schwinn810
Vcs-Git: git://github.com/mlt/schwinn810.git
Vcs-Browser: https://github.com/mlt/schwinn810

Package: schwinn810
Architecture: all
Depends: python-tz, python-serial, ${shlibs:Depends}, ${misc:Depends}
Recommends: gpsbabel, libnotify-bin
Description: Software for Schwinn 810 GPS sport watch with heart rate monitor
Set of a command line tools to extract data and convert into common formats, e.g. GPX, TCX, KML
36 changes: 36 additions & 0 deletions debian/copyright
@@ -0,0 +1,36 @@
Format: http://dep.debian.net/deps/dep5
Upstream-Name: schwinn810
Source: <url://example.com>

Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: <special license>
<Put the license of the package here indented by 1 space>
<This follows the format of Description: lines in control file>
.
<Including paragraphs>

# If you want to use GPL v2 or later for the /debian/* files use
# the following clauses, or change it to suit. Delete these two lines
Files: debian/*
Copyright: 2012 Mikhail Titov <mlt@gmx.us>
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".

# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
1 change: 1 addition & 0 deletions debian/docs
@@ -0,0 +1 @@
README.md
29 changes: 29 additions & 0 deletions debian/rules
@@ -0,0 +1,29 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS


%:
dh $@

override_dh_fixperms:
dh_fixperms
chmod 2775 debian/schwinn810/var/lib/schwinn810
chown :users debian/schwinn810/var/lib/schwinn810

# chmod +x debian/schwinn810/usr/share/schwinn810/env.awk
# chmod +x debian/schwinn810/usr/share/schwinn810/schwinn810_udev
22 changes: 22 additions & 0 deletions debian/schwinn810.config
@@ -0,0 +1,22 @@
#!/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

db_input low schwinn810/port || true
db_go

db_input low schwinn810/dir || true
db_go

db_input low schwinn810/auto || true
db_go

db_input low schwinn810/notify || true
db_go

db_input low schwinn810/hook || true
db_go

db_input low schwinn810/debug || true
db_go
1 change: 1 addition & 0 deletions debian/schwinn810.dirs
@@ -0,0 +1 @@
var/lib/schwinn810
7 changes: 7 additions & 0 deletions debian/schwinn810.install
@@ -0,0 +1,7 @@
src/download.py usr/share/schwinn810/
src/settings.py usr/share/schwinn810/
src/csv2tcx.py usr/share/schwinn810/
linux/babelize.sh usr/share/schwinn810/
linux/env.awk usr/share/schwinn810/
linux/schwinn810 usr/bin/
linux/schwinn810_udev usr/share/schwinn810/
56 changes: 56 additions & 0 deletions debian/schwinn810.postinst
@@ -0,0 +1,56 @@
#!/bin/sh -e

case "$1" in
configure|reconfigure)

. /usr/share/debconf/confmodule

TMPFILE=$(mktemp /tmp/schwinn810-postinst.XXXXXX)
trap "rm -f $TMPFILE" 0

echo "# use dpkg-reconfigure -plow schwinn810" >> $TMPFILE

db_get schwinn810/auto || true
if [[ $RET = true ]]; then
echo "AUTO=true" >> $TMPFILE
else
echo "AUTO=" >> $TMPFILE
fi

db_get schwinn810/port || true
echo "PORT=$RET" >> $TMPFILE

db_get schwinn810/dir || true
echo "DIR=$RET" >> $TMPFILE

db_get schwinn810/notify || true
if [[ $RET = true ]]; then
echo "NOTIFY=true" >> $TMPFILE
else
echo "NOTIFY=" >> $TMPFILE
fi

db_get schwinn810/hook || true
echo "HOOK=$RET" >> $TMPFILE

# db_get schwinn810/offset || true
OFF=$(date +%z)
OFF=${OFF/00/}
echo "OFFSET=$[-OFF]" >> $TMPFILE

db_get schwinn810/debug || true
if [[ $RET = true ]]; then
echo "DEBUG=true" >> $TMPFILE
else
echo "DEBUG=" >> $TMPFILE
fi

ucf --debconf-ok $TMPFILE /etc/schwinn810.conf
chmod +r /etc/schwinn810.conf
ucfr schwinn810 /etc/schwinn810.conf
esac

#DEBHELPER#

udevadm control --reload-rules

11 changes: 11 additions & 0 deletions debian/schwinn810.postrm
@@ -0,0 +1,11 @@
#!/bin/sh

CONFIG=/etc/schwinn810.conf

if [[ $1 = purge ]]; then
test -x /usr/bin/ucfr && ucfr --force --purge schwinn810 $CONFIG
test -x /usr/bin/ucf && ucf --purge $CONFIG
rm -f $CONFIG
fi

#DEBHELPER#
44 changes: 44 additions & 0 deletions debian/schwinn810.templates
@@ -0,0 +1,44 @@
Template: schwinn810/auto
Type: boolean
Default: true
Description: Start automatic data extraction upon device connect.
This makes use of udev to run script.

Template: schwinn810/port
Type: string
Default: /dev/schwinn810
Description: Device to communicate with watch
This package installs udev rule that creates a symbolic link
based on USB vendor & product IDs.
.
This link usually points to /dev/ttyUSB0 unless there are other devices.

Template: schwinn810/dir
Type: string
Default: /var/lib/schwinn810
Description: Where to upload data
All members of users group are able to read/write data at /var/lib/schwinn810 .

Template: schwinn810/notify
Type: boolean
Default: true
Description: Whether to notify user of events
Relies on DBUS, libnotify, and notify-send to send notifications about events.

Template: schwinn810/hook
Type: string
Default: /usr/share/schwinn810/babelize.sh
Description: Post-extraction actions
What to do with extracted track data.
.
Default is to use built-in TCX converter
and gpsbabel (if installed) to get KML & GPX.

Template: schwinn810/debug
Type: boolean
Default: false
Description: Create binary dump in /tmp/schwinn810.bin
This will create /tmp/schwinn810.bin while extracting data.
.
Note that if automatic extraction is used, this file is owned by root.
This may cause problems when regular user extracts data thereafter.
1 change: 1 addition & 0 deletions debian/schwinn810.udev
@@ -0,0 +1 @@
BUS=="usb", SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea61", SYMLINK+="schwinn810", MODE="0666", RUN+="/usr/share/schwinn810/schwinn810_udev"
1 change: 1 addition & 0 deletions debian/source/format
@@ -0,0 +1 @@
3.0 (native)
2 changes: 0 additions & 2 deletions etc/udev/rules.d/50-schwinn810.rules

This file was deleted.

12 changes: 12 additions & 0 deletions linux/babelize.sh
@@ -0,0 +1,12 @@
#!/bin/sh

. /etc/schwinn810.conf

if command -v gpsbabel &> /dev/null ; then
gpsbabel -i unicsv,utc=$OFFSET -f "$1.points" \
-x transform,trk=wpt \
-o gpx -F "$1.gpx" \
-o kml,lines=1,points=0,track=1,trackdirection=1 -F "$1.kml"
fi

/usr/share/schwinn810/csv2tcx.py "$1" > "$1.tcx"
20 changes: 20 additions & 0 deletions linux/env.awk
@@ -0,0 +1,20 @@
#!/usr/bin/gawk -f

BEGIN {
RS = "\0"
OFS = "="
ORS = ""
n = 0
}

/^(XAUTHORITY|DISPLAY|DBUS_SESSION_BUS_ADDRESS)=/ {
env[n++] = $0
}

END {
if (3 == length(env)) {
for (var in env)
print env[var] ";"
print "\n"
}
}
15 changes: 15 additions & 0 deletions linux/schwinn810
@@ -0,0 +1,15 @@
#!/bin/sh

. /etc/schwinn810.conf

[[ $HOOK ]] && HOOK="--hook $HOOK"
[[ $DEBUG ]] && DEBUG="--debug"
YEAR=$(date +%Y)
umask 0002
mkdir -p 2775 $DIR/$YEAR
#mkdir -p -m ug=rwx,o=rx $DIR/$YEAR

/usr/share/schwinn810/download.py $DEBUG $HOOK \
--port $PORT \
--dir $DIR/$YEAR && \
[[ $NOTIFY ]] && notify-send -u low -c transfer.complete "Schwinn 810 GPS watch" "Data extracted"
23 changes: 23 additions & 0 deletions linux/schwinn810_udev
@@ -0,0 +1,23 @@
#!/bin/sh

. /etc/schwinn810.conf

if [[ $NOTIFY ]]; then
LINES=$(find /proc/ -maxdepth 2 -name environ -exec /usr/share/schwinn810/env.awk {} \; | sort -u)
for line in $LINES; do
eval $line
XAUTHORITY=$XAUTHORITY DISPLAY=$DISPLAY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS notify-send -u low -c device.added "Schwinn 810 GPS watch connected"
done;
fi

[[ $AUTO ]] || exit

sleep 2 # delay for watch to initialize
/usr/bin/schwinn810 &> /dev/null

if [[ $RET = 0 && $NOTIFY ]]; then
for line in $LINES; do
eval $line
XAUTHORITY=$XAUTHORITY DISPLAY=$DISPLAY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS notify-send -u low -c device.added "Schwinn 810 GPS watch" "Data extracted"
done;
fi

0 comments on commit 8be4dc8

Please sign in to comment.