Subject: [bug#72635] [PATCH] gnu: Add python-usbrelay.

From: Evgeny Pisemsky <[email-masked]>
Date: Thu, 15 Aug 2024 10:15:38 +0300

>From 7848f0db92bee6fa523661d4599a294df1668b0c Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Evgeny Pisemsky <[email-masked]>
Date: Thu, 15 Aug 2024 10:00:00 +0300
Subject: [PATCH] gnu: Add python-usbrelay.

* gnu/packages/hardware.scm (python-usbrelay): New variable.

Change-Id: Icc389604a9bbc8f91fd7b00c1f5cebe3faac3e09
---
 gnu/packages/hardware.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index d8530f8705..5c82f02255 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -70,6 +70,7 @@ (define-module (gnu packages hardware)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages lxqt)
+  #:use-module (gnu packages messaging)
   #:use-module (gnu packages mtools)
   #:use-module (gnu packages package-management)
   #:use-module (gnu packages ncurses)
@@ -1622,3 +1623,32 @@ (define-public usbrelay
 HID compatible USB relay modules available with different number of
 output relays.")
     (license license:gpl2+)))
+
+(define-public python-usbrelay
+  (package
+    (inherit usbrelay)
+    (name "python-usbrelay")
+    (build-system python-build-system)
+    (inputs (list usbrelay))
+    (propagated-inputs (list python-paho-mqtt))
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'install-daemon
+                     (lambda _
+                       (install-file "usbrelayd.8"
+                                     (string-append #$output "/share/man/man8"))
+                       (install-file "usbrelayd"
+                                     (string-append #$output "/sbin"))
+                       (chmod (string-append #$output "/sbin/usbrelayd") #o555)))
+                   (add-after 'install-daemon 'chdir-and-set-version
+                     (lambda _
+                       (chdir "usbrelay_py")
+                       (substitute* "setup.py"
+                         (("    version = .*")
+                          (string-append "    version = '"
+                                         #$(package-version usbrelay) "',\n")))
+                       (substitute* "src/__init__.py"
+                         (("__version__ = .*")
+                          (string-append "__version__ = \""
+                                         #$(package-version usbrelay) "\"\n"))))))))))

base-commit: 936928fe38946a7496273e636ca8888914d100a9
-- 
2.45.2