unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 35640@debbugs.gnu.org
Subject: bug#35640: Make USB modems just work on Guix
Date: Tue, 14 May 2019 22:56:48 +0200	[thread overview]
Message-ID: <20190514205648.nl4s4lwvc4t67gho@pelzflorian.localdomain> (raw)
In-Reply-To: <20190514103555.1b2a6316@scratchpost.org>

[-- Attachment #1: Type: text/plain, Size: 1924 bytes --]

On Tue, May 14, 2019 at 10:35:55AM +0200, Danny Milosavljevic wrote:
> Should be
> 
>    (inputs `(("libusb" ,libusb)
>              ("tcl" ,tcl:tcl)))
> 

Yes I did mean that with comma, sorry.

> But I guess you meant that anyway.
> 
> The problem is there's a use-modules cycle somewhere.
> Try putting usb-modeswitch in another module (a new one if necessary).
>

Using a new module helps, thank you!  Now I also do not need a prefix
tcl: anymore.  @Ludo: without that prefix, I got errors because 'zip
was redefined or something, I do not remember now.

Now only packaging issues remain.  When I use trivial-build-system,

       #:builder
       (begin
         (use-modules (guix build utils)
                      (guix packages))
         (let ((source (assoc-ref %build-inputs "source"))
               (tar (assoc-ref %build-inputs "tar"))
               (bzip2 (assoc-ref %build-inputs "bzip2"))
               (share-dir (string-append %output "/share")))
           (copy-file source "data.tar.bz2")
           (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2")
           (invoke (string-append tar "/bin/tar") "xvf" "data.tar")
           (install-file (string-append "usb-modeswitch-data-"
                                        (package-version this-package)
                                        "/usb_modeswitch.d") share-dir))
         #t)))

this package-version call seems not to work (at least not without more
adding more modules).  Is this the right approach?  Also I forgot, do
I need this #t at the end?


> Also, does it really require tcl?  Sounds kinda weird to me.

TCL is not needed for command-line mode switching, but there is a TCL
script called usb_modeswitch_dispatcher that gets called by the UDEV
rule and by the systemd service file shipped with USB_ModeSwitch.
This dispatcher automatically modeswitches USB devices that are
plugged in, I believe.

Regards,
Florian

[-- Attachment #2: 0001-Add-USB_ModeSwitch.patch --]
[-- Type: text/plain, Size: 6265 bytes --]

From 3430070606904b6dc6b247a6b8bfb2ce7c4fce0f Mon Sep 17 00:00:00 2001
From: Florian Pelz <pelzflorian@pelzflorian.de>
Date: Tue, 14 May 2019 12:36:24 +0200
Subject: [PATCH] Add USB_ModeSwitch.

* gnu/packages/usb-modeswitch.scm (usb-modeswitch-data) Add it.
(usb-modeswitch) Add it.
---
 gnu/packages/usb-modeswitch.scm | 122 ++++++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 gnu/packages/usb-modeswitch.scm

diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm
new file mode 100644
index 0000000000..f3708c44ab
--- /dev/null
+++ b/gnu/packages/usb-modeswitch.scm
@@ -0,0 +1,122 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix 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 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages libusb)
+;;  #:use-module (gnu packages)
+  #:use-module ((guix licenses) #:prefix license:)
+  ;;  #:use-module (guix packages)
+  #:use-module (guix build-system trivial)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages libusb)
+  #:use-module (gnu packages tcl))
+
+(define-public usb-modeswitch-data
+  (package
+    (name "usb-modeswitch-data")
+    (version "20170806")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "http://www.draisberghof.de/usb_modeswitch/"
+                    "usb-modeswitch-data-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils)
+                  (guix packages))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (guix packages))
+         (let ((source (assoc-ref %build-inputs "source"))
+               (tar (assoc-ref %build-inputs "tar"))
+               (bzip2 (assoc-ref %build-inputs "bzip2"))
+               (share-dir (string-append %output "/share")))
+           (copy-file source "data.tar.bz2")
+           (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2")
+           (invoke (string-append tar "/bin/tar") "xvf" "data.tar")
+           (install-file (string-append "usb-modeswitch-data-"
+                                        (package-version this-package)
+                                        "/usb_modeswitch.d") share-dir))
+         #t)))
+    (native-inputs `(("tar" ,tar)
+                     ("bzip2" ,bzip2)))
+    (home-page "http://www.draisberghof.de/usb_modeswitch/")
+    (synopsis "Data package for USB_ModeSwitch")
+    (description "Device data collection and UDEV rules file for
+USB_ModeSwitch.")
+    (license license:gpl2+)))
+
+(define-public usb-modeswitch
+  (package
+    (name "usb-modeswitch")
+    (version "2.5.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "http://www.draisberghof.de/usb_modeswitch/"
+                    "usb-modeswitch-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb"))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (inputs `(("libusb" ,libusb)
+              ("tcl" ,tcl)))
+    (propagated-inputs `(("usb-modeswitch-data" ,usb-modeswitch-data)))
+    (outputs '("out" "dispatcher"))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                    ; does not support `make check`
+       #:make-flags (list "CC=gcc")
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)          ; no configure script
+         (replace 'install
+           (lambda _                  ; calling make would use usr as PREFIX
+             (let* ((source (assoc-ref %build-inputs "source"))
+                    (out (assoc-ref %outputs "out"))
+                    (bin (string-append out "/bin"))
+                    (man1 (string-append out "/share/man/man1"))
+                    (dispatcher-out (assoc-ref %outputs "dispatcher"))
+                    (etc (string-append dispatcher-out "/etc"))
+                    (dispatcher-bin (string-append dispatcher-out "/bin")))
+               (begin
+;;                 (use-modules (guix build utils))
+                 (install-file "usb_modeswitch" bin)
+                 (install-file "usb_modeswitch.1" man1)
+                 (install-file "usb_modeswitch.conf" etc)
+                 (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher")
+                 (substitute* "usb_modeswitch_dispatcher"
+                   (("!/usr/bin/tclsh")
+                     (string-append (assoc-ref %build-inputs "tcl")
+                                    "/bin/tclsh")))
+                 (install-file "usb_modeswitch_dispatcher"
+                               dispatcher-bin))))))))
+    (home-page "http://www.draisberghof.de/usb_modeswitch/")
+    (synopsis "Mode switching tool for controlling 'multi-mode' USB devices")
+    (description "USB_ModeSwitch is a mode switching tool for controlling USB
+devices with multiple \"modes\".  When plugged in for the first time many USB
+devices (primarily high-speed WAN modems) act like a flash storage containing
+installers for Windows drivers.  USB_ModeSwitch replays the sequence the
+Windows drivers would send to switch their mode from storage to modem (or
+whatever the thing is supposed to do).")
+    (license license:gpl2+)))
-- 
2.21.0


  reply	other threads:[~2019-05-14 20:58 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 18:26 bug#35640: Make USB modems just work on Guix pelzflorian (Florian Pelz)
2019-05-09  5:31 ` pelzflorian (Florian Pelz)
2019-05-09 12:55   ` Danny Milosavljevic
2019-05-09 13:07     ` pelzflorian (Florian Pelz)
2019-05-09 13:43       ` pelzflorian (Florian Pelz)
2019-05-09 15:24 ` Ludovic Courtès
2019-05-13 20:57   ` pelzflorian (Florian Pelz)
2019-05-13 21:04     ` pelzflorian (Florian Pelz)
2019-05-14  7:22       ` pelzflorian (Florian Pelz)
2019-05-14  8:35       ` Danny Milosavljevic
2019-05-14 20:56         ` pelzflorian (Florian Pelz) [this message]
2019-05-15 13:01           ` Ludovic Courtès
2019-05-15 14:40             ` pelzflorian (Florian Pelz)
2019-05-22 16:29             ` pelzflorian (Florian Pelz)
2019-05-22 17:58               ` pelzflorian (Florian Pelz)
2019-05-24 15:37               ` Ludovic Courtès
2019-05-24 20:12                 ` pelzflorian (Florian Pelz)
2019-05-25 11:18                   ` pelzflorian (Florian Pelz)
2019-05-25 12:43                     ` pelzflorian (Florian Pelz)
2019-05-25 17:44                     ` Ludovic Courtès
2019-05-25 19:42                       ` pelzflorian (Florian Pelz)
2019-06-12 10:36                         ` pelzflorian (Florian Pelz)
2019-06-12 10:41                           ` pelzflorian (Florian Pelz)
2019-06-12 21:00                             ` Ludovic Courtès
2019-06-12 21:11                           ` Ludovic Courtès
2019-06-13 18:04                             ` pelzflorian (Florian Pelz)
2019-06-13 18:05                               ` pelzflorian (Florian Pelz)
2019-06-15 16:39                                 ` Ludovic Courtès
2019-06-12 12:13                       ` pelzflorian (Florian Pelz)
2019-06-12 12:21                         ` Ludovic Courtès
2019-06-12 19:51                           ` pelzflorian (Florian Pelz)
2019-06-12 20:42                             ` Ludovic Courtès
2019-06-12 20:58                         ` Ludovic Courtès
2019-05-14 20:48     ` Ludovic Courtès
2019-05-15 11:17     ` pelzflorian (Florian Pelz)
2019-05-15 12:51       ` Ludovic Courtès
2019-05-16  7:50   ` pelzflorian (Florian Pelz)
2019-05-16  8:34     ` pelzflorian (Florian Pelz)
2019-05-16 11:30     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190514205648.nl4s4lwvc4t67gho@pelzflorian.localdomain \
    --to=pelzflorian@pelzflorian.de \
    --cc=35640@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).