1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
5 ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
8 ;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de>
9 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages libusb)
28 #:use-module (gnu packages)
29 #:use-module (guix licenses)
30 #:use-module (guix packages)
31 #:use-module (guix utils)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix build-system ant)
35 #:use-module (guix build-system cmake)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system glib-or-gtk)
38 #:use-module (guix build-system python)
39 #:use-module (gnu packages autotools)
40 #:use-module (gnu packages gnupg)
41 #:use-module (gnu packages gtk)
42 #:use-module (gnu packages java)
43 #:use-module (gnu packages linux)
44 #:use-module (gnu packages mp3)
45 #:use-module (gnu packages pkg-config)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages xiph))
56 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
57 "libusb-" version "/libusb-" version ".tar.bz2"))
60 "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm"))))
61 (build-system gnu-build-system)
63 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
65 (arguments `(#:configure-flags '("--disable-udev")))
66 ;; (inputs `(("eudev" ,eudev)))
68 (home-page "https://libusb.info")
69 (synopsis "User-space USB library")
71 "Libusb is a library that gives applications easy access to USB
72 devices on various operating systems.")
75 (define-public libusb-compat
77 (name "libusb-compat")
82 (uri (string-append "mirror://sourceforge/libusb/"
83 name "-" (version-major+minor version) "/"
85 name "-" version ".tar.bz2"))
88 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
89 (build-system gnu-build-system)
91 `(("pkg-config" ,pkg-config)))
93 `(("libusb" ,libusb)))
94 (home-page "https://libusb.info")
95 (synopsis "Compatibility shim for libusb")
97 "Libusb-compat provides a shim allowing applications based on older
98 version of libusb to run with newer libusb.")
101 ;; required by 0xffff, which compiles with libusb-compat, but executes only
103 (define-public libusb-0.1
104 (package (inherit libusb)
109 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
110 version "/libusb-" version ".tar.gz"))
113 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
114 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
116 (define-public libusb4java
117 ;; There is no public release so we take the latest version from git.
118 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
122 (version (string-append "0-" revision "." (string-take commit 9)))
126 (url "https://github.com/usb4java/libusb4java.git")
128 (file-name (git-file-name name version))
131 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
132 (build-system cmake-build-system)
134 `(#:tests? #f ; there are no tests
136 (modify-phases %standard-phases
137 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
138 ;; fails because libusb4java uses a deprecated procedure.
139 (add-after 'unpack 'disable-Werror
141 (substitute* "CMakeLists.txt"
144 (add-before 'configure 'set-JAVA_HOME
145 (lambda* (#:key inputs #:allow-other-keys)
146 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
149 `(("libusb" ,libusb)))
151 `(("jdk" ,icedtea "jdk")))
152 (home-page "https://github.com/usb4java/libusb4java/")
153 (synopsis "JNI bindings to libusb")
155 "This package provides Java JNI bindings to the libusb library for use
159 (define-public java-usb4java
161 (name "java-usb4java")
165 (uri (string-append "https://github.com/usb4java/usb4java/"
166 "archive/usb4java-" version ".tar.gz"))
169 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
170 (build-system ant-build-system)
172 `(#:jar-name "usb4java.jar"
174 (modify-phases %standard-phases
175 ;; Usually, native libusb4java libraries for all supported systems
176 ;; would be included in the jar and extracted at runtime. Since we
177 ;; build everything from source we cannot just bundle pre-built
178 ;; binaries for other systems. Instead, we patch the loader to
179 ;; directly return the appropriate library for this system. The
180 ;; downside is that the jar will only work on the same architecture
181 ;; that it was built on.
182 (add-after 'unpack 'copy-libusb4java
183 (lambda* (#:key inputs #:allow-other-keys)
184 (substitute* "src/main/java/org/usb4java/Loader.java"
185 (("private static String extractLibrary" line)
187 line "(final String a, final String b) {"
189 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
191 "private static String _extractLibrary")))
193 (add-after 'unpack 'disable-broken-tests
195 (with-directory-excursion "src/test/java/org/usb4java"
196 ;; These tests should only be run when USB devices are present.
197 (substitute* '("LibUsbGlobalTest.java"
199 (("this.context = new Context\\(\\);")
200 "this.context = null;")
201 (("LibUsb.init") "//"))
202 (substitute* "DeviceListIteratorTest.java"
203 (("this.iterator.remove" line)
204 (string-append "assumeUsbTestsEnabled();" line))))
207 `(("libusb4java" ,libusb4java)
208 ("java-commons-lang3" ,java-commons-lang3)
209 ("java-junit" ,java-junit)
210 ("java-hamcrest-core" ,java-hamcrest-core)))
211 (home-page "http://usb4java.org/")
212 (synopsis "USB library for Java")
214 "This package provides a USB library for Java based on libusb and
215 implementing @code{javax.usb} (JSR-80).")
218 (define-public python-libusb1
220 (name "python-libusb1")
225 (uri (pypi-uri "libusb1" version))
228 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
229 (build-system python-build-system)
231 `(#:modules ((srfi srfi-1)
233 (guix build python-build-system))
235 (modify-phases %standard-phases
236 (add-before 'install-license-files 'remove-incorrect-license
237 (lambda* (#:key out #:allow-other-keys)
238 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
239 ;; in source. Remove it so it does not get installed.
240 (delete-file "COPYING")
242 (add-after 'unpack 'fix-libusb-reference
243 (lambda* (#:key inputs #:allow-other-keys)
244 (substitute* "usb1/libusb1.py"
245 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
248 (find (negate symbolic-link?)
249 (find-files (assoc-ref inputs "libusb")
250 "^libusb.*\\.so\\..*"))
253 (inputs `(("libusb" ,libusb)))
254 (home-page "https://github.com/vpelletier/python-libusb1")
255 (synopsis "Pure-python wrapper for libusb-1.0")
256 (description "Libusb is a library that gives applications easy access to
257 USB devices on various operating systems. This package provides a Python
258 wrapper for accessing libusb-1.0.")
261 (define-public python-pyusb
263 (name "python-pyusb")
268 (uri (pypi-uri "pyusb" version))
271 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
272 (build-system python-build-system)
274 `(#:tests? #f ; no tests
275 #:modules ((srfi srfi-1)
278 (guix build python-build-system))
280 (modify-phases %standard-phases
281 (add-after 'unpack 'fix-libusb-reference
282 (lambda* (#:key inputs #:allow-other-keys)
283 (substitute* "usb/libloader.py"
284 (("lib = locate_library\\(candidates, find_library\\)")
287 (find (negate symbolic-link?)
288 (find-files (assoc-ref inputs "libusb")
289 "^libusb-.*\\.so\\..*"))
293 `(("libusb" ,libusb)))
294 (home-page "https://pyusb.github.io/pyusb/")
295 (synopsis "Python bindings to the libusb library")
297 "PyUSB aims to be an easy to use Python module to access USB devices.")
300 (define-public python2-pyusb
301 (package-with-python2 python-pyusb))
303 (define-public libmtp
309 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
310 "/libmtp-" version ".tar.gz"))
313 "185vh9bds6dcy00ycggg69g4v7m3api40zv8vrcfb3fk3vfzjs2v"))))
314 (build-system gnu-build-system)
316 `(("pkg-config" ,pkg-config)))
318 ;; libmtp.pc refers to all these.
319 `(("libgcrypt" ,libgcrypt)
323 (list (string-append "--with-udev="
324 (assoc-ref %outputs "out")
326 (home-page "http://libmtp.sourceforge.net/")
327 (synopsis "Library implementing the Media Transfer Protocol")
328 (description "Libmtp implements an MTP (Media Transfer Protocol)
329 initiator, which means that it initiates MTP sessions with devices. The
330 devices responding are known as MTP responders. Libmtp runs on devices
331 with a USB host controller interface. It implements MTP Basic, which was
332 proposed for standardization.")
333 ;; COPYING contains lgpl2.1, while files headers give
334 ;; "GNU Lesser General Public License as published by the Free Software
335 ;; Foundation; either version 2 of the License, or (at your option) any
345 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
346 "/gmtp-" version ".tar.gz"))
349 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
350 (build-system glib-or-gtk-build-system)
353 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
355 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
356 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
357 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
361 ("libvorbis" ,libvorbis)
362 ("libid3tag" ,libid3tag)
365 `(("pkg-config" ,pkg-config)))
366 (home-page "http://gmtp.sourceforge.net/")
367 (synopsis "Simple graphical MTP client")
368 (description "gMTP is a simple graphical client for the Media Transfer Protocol
369 (MTP), which allows media files to be transferred to and from many portable
373 (define-public hidapi
376 (version "0.8.0-rc1")
379 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
383 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
384 (build-system gnu-build-system)
389 `(("autoconf" ,autoconf)
390 ("automake" ,automake)
392 ("pkg-config" ,pkg-config)))
393 (home-page "http://www.signal11.us/oss/hidapi/")
394 (synopsis "HID API library")
396 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
398 ;; HIDAPI can be used under one of three licenses.
401 (non-copyleft "file://LICENSE-orig.txt")))))
403 (define-public python-hidapi
405 (name "python-hidapi")
406 (version "0.7.99.post21")
410 (uri (pypi-uri "hidapi" version))
413 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
414 (modules '((guix build utils)))
416 ;; Remove bundled libraries.
418 (delete-file-recursively "hidapi")
420 (build-system python-build-system)
423 (modify-phases %standard-phases
424 (add-after 'unpack 'patch-configuration
425 (lambda* (#:key inputs #:allow-other-keys)
426 (substitute* "setup.py"
427 (("'/usr/include/libusb-1.0'")
428 (string-append "'" (assoc-ref inputs "libusb")
429 "/include/libusb-1.0'"))
430 (("'/usr/include/hidapi'")
431 (string-append "'" (assoc-ref inputs "hidapi")
432 "/include/hidapi'")))
434 ;; XXX Necessary because python-build-system drops the arguments.
437 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
440 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
442 (lambda* (#:key outputs #:allow-other-keys)
443 (invoke "python" "setup.py" "install" "--with-system-hidapi"
444 (string-append "--prefix=" (assoc-ref outputs "out"))
445 "--single-version-externally-managed" "--root=/"))))))
451 `(("python-cython" ,python-cython)))
452 (home-page "https://github.com/trezor/cython-hidapi")
453 (synopsis "Cython interface to hidapi")
454 (description "This package provides a Cython interface to @code{hidapi}.")
455 ;; The library can be used under either of these licenses.
456 (license (list gpl3 bsd-3
458 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
459 "You are free to use cython-hidapi code for any purpose.")))))
461 (define-public python2-hidapi
462 (package-with-python2 python-hidapi))