aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Vitale <nivit@FreeBSD.org>2024-02-11 17:29:41 +0000
committerNicola Vitale <nivit@FreeBSD.org>2024-02-11 17:29:41 +0000
commitb6998fd13cf6354a837506d53c87e58fd9307417 (patch)
tree32fa93a733ff67b73f2f7b76ac33d56c8f7b299c
parent0cb8cd0d1c3f18d0525bba413e56322fca6176d4 (diff)
downloadports-b6998fd13cf6354a837506d53c87e58fd9307417.tar.gz
ports-b6998fd13cf6354a837506d53c87e58fd9307417.zip
sysutils/py-blinkstick: Add new port
Python interface to control Blinkstick devices connected to computer. https://pypi.org/project/BlinkStick/
-rw-r--r--sysutils/Makefile1
-rw-r--r--sysutils/py-blinkstick/Makefile29
-rw-r--r--sysutils/py-blinkstick/distinfo3
-rw-r--r--sysutils/py-blinkstick/files/blinkstick-devices.conf13
-rw-r--r--sysutils/py-blinkstick/files/patch-blinkstick_blinkstick.py17
-rw-r--r--sysutils/py-blinkstick/pkg-descr1
-rw-r--r--sysutils/py-blinkstick/pkg-message15
7 files changed, 79 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile
index 89209c34ea66..44bdc5cb6982 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -1092,6 +1092,7 @@
SUBDIR += py-azure-cli-core
SUBDIR += py-azure-cli-telemetry
SUBDIR += py-bitrot
+ SUBDIR += py-blinkstick
SUBDIR += py-borgmatic
SUBDIR += py-concurrent-log-handler
SUBDIR += py-cron-descriptor
diff --git a/sysutils/py-blinkstick/Makefile b/sysutils/py-blinkstick/Makefile
new file mode 100644
index 000000000000..3f82eddc3dc0
--- /dev/null
+++ b/sysutils/py-blinkstick/Makefile
@@ -0,0 +1,29 @@
+PORTNAME= blinkstick
+DISTVERSION= g20230504
+CATEGORIES= sysutils python
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+DISTNAME= BlinkStick-${PORTVERSION}
+
+MAINTAINER= nivit@FreeBSD.org
+COMMENT= Python package to control BlinkStick USB devices
+WWW= https://pypi.org/project/BlinkStick/
+
+LICENSE= BSD3CLAUSE
+LICENSE_FILE= ${WRKSRC}/LICENSE.txt
+
+RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pyusb>=1.2.1:devel/py-pyusb@${PY_FLAVOR}
+
+USES= python
+
+USE_GITHUB= yes
+GH_ACCOUNT= arvydas
+GH_PROJECT= ${PORTNAME}-python
+GH_TAGNAME= 8140b9fa
+USE_PYTHON= autoplist distutils
+
+PLIST_FILES= etc/devd/blinkstick-devices.conf
+
+post-install:
+ ${INSTALL_DATA} ${FILESDIR}/blinkstick-devices.conf ${STAGEDIR}${PREFIX}/etc/devd/
+
+.include <bsd.port.mk>
diff --git a/sysutils/py-blinkstick/distinfo b/sysutils/py-blinkstick/distinfo
new file mode 100644
index 000000000000..2e5ea8373c4a
--- /dev/null
+++ b/sysutils/py-blinkstick/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1707667097
+SHA256 (arvydas-blinkstick-python-g20230504-8140b9fa_GH0.tar.gz) = 56b09bc6fcde82c9cabb7bfe47fa830e43049c8027df1241d56a81a3779ff24d
+SIZE (arvydas-blinkstick-python-g20230504-8140b9fa_GH0.tar.gz) = 18708
diff --git a/sysutils/py-blinkstick/files/blinkstick-devices.conf b/sysutils/py-blinkstick/files/blinkstick-devices.conf
new file mode 100644
index 000000000000..5bce2267dc61
--- /dev/null
+++ b/sysutils/py-blinkstick/files/blinkstick-devices.conf
@@ -0,0 +1,13 @@
+# devd configuration for Blinkstick devices
+#
+# users must be added to the operator group
+
+notify 8352 {
+ match "system" "USB";
+ match "subsystem" "DEVICE";
+ match "type" "ATTACH";
+ match "vendor" "0x20a0";
+ match "product" "0x41e5";
+ action "chgrp operator /dev/$cdev; chmod 660 /dev/$cdev";
+};
+
diff --git a/sysutils/py-blinkstick/files/patch-blinkstick_blinkstick.py b/sysutils/py-blinkstick/files/patch-blinkstick_blinkstick.py
new file mode 100644
index 000000000000..8b946c7cf6f6
--- /dev/null
+++ b/sysutils/py-blinkstick/files/patch-blinkstick_blinkstick.py
@@ -0,0 +1,17 @@
+--- blinkstick/blinkstick.py.orig 2023-05-04 08:45:38 UTC
++++ blinkstick/blinkstick.py
+@@ -1,4 +1,5 @@ from ._version import __version__
+ from ._version import __version__
++import os
+ import time
+ import sys
+ import re
+@@ -820,7 +821,7 @@ class BlinkStick(object):
+ if self.device is None:
+ raise BlinkStickException("Could not find BlinkStick...")
+
+- if self.device.is_kernel_driver_active(0):
++ if os.geteuid() == 0 and self.device.is_kernel_driver_active(0):
+ try:
+ self.device.detach_kernel_driver(0)
+ except usb.core.USBError as e:
diff --git a/sysutils/py-blinkstick/pkg-descr b/sysutils/py-blinkstick/pkg-descr
new file mode 100644
index 000000000000..94cd2589d45a
--- /dev/null
+++ b/sysutils/py-blinkstick/pkg-descr
@@ -0,0 +1 @@
+Python interface to control Blinkstick devices connected to computer.
diff --git a/sysutils/py-blinkstick/pkg-message b/sysutils/py-blinkstick/pkg-message
new file mode 100644
index 000000000000..556d44de91c6
--- /dev/null
+++ b/sysutils/py-blinkstick/pkg-message
@@ -0,0 +1,15 @@
+[
+{ type: install
+ message: <<EOM
+Blinkstick has been installed. You have to restart devd(8) with the command:
+
+# service devd restart
+
+Blinkstick also requires read/write access to devices, so the users
+must belong to the operator group. You can add them with the command:
+
+# pw group mod operator -m <user>
+
+EOM
+}
+]