aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/usb-modeswitch.scm
blob: 2092e4cdaffd7d8807ba97ec48530fa4d4b6af60 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; 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 usb-modeswitch)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system trivial)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages embedded)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages pkg-config))

(define-public usb-modeswitch-data
  (package
    (name "usb-modeswitch-data")
    (version "20191128")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://www.draisberghof.de/usb_modeswitch/"
                    "usb-modeswitch-data-" version ".tar.bz2"))
              (sha256
               (base32
                "1ygahl3r26r38ai8yyblq9nhf3v5i6n6r6672p5wf88wg5h9n0rz"))))
    (build-system trivial-build-system)
    (native-inputs (list tar bzip2))
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (let* ((source (assoc-ref %build-inputs "source"))
                (tar (assoc-ref %build-inputs "tar"))
                (bzip2 (assoc-ref %build-inputs "bzip2"))
                (files (string-append "usb-modeswitch-data-"
                                      ,(package-version this-package)))
                (share-dir (string-append %output "/share"))
                (doc-dir (string-append share-dir "/doc/"))
                (license-dir (string-append doc-dir
                                            (strip-store-file-name %output)))
                (udev-dir (string-append %output "/udev")))
           (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")
           (copy-recursively (string-append files "/usb_modeswitch.d")
                             (string-append share-dir "/usb_modeswitch.d"))
           (install-file (string-append files "/40-usb_modeswitch.rules")
                         udev-dir)
           (install-file (string-append files "/COPYING") license-dir)))))
    (home-page "https://www.draisberghof.de/usb_modeswitch/")
    (synopsis "Data package for USB_ModeSwitch")
    (description "This package contains data about devices and a UDEV rules
file for use with USB_ModeSwitch.")
    (license license:gpl2+)))

