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, 2018, 2019 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>
11 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu packages libusb)
29 #:use-module (gnu packages)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix build-system ant)
36 #:use-module (guix build-system cmake)
37 #:use-module (guix build-system gnu)
38 #:use-module (guix build-system glib-or-gtk)
39 #:use-module (guix build-system python)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages gnupg)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages java)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages mp3)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages xiph))
59 (uri (string-append "https://github.com/libusb/libusb/"
60 "releases/download/v" version
61 "/libusb-" version ".tar.bz2"))
63 (base32 "13dd2a9x290d1q8nb1lqiaf36grcvns5ripk5k2xm0lajmpc04fv"))))
64 (build-system gnu-build-system)
66 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
68 (arguments `(#:configure-flags '("--disable-udev")))
69 ;; (inputs `(("eudev" ,eudev)))
71 (home-page "https://libusb.info")
72 (synopsis "User-space USB library")
74 "Libusb is a library that gives applications easy access to USB
75 devices on various operating systems.")
76 (license license:lgpl2.1+)))
78 (define-public libusb-compat
80 (name "libusb-compat")
85 (uri (string-append "mirror://sourceforge/libusb/"
86 "libusb-compat-" (version-major+minor version) "/"
87 "libusb-compat-" version "/"
88 "libusb-compat-" version ".tar.bz2"))
91 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
92 (build-system gnu-build-system)
94 `(("pkg-config" ,pkg-config)))
96 `(("libusb" ,libusb)))
97 (home-page "https://libusb.info")
98 (synopsis "Compatibility shim for libusb")
100 "Libusb-compat provides a shim allowing applications based on older
101 version of libusb to run with newer libusb.")
102 (license license:lgpl2.1+)))
104 ;; required by 0xffff, which compiles with libusb-compat, but executes only
106 (define-public libusb-0.1
107 (package (inherit libusb)
112 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
113 version "/libusb-" version ".tar.gz"))
116 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
117 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
119 (define-public libusb4java
120 ;; There is no public release so we take the latest version from git.
121 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
125 (version (string-append "0-" revision "." (string-take commit 9)))
129 (url "https://github.com/usb4java/libusb4java.git")
131 (file-name (git-file-name name version))
134 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
135 (build-system cmake-build-system)
137 `(#:tests? #f ; there are no tests
139 (modify-phases %standard-phases
140 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
141 ;; fails because libusb4java uses a deprecated procedure.
142 (add-after 'unpack 'disable-Werror
144 (substitute* "CMakeLists.txt"
147 (add-before 'configure 'set-JAVA_HOME
148 (lambda* (#:key inputs #:allow-other-keys)
149 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
152 `(("libusb" ,libusb)))
154 `(("jdk" ,icedtea "jdk")))
155 (home-page "https://github.com/usb4java/libusb4java/")
156 (synopsis "JNI bindings to libusb")
158 "This package provides Java JNI bindings to the libusb library for use
160 (license license:expat))))
162 (define-public java-usb4java
164 (name "java-usb4java")
168 (uri (string-append "https://github.com/usb4java/usb4java/"
169 "archive/usb4java-" version ".tar.gz"))
172 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
173 (build-system ant-build-system)
175 `(#:jar-name "usb4java.jar"
177 (modify-phases %standard-phases
178 ;; Usually, native libusb4java libraries for all supported systems
179 ;; would be included in the jar and extracted at runtime. Since we
180 ;; build everything from source we cannot just bundle pre-built
181 ;; binaries for other systems. Instead, we patch the loader to
182 ;; directly return the appropriate library for this system. The
183 ;; downside is that the jar will only work on the same architecture
184 ;; that it was built on.
185 (add-after 'unpack 'copy-libusb4java
186 (lambda* (#:key inputs #:allow-other-keys)
187 (substitute* "src/main/java/org/usb4java/Loader.java"
188 (("private static String extractLibrary" line)
190 line "(final String a, final String b) {"
192 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
194 "private static String _extractLibrary")))
196 (add-after 'unpack 'disable-broken-tests
198 (with-directory-excursion "src/test/java/org/usb4java"
199 ;; These tests should only be run when USB devices are present.
200 (substitute* '("LibUsbGlobalTest.java"
202 (("this.context = new Context\\(\\);")
203 "this.context = null;")
204 (("LibUsb.init") "//"))
205 (substitute* "DeviceListIteratorTest.java"
206 (("this.iterator.remove" line)
207 (string-append "assumeUsbTestsEnabled();" line))))
210 `(("libusb4java" ,libusb4java)
211 ("java-commons-lang3" ,java-commons-lang3)
212 ("java-junit" ,java-junit)
213 ("java-hamcrest-core" ,java-hamcrest-core)))
214 (home-page "http://usb4java.org/")
215 (synopsis "USB library for Java")
217 "This package provides a USB library for Java based on libusb and
218 implementing @code{javax.usb} (JSR-80).")
219 (license license:expat)))
221 (define-public python-libusb1
223 (name "python-libusb1")
228 (uri (pypi-uri "libusb1" version))
231 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
232 (build-system python-build-system)
234 `(#:modules ((srfi srfi-1)
236 (guix build python-build-system))
238 (modify-phases %standard-phases
239 (add-before 'install-license-files 'remove-incorrect-license
240 (lambda* (#:key out #:allow-other-keys)
241 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
242 ;; in source. Remove it so it does not get installed.
243 (delete-file "COPYING")
245 (add-after 'unpack 'fix-libusb-reference
246 (lambda* (#:key inputs #:allow-other-keys)
247 (substitute* "usb1/libusb1.py"
248 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
251 (find (negate symbolic-link?)
252 (find-files (assoc-ref inputs "libusb")
253 "^libusb.*\\.so\\..*"))
256 (inputs `(("libusb" ,libusb)))
257 (home-page "https://github.com/vpelletier/python-libusb1")
258 (synopsis "Pure-python wrapper for libusb-1.0")
259 (description "Libusb is a library that gives applications easy access to
260 USB devices on various operating systems. This package provides a Python
261 wrapper for accessing libusb-1.0.")
262 (license license:lgpl2.1+)))
264 (define-public python-pyusb
266 (name "python-pyusb")
271 (uri (pypi-uri "pyusb" version))
274 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
275 (build-system python-build-system)
277 `(#:tests? #f ; no tests
278 #:modules ((srfi srfi-1)
281 (guix build python-build-system))
283 (modify-phases %standard-phases
284 (add-after 'unpack 'fix-libusb-reference
285 (lambda* (#:key inputs #:allow-other-keys)
286 (substitute* "usb/libloader.py"
287 (("lib = locate_library\\(candidates, find_library\\)")
290 (find (negate symbolic-link?)
291 (find-files (assoc-ref inputs "libusb")
292 "^libusb-.*\\.so\\..*"))
296 `(("libusb" ,libusb)))
297 (home-page "https://pyusb.github.io/pyusb/")
298 (synopsis "Python bindings to the libusb library")
300 "PyUSB aims to be an easy to use Python module to access USB devices.")
301 (license license:bsd-3)))
303 (define-public python2-pyusb
304 (package-with-python2 python-pyusb))
306 (define-public python-capablerobot-usbhub
308 (name "python-capablerobot-usbhub")
313 (uri (pypi-uri "capablerobot_usbhub" version))
316 "1priic4iq2vn1rc711kzxwhxrwa508rkxrr193qdz2lw26kdhvix"))))
317 (build-system python-build-system)
320 (modify-phases %standard-phases
321 (add-after 'install 'install-udev-rules
322 (lambda* (#:key outputs #:allow-other-keys)
323 (let ((out (assoc-ref outputs "out")))
324 (mkdir-p (string-append out "/lib/udev/rules.d"))
325 (copy-file "50-capablerobot-usbhub.rules"
328 "50-capablerobot-usbhub.rules"))
331 `(("python-click" ,python-click)
332 ("python-construct" ,python-construct)
333 ("python-pyusb" ,python-pyusb)
334 ("python-pyyaml" ,python-pyyaml)))
336 "https://github.com/CapableRobot/CapableRobot_USBHub_Driver")
338 "Host side driver for the Capable Robot Programmable USB Hub")
340 "This package provides access to the internal state of the Capable Robot
341 USB Hub, allowing you to monitor and control the Hub from an upstream
342 computer. It also creates a transparent CircuitPython Bridge, allowing
343 unmodified CircuitPython code to run on the host computer and interact with
344 I2C and SPI devices attached to the USB Hub.")
345 (license license:expat)))
347 (define-public libplist
355 (url "https://github.com/libimobiledevice/libplist.git")
357 (file-name (git-file-name name version))
359 (base32 "02vraf4j46bp746s0gz7vga2gv2dy3zd1v1bsy9x8algg9fpcb7n"))))
360 (build-system gnu-build-system)
362 `(;; Tests fail randomly when run in parallel because several of them write
363 ;; and read to/from the same file--e.g., "4.plist" is accessed by
364 ;; 'large.test' and 'largecmp.test'.
365 #:parallel-tests? #f))
367 `(("python" ,python)))
369 `(("autoconf" ,autoconf)
370 ("automake" ,automake)
372 ("pkg-config" ,pkg-config)
373 ("python-cython" ,python-cython))) ; to build Python bindings
374 (home-page "https://www.libimobiledevice.org/")
375 (synopsis "C library to handle Apple Property List files")
376 (description "This package provides a small portable C library to handle
377 Apple Property List files in binary or XML.")
378 (license license:lgpl2.1+)))
380 (define-public libusbmuxd
386 (uri (string-append "https://www.libimobiledevice.org/downloads/"
387 "libusbmuxd-" version ".tar.bz2"))
390 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
391 (build-system gnu-build-system)
393 `(("pkg-config" ,pkg-config)
394 ("libplist" ,libplist)))
395 (home-page "https://www.libimobiledevice.org/")
396 (synopsis "Library to multiplex connections from and to iOS devices")
397 (description "This package provides a client library to multiplex
398 connections from and to iOS devices by connecting to a socket provided by a
399 @code{usbmuxd} daemon.")
400 (license license:lgpl2.1+)))
402 ;; These patches are needed to build with Python 3.8.
403 (define %libimobiledevice-patches
406 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
407 "/commit/1ff3448d2e27f1bac8d2f0af8b8e952854860278.patch"))
408 (file-name "libimobiledevice-python-config.patch")
411 "1mkwhp8vvhajij29jk3w4rkgcfh8d8waf908drh3076k70hb6i8y")))
414 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
415 "/commit/eea4f1be9107c8ab621fd71460e47d0d38e55d71.patch"))
416 (file-name "libimobiledevice-python-3.8-compat.patch")
419 "1zz8v7kgwyq5ck1qp03l29pcmljygnjwls9d6q28nv5pkwa6848w")))))
421 (define-public libimobiledevice
423 (name "libimobiledevice")
427 (uri (string-append "https://www.libimobiledevice.org/downloads/"
428 "libimobiledevice-" version ".tar.bz2"))
429 ;; Note: Remove the 'force-bootstrap' phase and the autoconf
430 ;; inputs below when removing these patches.
431 (patches %libimobiledevice-patches)
434 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
435 (build-system gnu-build-system)
437 `(#:phases (modify-phases %standard-phases
438 (add-before 'bootstrap 'force-bootstrap
440 (delete-file "configure")
443 `(("openssl" ,openssl-1.0)
444 ("libplist" ,libplist)
445 ("libusbmuxd" ,libusbmuxd)))
447 `(("python" ,python)))
449 `(("pkg-config" ,pkg-config)
450 ("python-cython" ,python-cython)
452 ;; These are required because we patch and bootstrap the build system.
453 ("autoconf" ,autoconf)
454 ("automake" ,automake)
455 ("libtool" ,libtool)))
456 (home-page "https://www.libimobiledevice.org/")
457 (synopsis "Protocol library and tools to communicate with Apple devices")
458 (description "libimobiledevice is a software library that talks the
459 protocols to support Apple devices. It allows other software to easily access
460 the device's file system, retrieve information about the device and its
461 internals, backup/restore the device, manage installed applications, retrieve
462 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
463 music and video to the device.")
464 (license license:lgpl2.1+)))
472 (uri (string-append "https://www.libimobiledevice.org/downloads/"
473 "ifuse-" version ".tar.bz2"))
476 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
479 ("libimobiledevice" ,libimobiledevice)))
481 `(("pkg-config" ,pkg-config)))
482 (build-system gnu-build-system)
483 (home-page "https://www.libimobiledevice.org/")
484 (synopsis "Mount iOS devices")
485 (description "This package provides @command{ifuse}, a command to mount
486 iOS devices and access their contents.")
487 (license license:lgpl2.1+)))
489 (define-public usbmuxd
495 (uri (string-append "https://www.libimobiledevice.org/downloads/"
496 "usbmuxd-" version ".tar.bz2"))
499 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
501 `(("libplist" ,libplist)
503 ("libimobiledevice" ,libimobiledevice)))
505 `(("pkg-config" ,pkg-config)))
506 (build-system gnu-build-system)
507 (home-page "https://www.libimobiledevice.org/")
508 (synopsis "Multiplex connections over USB to an iOS device")
509 (description "This package provides the @code{usbmuxd} daemon
510 which multiplexes connections over USB to an iOS device. To
511 users, it means you can sync your music, contacts, photos, etc.
513 (license license:gpl2+)))
515 (define-public libmtp
521 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
522 "/libmtp-" version ".tar.gz"))
525 "1p3r38nvdip40ab1h4scj3mzfjkx6kd14szjqyw9r6wz5pslr8zq"))))
526 (build-system gnu-build-system)
528 `(("pkg-config" ,pkg-config)))
530 `(("libgcrypt" ,libgcrypt)))
532 ;; libmtp.pc refers to all these.
533 `(("libusb" ,libusb)))
536 (list "--disable-static"
537 (string-append "--with-udev="
538 (assoc-ref %outputs "out")
540 (home-page "http://libmtp.sourceforge.net/")
541 (synopsis "Library implementing the Media Transfer Protocol")
542 (description "Libmtp implements an MTP (Media Transfer Protocol)
543 initiator, which means that it initiates MTP sessions with devices. The
544 devices responding are known as MTP responders. Libmtp runs on devices
545 with a USB host controller interface. It implements MTP Basic, which was
546 proposed for standardization.")
547 ;; COPYING contains lgpl2.1, while files headers give
548 ;; "GNU Lesser General Public License as published by the Free Software
549 ;; Foundation; either version 2 of the License, or (at your option) any
551 (license license:lgpl2.1+)))
559 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
560 "/gmtp-" version ".tar.gz"))
563 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
564 (build-system glib-or-gtk-build-system)
567 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
569 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
570 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
571 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
575 ("libvorbis" ,libvorbis)
576 ("libid3tag" ,libid3tag)
579 `(("pkg-config" ,pkg-config)))
580 (home-page "http://gmtp.sourceforge.net/")
581 (synopsis "Simple graphical MTP client")
582 (description "gMTP is a simple graphical client for the Media Transfer Protocol
583 (MTP), which allows media files to be transferred to and from many portable
585 (license license:bsd-3)))
587 (define-public hidapi
595 (url "https://github.com/libusb/hidapi.git")
596 (commit (string-append "hidapi-" version))))
597 (file-name (git-file-name name version))
599 (base32 "1p4g8lgwj4rki6lbn5l6rvwj0xlbn1xfh4d255bg5pvgczmwmc4i"))))
600 (build-system gnu-build-system)
605 `(("autoconf" ,autoconf)
606 ("automake" ,automake)
608 ("pkg-config" ,pkg-config)))
609 (home-page "https://github.com/libusb/hidapi")
610 (synopsis "HID API library")
612 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
614 ;; HIDAPI can be used under one of three licenses.
615 (license (list license:gpl3
617 (license:non-copyleft "file://LICENSE-orig.txt")))))
619 (define-public python-hidapi
621 (name "python-hidapi")
622 (version "0.7.99.post21")
626 (uri (pypi-uri "hidapi" version))
629 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
630 (modules '((guix build utils)))
632 ;; Remove bundled libraries.
634 (delete-file-recursively "hidapi")
636 (build-system python-build-system)
639 (modify-phases %standard-phases
640 (add-after 'unpack 'patch-configuration
641 (lambda* (#:key inputs #:allow-other-keys)
642 (substitute* "setup.py"
643 (("'/usr/include/libusb-1.0'")
644 (string-append "'" (assoc-ref inputs "libusb")
645 "/include/libusb-1.0'"))
646 (("'/usr/include/hidapi'")
647 (string-append "'" (assoc-ref inputs "hidapi")
648 "/include/hidapi'")))
650 ;; XXX Necessary because python-build-system drops the arguments.
653 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
656 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
658 (lambda* (#:key outputs #:allow-other-keys)
659 (invoke "python" "setup.py" "install" "--with-system-hidapi"
660 (string-append "--prefix=" (assoc-ref outputs "out"))
661 "--single-version-externally-managed" "--root=/"))))))
667 `(("python-cython" ,python-cython)))
668 (home-page "https://github.com/trezor/cython-hidapi")
669 (synopsis "Cython interface to hidapi")
670 (description "This package provides a Cython interface to @code{hidapi}.")
671 ;; The library can be used under either of these licenses.
672 (license (list license:gpl3
674 (license:non-copyleft
675 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
676 "You are free to use cython-hidapi code for any purpose.")))))
678 (define-public python2-hidapi
679 (package-with-python2 python-hidapi))