From 23498ba12222276f9883d8e0007f99b8c305b756 Mon Sep 17 00:00:00 2001 From: Viktor Dragomiretskyy Date: Fri, 10 Jul 2020 17:48:51 +1200 Subject: [PATCH] Added debian packaging --- .gitignore | 11 +++++++++- dbus_service/50-python-validity.rules | 4 ++++ dbus_service/python-validity@.service | 12 +++++++++++ debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 25 +++++++++++++++++++++ debian/copyright | 9 ++++++++ debian/install | 5 +++++ debian/pycompat | 1 + debian/rules | 10 +++++++++ debian/source/format | 1 + requirements.txt | 2 -- setup.py | 3 ++- validitysensor/sensor.py | 31 +++++---------------------- validitysensor/upload_fwext.py | 3 ++- 15 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 dbus_service/50-python-validity.rules create mode 100644 dbus_service/python-validity@.service create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/pycompat create mode 100755 debian/rules create mode 100644 debian/source/format delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 14f41bf..8bfd033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,16 @@ +debian/tmp/ +debian/python3-validity/ +debian/python3-validity.substvars +debian/python3-validity.prerm.debhelper +debian/python3-validity.postinst.debhelper +debian/files +debian/.debhelper/ + __pycache__ +.pybuild/ build dist -python3_validity.egg-info/ +python_validity.egg-info/ tls.dict *.bin *.log diff --git a/dbus_service/50-python-validity.rules b/dbus_service/50-python-validity.rules new file mode 100644 index 0000000..d2dcfee --- /dev/null +++ b/dbus_service/50-python-validity.rules @@ -0,0 +1,4 @@ +# TODO me + +ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0097", TAG+="systemd", ENV{SYSTEMD_WANTS}+="python-validity@usb-$env{BUSNUM}-$env{DEVNUM}.service" + diff --git a/dbus_service/python-validity@.service b/dbus_service/python-validity@.service new file mode 100644 index 0000000..81d9212 --- /dev/null +++ b/dbus_service/python-validity@.service @@ -0,0 +1,12 @@ +# TODO me + +[Unit] +Description=python-validity driver dbus service for %I + +[Service] +Type=simple +ExecStart=/usr/lib/python-validity/dbus-service %i +Restart=no + +#[Install] +#WantedBy=multi-user.target diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..2915641 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +python-validity (0.1~ppa1) bionic; urgency=medium + + * Initial release. + + -- uunicorn Fri, 10 Jul 2020 17:21:35 +1200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..f33b6e5 --- /dev/null +++ b/debian/control @@ -0,0 +1,25 @@ +Source: python-validity +Section: misc +Priority: optional +Maintainer: uunicorn +Build-Depends: debhelper (>= 7.0.50~), + dh-python, + python3-all, + python3-setuptools +X-Python3-Version: >= 3.6 +Standards-Version: 3.9.2 + +Package: python3-validity +Architecture: all +Depends: ${python3:Depends}, + ${misc:Depends}, + python3-dbus, + python3-usb, + dbus, + open-fprintd (>= 0.2~) +XB-Python-Version: ${python3:Versions} +Description: Validity Fingerprint Sensor DBus Driver + This package adds support to some Validity sensors. + . + Warning: this is an experimental software. It lacks proper auth checks. + Install and use at your own risk. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c1a3d54 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,9 @@ + +Files: * +Copyright: Copyright © 2020, uunicorn +License: GPL-2+ + +License: GPL-2+ + On Debian systems, the complete text of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-2'. + diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..4617330 --- /dev/null +++ b/debian/install @@ -0,0 +1,5 @@ +usr/bin +usr/lib/python*/*-packages/*.egg-info +usr/lib/python*/*-packages/validitysensor/*.py +usr/lib/python-validity +usr/share/python-validity diff --git a/debian/pycompat b/debian/pycompat new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/debian/pycompat @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..541e53b --- /dev/null +++ b/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +#export DH_VERBOSE = 1 + +%: + dh $@ --with python3 --buildsystem=pybuild + +override_dh_auto_install: + python3 ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9d5dcb9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -cryptography>=2.1.4 -pyusb>=1.0.2 diff --git a/setup.py b/setup.py index 75e0874..8f0878d 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup -setup(name='python3-validity', +setup(name='python-validity', version='0.1', py_modules = [], packages=['validitysensor'], @@ -15,6 +15,7 @@ setup(name='python3-validity', 'pyusb >= 1.0.2' ], data_files=[ + ('share/python-validity/playground/', ['factory-reset.py', 'pair.py', 'prototype.py']), ('lib/python-validity/', ['dbus_service/dbus-service']), ] ) diff --git a/validitysensor/sensor.py b/validitysensor/sensor.py index bff733b..354b4a7 100644 --- a/validitysensor/sensor.py +++ b/validitysensor/sensor.py @@ -15,9 +15,8 @@ from .hw_tables import dev_info_lookup from .blobs import reset_blob from . import timeslot as prg -calib_data_path='calib-data.bin' - -debug=False +# TODO: this should be specific to an individual device (system may have more than one sensor) +calib_data_path='/usr/share/python-validity/calib-data.bin' line_update_type1_devices = [ 0xB5, 0x885, 0xB3, 0x143B, 0x1055, 0xE1, 0x8B1, 0xEA, 0xE4, 0xED, 0x1825, 0x1FF5, 0x199 ] @@ -67,12 +66,7 @@ def factory_reset(): class RomInfo(): def get(): - if not debug: - rsp=tls.cmd(b'\x01') - else: - # 0097 - rsp=unhexlify('0000f0b05e54a40000000607013000010000090a089141a80023000000000100000000000007'); - + rsp=tls.cmd(b'\x01') assert_status(rsp) rsp=rsp[2:] return RomInfo(*unpack('