(define-public usb-modeswitch
  (package
    (name "usb-modeswitch")
    (version "2.6.1")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://www.draisberghof.de/usb_modeswitch/"
                    "usb-modeswitch-" version ".tar.bz2"))
              (sha256
               (base32
                "0d7s8p92r36danjd15y1zaznf6rbk17kxyg9367nabz56vhxk5ai"))))
    (native-inputs (list pkg-config))
    (inputs (list libusb jimtcl usb-modeswitch-data))
    (outputs '("out" "dispatcher"))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f                    ; does not support `make check`
       #:make-flags
       (list ,(string-append "CC=" (cc-for-target)))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)          ; no configure script
         (replace 'install
           (lambda* (#:key source outputs inputs #:allow-other-keys)
             (let* ((source (assoc-ref inputs "source"))
                    (jimtcl (assoc-ref inputs "jimtcl"))
                    (data (assoc-ref inputs "usb-modeswitch-data"))
                    (out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin"))
                    (man1 (string-append out "/share/man/man1"))
                    (dispatcher-out (assoc-ref outputs "dispatcher"))
                    (udev (string-append dispatcher-out "/lib/udev"))
                    (etc (string-append dispatcher-out "/etc"))
                    (dispatcher-bin (string-append dispatcher-out "/bin"))
                    (dispatcher-man1 (string-append dispatcher-out
                                                    "/share/man/man1")))
               (begin
                 ;; Users can install the default output and
                 ;; usb-modeswitch-data and then modeswitch their USB device
                 ;; by running e.g.:
                 ;;
                 ;;   sudo usb_modeswitch -c \
                 ;;   ~/.guix-profile/share/usb_modeswitch.d/12d1\:14fe \
                 ;;   -v 0x12d1 -p 0x14fe
                 ;;
                 ;; But it is simpler to use the usb-modeswitch-service-type
                 ;; that installs a UDEV rules file which invokes a shell
                 ;; script in lib/udev (also called `usb_modeswitch' like the
                 ;; main binary) which, in turn, invokes the program
                 ;; `usb_modeswitch_dispatcher'.  Normal users should not
                 ;; invoke this dispatcher directly, so it is a separate output.
                 (install-file "usb_modeswitch" bin)
                 (install-file "usb_modeswitch.conf" etc)
                 (install-file "usb_modeswitch.1" man1)
                 (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1)

                 (substitute* "usb_modeswitch.sh"
                   (("PATH=") "PATH=$PATH:") ; we do not want hardcoded FHS path
                   (("init_path=") "init_path=/does/not/exist")) ; no /sbin/init
                 (rename-file "usb_modeswitch.sh" "usb_modeswitch")
                 (install-file "usb_modeswitch" udev)

                 (rename-file "usb_modeswitch_dispatcher.tcl" "usb_modeswitch_dispatcher")
                 (substitute* "usb_modeswitch_dispatcher"
                   (("/usr/bin/tclsh")
                    (string-append jimtcl "/bin/jimsh"))
                   (("/usr/sbin") bin)
                   (("/usr/share/usb_modeswitch")
                    (string-append data "/share/usb_modeswitch.d")))
                 (install-file "usb_modeswitch_dispatcher"
                               dispatcher-bin)
                 #t)))))))
    (home-page "https://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 @dfn{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 (list license:gpl2+ ;"this program" according to home page
                   license:bsd-2)))) ;dispatcher.c
nu/packages.scm (find-best-packages-by-name): Remove. (find-best-packages-by-name): Use 'find-packages-by-name' instead of 'find-newest-available-packages'. Ludovic Courtès 2018-12-20gnu: Use i686-linux bootstrap binaries on x86_64-linux....This saves 4.4 MB on the installed Guix. * gnu/packages/bootstrap/x86_64-linux: Remove directory. * gnu/local.mk (bootstrap_x86_64_linuxdir) (dist_bootstrap_x86_64_linux_DATA): Remove. * gnu/packages.scm (search-bootstrap-binary): When SYSTEM is "x86_64-linux", use "i686-linux" instead. Ludovic Courtès 2018-09-02Add (guix describe) and use it to initialize '%package-search-path'....* guix/describe.scm: New file. * Makefile.am (MODULES): Add it. * gnu/packages.scm (%default-package-module-path): New variable. (%package-module-path): Honor 'package-path-entries'. * build-aux/update-NEWS.scm (main): Use %DEFAULT-PACKAGE-MODULE-PATH instead of (last (%package-module-path)). Ludovic Courtès 2018-05-13packages: 'find-packages-by-name' properly honors version prefixes....Fixes <https://bugs.gnu.org/28446>. Reported by Mark H Weaver <mhw@netris.org>. * gnu/packages.scm (find-packages-by-name): Use 'version-prefix?' instead of 'string-prefix?'. Ludovic Courtès 2018-04-08discovery: Remove dependency on (guix ui)....This reduces the closure of (guix discovery) from 28 to 8 modules. * guix/discovery.scm (scheme-files): Use 'format' instead of 'warning'. (scheme-modules): Add #:warn parameter. Use it instead of 'warn-about-load-error'. (fold-modules): Add #:warn and pass it to 'scheme-modules'. (all-modules): Likewise. * gnu/bootloader.scm (bootloader-modules): Pass #:warn to 'all-modules'. * gnu/packages.scm (fold-packages): Likewise. * gnu/services.scm (all-service-modules): Likewise. * guix/upstream.scm (importer-modules): Likewise. Ludovic Courtès 2018-04-08Add (guix self)....* guix/self.scm: New file. * Makefile.am (MODULES): Add it. * gnu/packages.scm (%distro-root-directory): Rewrite to try different directories. * guix/discovery.scm (guix): Export 'scheme-files'. Ludovic Courtès 2017-11-07packages: 'fold-packages' takes #:select? parameter....* gnu/packages.scm (fold-packages): Add #:select? parameter and honor it. Ludovic Courtès 2017-09-01packages: 'fold-packages' takes an optional 'modules' parameter....Suggested by Christopher Baines <mail@cbaines.net>. * gnu/packages.scm (fold-packages): Add optional 'modules' parameter and honor it. Ludovic Courtès 2017-06-11packages: Add 'specifications->manifest'....* gnu/packages.scm (specifications->manifest): New procedure. * doc/guix.texi (Invoking guix package): Change example from using '(compose list specification->package+output)' to using 'specifications->manifest'. Ludovic Courtès 2017-05-03Add (guix discovery)....* guix/discovery.scm, tests/discovery.scm: New files. * gnu/packages.scm (scheme-files, file-name->module-name) (scheme-modules, all-package-modules): Remove. (fold-packages): Rewrite in terms of 'fold-module-public-variables'. * gnu/tests.scm: Use (guix discovery). * Makefile.am (MODULES): Add guix/discovery.scm. (SCM_TESTS): Add tests/discovery.scm. Ludovic Courtès 2017-05-03ui: Rename '_' to 'G_'....This avoids collisions with '_' when the latter is used as a 'match' pattern for instance. See <https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>. * guix/ui.scm: Rename '_' to 'G_'. * po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly. * build-aux/compile-all.scm (warnings): Remove 'format'. * gnu/packages.scm, gnu/services.scm, gnu/services/shepherd.scm, gnu/system.scm, gnu/system/shadow.scm, guix/gnupg.scm, guix/http-client.scm, guix/import/cpan.scm, guix/import/elpa.scm, guix/import/pypi.scm, guix/nar.scm, guix/scripts.scm, guix/scripts/archive.scm, guix/scripts/authenticate.scm, guix/scripts/build.scm, guix/scripts/challenge.scm, guix/scripts/container.scm, guix/scripts/container/exec.scm, guix/scripts/copy.scm, guix/scripts/download.scm, guix/scripts/edit.scm, guix/scripts/environment.scm, guix/scripts/gc.scm, guix/scripts/graph.scm, guix/scripts/hash.scm, guix/scripts/import.scm, guix/scripts/import/cpan.scm, guix/scripts/import/cran.scm, guix/scripts/import/crate.scm, guix/scripts/import/elpa.scm, guix/scripts/import/gem.scm, guix/scripts/import/gnu.scm, guix/scripts/import/hackage.scm, guix/scripts/import/nix.scm, guix/scripts/import/pypi.scm, guix/scripts/import/stackage.scm, guix/scripts/lint.scm, guix/scripts/offload.scm, guix/scripts/pack.scm, guix/scripts/package.scm, guix/scripts/perform-download.scm, guix/scripts/publish.scm, guix/scripts/pull.scm, guix/scripts/refresh.scm, guix/scripts/size.scm, guix/scripts/substitute.scm, guix/scripts/system.scm, guix/ssh.scm, guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`". Ludovic Courtès 2017-05-01packages: Remove support for PACKAGE-VERSION deprecated syntax....This syntax had been deprecated since 2016-02-28. * gnu/packages.scm (%find-package): Remove #:fallback? parameter and handling. * tests/guix-build.sh: Remove test for "time-1.7" syntax. * doc/guix.texi (Invoking guix lint): Update 'guix lint' output in example. Ludovic Courtès