>From 8861177166d74b84c0ac18bf102802cc1e6cf5d3 Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Mon, 13 May 2019 22:35:00 +0200 Subject: [PATCH] Add USB_ModeSwitch. * gnu/packages/libusb.scm (usb-modeswitch-data) Add it. (usb-modeswitch) Add it. --- gnu/packages/libusb.scm | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm index 5ef62e47fb..00577bb333 100644 --- a/gnu/packages/libusb.scm +++ b/gnu/packages/libusb.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2017 Jonathan Brielmaier ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2018 Vagrant Cascadian +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu packages libusb) + #:use-module (system repl debug) #:use-module (gnu packages) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) @@ -36,6 +38,7 @@ #:use-module (guix build-system gnu) #:use-module (guix build-system glib-or-gtk) #:use-module (guix build-system python) + #:use-module (guix build-system trivial) #:use-module (gnu packages autotools) #:use-module (gnu packages gnupg) #:use-module (gnu packages gtk) @@ -45,8 +48,12 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-xyz) + #:use-module ((gnu packages tcl) #:prefix tcl:) + #:use-module (system foreign) + #:use-module (rnrs bytevectors) #:use-module (gnu packages tls) #:use-module (gnu packages xiph)) +(terminal-width 1000000) (define-public libusb (package @@ -601,3 +608,87 @@ HID-Class devices.") (define-public python2-hidapi (package-with-python2 python-hidapi)) + +(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)) + #:builder + (begin + (let ((share-dir (string-append %output "/share"))) + (install-file + (string-append (assoc-ref %build-inputs "source") + "/usb_modeswitch.d") + share-dir)) + #t))) + (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" ,(error 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 + (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