| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | (define-module (gnu packages usb-modeswitch)
|
| 21 | #:use-module ((guix licenses) #:prefix license:)
|
| 22 | #:use-module (guix packages)
|
| 23 | #:use-module (guix download)
|
| 24 | #:use-module (guix build-system gnu)
|
| 25 | #:use-module (guix build-system trivial)
|
| 26 | #:use-module (guix utils)
|
| 27 | #:use-module (gnu packages)
|
| 28 | #:use-module (gnu packages base)
|
| 29 | #:use-module (gnu packages compression)
|
| 30 | #:use-module (gnu packages libusb)
|
| 31 | #:use-module (gnu packages pkg-config)
|
| 32 | #:use-module (gnu packages tcl))
|
| 33 |
|
| 34 | (define-public usb-modeswitch-data
|
| 35 | (package
|
| 36 | (name "usb-modeswitch-data")
|
| 37 | (version "20191128")
|
| 38 | (source (origin
|
| 39 | (method url-fetch)
|
| 40 | (uri (string-append
|
| 41 | "https://www.draisberghof.de/usb_modeswitch/"
|
| 42 | "usb-modeswitch-data-" version ".tar.bz2"))
|
| 43 | (sha256
|
| 44 | (base32
|
| 45 | "1ygahl3r26r38ai8yyblq9nhf3v5i6n6r6672p5wf88wg5h9n0rz"))))
|
| 46 | (build-system trivial-build-system)
|
| 47 | (native-inputs (list tar bzip2))
|
| 48 | (arguments
|
| 49 | `(#:modules ((guix build utils))
|
| 50 | #:builder
|
| 51 | (begin
|
| 52 | (use-modules (guix build utils))
|
| 53 | (let* ((source (assoc-ref %build-inputs "source"))
|
| 54 | (tar (assoc-ref %build-inputs "tar"))
|
| 55 | (bzip2 (assoc-ref %build-inputs "bzip2"))
|
| 56 | (files (string-append "usb-modeswitch-data-"
|
| 57 | ,(package-version this-package)))
|
| 58 | (share-dir (string-append %output "/share"))
|
| 59 | (doc-dir (string-append share-dir "/doc/"))
|
| 60 | (license-dir (string-append doc-dir
|
| 61 | (strip-store-file-name %output)))
|
| 62 | (udev-dir (string-append %output "/udev")))
|
| 63 | (copy-file source "data.tar.bz2")
|
| 64 | (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2")
|
| 65 | (invoke (string-append tar "/bin/tar") "xvf" "data.tar")
|
| 66 | (copy-recursively (string-append files "/usb_modeswitch.d")
|
| 67 | (string-append share-dir "/usb_modeswitch.d"))
|
| 68 | (install-file (string-append files "/40-usb_modeswitch.rules")
|
| 69 | udev-dir)
|
| 70 | (install-file (string-append files "/COPYING") license-dir)))))
|
| 71 | (home-page "https://www.draisberghof.de/usb_modeswitch/")
|
| 72 | (synopsis "Data package for USB_ModeSwitch")
|
| 73 | (description "This package contains data about devices and a UDEV rules
|
| 74 | file for use with USB_ModeSwitch.")
|
| 75 | (license license:gpl2+)))
|
| 76 |
|
| 77 | (define-public usb-modeswitch
|
| 78 | (package
|
| 79 | (name "usb-modeswitch")
|
| 80 | (version "2.6.1")
|
| 81 | (source (origin
|
| 82 | (method url-fetch)
|
| 83 | (uri (string-append
|
| 84 | "https://www.draisberghof.de/usb_modeswitch/"
|
| 85 | "usb-modeswitch-" version ".tar.bz2"))
|
| 86 | (sha256
|
| 87 | (base32
|
| 88 | "0d7s8p92r36danjd15y1zaznf6rbk17kxyg9367nabz56vhxk5ai"))))
|
| 89 | (native-inputs (list pkg-config))
|
| 90 | (inputs (list libusb jimtcl usb-modeswitch-data))
|
| 91 | (outputs '("out" "dispatcher"))
|
| 92 | (build-system gnu-build-system)
|
| 93 | (arguments
|
| 94 | `(#:tests? #f |
| 95 | #:make-flags
|
| 96 | (list ,(string-append "CC=" (cc-for-target)))
|
| 97 | #:phases
|
| 98 | (modify-phases %standard-phases
|
| 99 | (delete 'configure) |
| 100 | (replace 'install
|
| 101 | (lambda* (#:key source outputs inputs #:allow-other-keys)
|
| 102 | (let* ((source (assoc-ref inputs "source"))
|
| 103 | (jimtcl (assoc-ref inputs "jimtcl"))
|
| 104 | (data (assoc-ref inputs "usb-modeswitch-data"))
|
| 105 | (out (assoc-ref outputs "out"))
|
| 106 | (bin (string-append out "/bin"))
|
| 107 | (man1 (string-append out "/share/man/man1"))
|
| 108 | (dispatcher-out (assoc-ref outputs "dispatcher"))
|
| 109 | (udev (string-append dispatcher-out "/lib/udev"))
|
| 110 | (etc (string-append dispatcher-out "/etc"))
|
| 111 | (dispatcher-bin (string-append dispatcher-out "/bin"))
|
| 112 | (dispatcher-man1 (string-append dispatcher-out
|
| 113 | "/share/man/man1")))
|
| 114 | (begin
|
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | (install-file "usb_modeswitch" bin)
|
| 130 | (install-file "usb_modeswitch.conf" etc)
|
| 131 | (install-file "usb_modeswitch.1" man1)
|
| 132 | (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1)
|
| 133 |
|
| 134 | (substitute* "usb_modeswitch.sh"
|
| 135 | (("PATH=") "PATH=$PATH:") |
| 136 | (("init_path=") "init_path=/does/not/exist")) |
| 137 | (rename-file "usb_modeswitch.sh" "usb_modeswitch")
|
| 138 | (install-file "usb_modeswitch" udev)
|
| 139 |
|
| 140 | (rename-file "usb_modeswitch_dispatcher.tcl" "usb_modeswitch_dispatcher")
|
| 141 | (substitute* "usb_modeswitch_dispatcher"
|
| 142 | (("/usr/bin/tclsh")
|
| 143 | (string-append jimtcl "/bin/jimsh"))
|
| 144 | (("/usr/sbin") bin)
|
| 145 | (("/usr/share/usb_modeswitch")
|
| 146 | (string-append data "/share/usb_modeswitch.d")))
|
| 147 | (install-file "usb_modeswitch_dispatcher"
|
| 148 | dispatcher-bin)
|
| 149 | #t)))))))
|
| 150 | (home-page "https://www.draisberghof.de/usb_modeswitch/")
|
| 151 | (synopsis "Mode switching tool for controlling `multi-mode' USB devices")
|
| 152 | (description "USB_ModeSwitch is a mode switching tool for controlling USB
|
| 153 | devices with multiple @dfn{modes}. When plugged in for the first time many
|
| 154 | USB devices (primarily high-speed WAN modems) act like a flash storage
|
| 155 | containing installers for Windows drivers. USB_ModeSwitch replays the
|
| 156 | sequence the Windows drivers would send to switch their mode from storage to
|
| 157 | modem (or whatever the thing is supposed to do).")
|
| 158 | (license (list license:gpl2+ |
| 159 | license:bsd-2)))) |