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>
12 ;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages libusb)
30 #:use-module (gnu packages)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix packages)
33 #:use-module (guix utils)
34 #:use-module (guix download)
35 #:use-module (guix git-download)
36 #:use-module (guix build-system ant)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system gnu)
39 #:use-module (guix build-system glib-or-gtk)
40 #:use-module (guix build-system python)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages gnupg)
43 #:use-module (gnu packages gtk)
44 #:use-module (gnu packages java)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages mp3)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages python-xyz)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages xiph))
60 (uri (string-append "https://github.com/libusb/libusb/"
61 "releases/download/v" version
62 "/libusb-" version ".tar.bz2"))
64 (base32 "13dd2a9x290d1q8nb1lqiaf36grcvns5ripk5k2xm0lajmpc04fv"))))
65 (build-system gnu-build-system)
67 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
69 (arguments `(#:configure-flags '("--disable-udev")))
70 ;; (inputs `(("eudev" ,eudev)))
72 (home-page "https://libusb.info")
73 (synopsis "User-space USB library")
75 "Libusb is a library that gives applications easy access to USB
76 devices on various operating systems.")
77 (license license:lgpl2.1+)))
79 (define-public libusb-compat
81 (name "libusb-compat")
86 (uri (string-append "mirror://sourceforge/libusb/"
87 "libusb-compat-" (version-major+minor version) "/"
88 "libusb-compat-" version "/"
89 "libusb-compat-" version ".tar.bz2"))
92 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
93 (build-system gnu-build-system)
95 `(("pkg-config" ,pkg-config)))
97 `(("libusb" ,libusb)))
98 (home-page "https://libusb.info")
99 (synopsis "Compatibility shim for libusb")
101 "Libusb-compat provides a shim allowing applications based on older
102 version of libusb to run with newer libusb.")
103 (license license:lgpl2.1+)))
105 ;; required by 0xffff, which compiles with libusb-compat, but executes only
107 (define-public libusb-0.1
108 (package (inherit libusb)
113 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
114 version "/libusb-" version ".tar.gz"))
117 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
118 (patches (search-patches "libusb-0.1-disable-tests.patch"))))
119 (arguments `(#:configure-flags (list "CFLAGS=-Wno-error")))))
121 (define-public libusb4java
122 ;; There is no public release so we take the latest version from git.
123 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
127 (version (string-append "0-" revision "." (string-take commit 9)))
131 (url "https://github.com/usb4java/libusb4java.git")
133 (file-name (git-file-name name version))
136 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
137 (build-system cmake-build-system)
139 `(#:tests? #f ; there are no tests
141 (modify-phases %standard-phases
142 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
143 ;; fails because libusb4java uses a deprecated procedure.
144 (add-after 'unpack 'disable-Werror
146 (substitute* "CMakeLists.txt"
149 (add-before 'configure 'set-JAVA_HOME
150 (lambda* (#:key inputs #:allow-other-keys)
151 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
154 `(("libusb" ,libusb)))
156 `(("jdk" ,icedtea "jdk")))
157 (home-page "https://github.com/usb4java/libusb4java/")
158 (synopsis "JNI bindings to libusb")
160 "This package provides Java JNI bindings to the libusb library for use
162 (license license:expat))))
164 (define-public java-usb4java
166 (name "java-usb4java")
170 (uri (string-append "https://github.com/usb4java/usb4java/"
171 "archive/usb4java-" version ".tar.gz"))
174 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
175 (build-system ant-build-system)
177 `(#:jar-name "usb4java.jar"
179 (modify-phases %standard-phases
180 ;; Usually, native libusb4java libraries for all supported systems
181 ;; would be included in the jar and extracted at runtime. Since we
182 ;; build everything from source we cannot just bundle pre-built
183 ;; binaries for other systems. Instead, we patch the loader to
184 ;; directly return the appropriate library for this system. The
185 ;; downside is that the jar will only work on the same architecture
186 ;; that it was built on.
187 (add-after 'unpack 'copy-libusb4java
188 (lambda* (#:key inputs #:allow-other-keys)
189 (substitute* "src/main/java/org/usb4java/Loader.java"
190 (("private static String extractLibrary" line)
192 line "(final String a, final String b) {"
194 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
196 "private static String _extractLibrary")))
198 (add-after 'unpack 'disable-broken-tests
200 (with-directory-excursion "src/test/java/org/usb4java"
201 ;; These tests should only be run when USB devices are present.
202 (substitute* '("LibUsbGlobalTest.java"
204 (("this.context = new Context\\(\\);")
205 "this.context = null;")
206 (("LibUsb.init") "//"))
207 (substitute* "DeviceListIteratorTest.java"
208 (("this.iterator.remove" line)
209 (string-append "assumeUsbTestsEnabled();" line))))
212 `(("libusb4java" ,libusb4java)
213 ("java-commons-lang3" ,java-commons-lang3)
214 ("java-junit" ,java-junit)
215 ("java-hamcrest-core" ,java-hamcrest-core)))
216 (home-page "http://usb4java.org/")
217 (synopsis "USB library for Java")
219 "This package provides a USB library for Java based on libusb and
220 implementing @code{javax.usb} (JSR-80).")
221 (license license:expat)))
223 (define-public python-libusb1
225 (name "python-libusb1")
230 (uri (pypi-uri "libusb1" version))
233 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
234 (build-system python-build-system)
236 `(#:modules ((srfi srfi-1)
238 (guix build python-build-system))
240 (modify-phases %standard-phases
241 (add-before 'install-license-files 'remove-incorrect-license
242 (lambda* (#:key out #:allow-other-keys)
243 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
244 ;; in source. Remove it so it does not get installed.
245 (delete-file "COPYING")
247 (add-after 'unpack 'fix-libusb-reference
248 (lambda* (#:key inputs #:allow-other-keys)
249 (substitute* "usb1/libusb1.py"
250 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
253 (find (negate symbolic-link?)
254 (find-files (assoc-ref inputs "libusb")
255 "^libusb.*\\.so\\..*"))
258 (inputs `(("libusb" ,libusb)))
259 (home-page "https://github.com/vpelletier/python-libusb1")
260 (synopsis "Pure-python wrapper for libusb-1.0")
261 (description "Libusb is a library that gives applications easy access to
262 USB devices on various operating systems. This package provides a Python
263 wrapper for accessing libusb-1.0.")
264 (license license:lgpl2.1+)))
266 (define-public python-pyusb
268 (name "python-pyusb")
273 (uri (pypi-uri "pyusb" version))
276 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
277 (build-system python-build-system)
279 `(#:tests? #f ; no tests
280 #:modules ((srfi srfi-1)
283 (guix build python-build-system))
285 (modify-phases %standard-phases
286 (add-after 'unpack 'fix-libusb-reference
287 (lambda* (#:key inputs #:allow-other-keys)
288 (substitute* "usb/libloader.py"
289 (("lib = locate_library\\(candidates, find_library\\)")
292 (find (negate symbolic-link?)
293 (find-files (assoc-ref inputs "libusb")
294 "^libusb-.*\\.so\\..*"))
298 `(("libusb" ,libusb)))
299 (home-page "https://pyusb.github.io/pyusb/")
300 (synopsis "Python bindings to the libusb library")
302 "PyUSB aims to be an easy to use Python module to access USB devices.")
303 (license license:bsd-3)))
305 (define-public python2-pyusb
306 (package-with-python2 python-pyusb))
308 (define-public python-capablerobot-usbhub
310 (name "python-capablerobot-usbhub")
315 (uri (pypi-uri "capablerobot_usbhub" version))
318 "1priic4iq2vn1rc711kzxwhxrwa508rkxrr193qdz2lw26kdhvix"))))
319 (build-system python-build-system)
322 (modify-phases %standard-phases
323 (add-after 'install 'install-udev-rules
324 (lambda* (#:key outputs #:allow-other-keys)
325 (let ((out (assoc-ref outputs "out")))
326 (mkdir-p (string-append out "/lib/udev/rules.d"))
327 (copy-file "50-capablerobot-usbhub.rules"
330 "50-capablerobot-usbhub.rules"))
333 `(("python-click" ,python-click)
334 ("python-construct" ,python-construct)
335 ("python-pyusb" ,python-pyusb)
336 ("python-pyyaml" ,python-pyyaml)))
338 "https://github.com/CapableRobot/CapableRobot_USBHub_Driver")
340 "Host side driver for the Capable Robot Programmable USB Hub")
342 "This package provides access to the internal state of the Capable Robot
343 USB Hub, allowing you to monitor and control the Hub from an upstream
344 computer. It also creates a transparent CircuitPython Bridge, allowing
345 unmodified CircuitPython code to run on the host computer and interact with
346 I2C and SPI devices attached to the USB Hub.")
347 (license license:expat)))
349 (define-public libplist
357 (url "https://github.com/libimobiledevice/libplist.git")
359 (file-name (git-file-name name version))
361 (base32 "02vraf4j46bp746s0gz7vga2gv2dy3zd1v1bsy9x8algg9fpcb7n"))))
362 (build-system gnu-build-system)
364 `(;; Tests fail randomly when run in parallel because several of them write
365 ;; and read to/from the same file--e.g., "4.plist" is accessed by
366 ;; 'large.test' and 'largecmp.test'.
367 #:parallel-tests? #f))
369 `(("python" ,python)))
371 `(("autoconf" ,autoconf)
372 ("automake" ,automake)
374 ("pkg-config" ,pkg-config)
375 ("python-cython" ,python-cython))) ; to build Python bindings
376 (home-page "https://www.libimobiledevice.org/")
377 (synopsis "C library to handle Apple Property List files")
378 (description "This package provides a small portable C library to handle
379 Apple Property List files in binary or XML.")
380 (license license:lgpl2.1+)))
382 (define-public libusbmuxd
388 (uri (string-append "https://www.libimobiledevice.org/downloads/"
389 "libusbmuxd-" version ".tar.bz2"))
392 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
393 (build-system gnu-build-system)
395 `(("pkg-config" ,pkg-config)
396 ("libplist" ,libplist)))
397 (home-page "https://www.libimobiledevice.org/")
398 (synopsis "Library to multiplex connections from and to iOS devices")
399 (description "This package provides a client library to multiplex
400 connections from and to iOS devices by connecting to a socket provided by a
401 @code{usbmuxd} daemon.")
402 (license license:lgpl2.1+)))
404 ;; These patches are needed to build with Python 3.8.
405 (define %libimobiledevice-patches
408 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
409 "/commit/1ff3448d2e27f1bac8d2f0af8b8e952854860278.patch"))
410 (file-name "libimobiledevice-python-config.patch")
413 "1mkwhp8vvhajij29jk3w4rkgcfh8d8waf908drh3076k70hb6i8y")))
416 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
417 "/commit/eea4f1be9107c8ab621fd71460e47d0d38e55d71.patch"))
418 (file-name "libimobiledevice-python-3.8-compat.patch")
421 "1zz8v7kgwyq5ck1qp03l29pcmljygnjwls9d6q28nv5pkwa6848w")))))
423 (define-public libimobiledevice
425 (name "libimobiledevice")
429 (uri (string-append "https://www.libimobiledevice.org/downloads/"
430 "libimobiledevice-" version ".tar.bz2"))
431 ;; Note: Remove the 'force-bootstrap' phase and the autoconf
432 ;; inputs below when removing these patches.
433 (patches %libimobiledevice-patches)
436 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
437 (build-system gnu-build-system)
439 `(#:phases (modify-phases %standard-phases
440 (add-before 'bootstrap 'force-bootstrap
442 (delete-file "configure")
445 `(("openssl" ,openssl-1.0)
446 ("libplist" ,libplist)
447 ("libusbmuxd" ,libusbmuxd)))
449 `(("python" ,python)))
451 `(("pkg-config" ,pkg-config)
452 ("python-cython" ,python-cython)
454 ;; These are required because we patch and bootstrap the build system.
455 ("autoconf" ,autoconf)
456 ("automake" ,automake)
457 ("libtool" ,libtool)))
458 (home-page "https://www.libimobiledevice.org/")
459 (synopsis "Protocol library and tools to communicate with Apple devices")
460 (description "libimobiledevice is a software library that talks the
461 protocols to support Apple devices. It allows other software to easily access
462 the device's file system, retrieve information about the device and its
463 internals, backup/restore the device, manage installed applications, retrieve
464 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
465 music and video to the device.")
466 (license license:lgpl2.1+)))
474 (uri (string-append "https://www.libimobiledevice.org/downloads/"
475 "ifuse-" version ".tar.bz2"))
478 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
481 ("libimobiledevice" ,libimobiledevice)))
483 `(("pkg-config" ,pkg-config)))
484 (build-system gnu-build-system)
485 (home-page "https://www.libimobiledevice.org/")
486 (synopsis "Mount iOS devices")
487 (description "This package provides @command{ifuse}, a command to mount
488 iOS devices and access their contents.")
489 (license license:lgpl2.1+)))
491 (define-public usbmuxd
497 (uri (string-append "https://www.libimobiledevice.org/downloads/"
498 "usbmuxd-" version ".tar.bz2"))
501 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
503 `(("libplist" ,libplist)
505 ("libimobiledevice" ,libimobiledevice)))
507 `(("pkg-config" ,pkg-config)))
508 (build-system gnu-build-system)
509 (home-page "https://www.libimobiledevice.org/")
510 (synopsis "Multiplex connections over USB to an iOS device")
511 (description "This package provides the @code{usbmuxd} daemon
512 which multiplexes connections over USB to an iOS device. To
513 users, it means you can sync your music, contacts, photos, etc.
515 (license license:gpl2+)))
517 (define-public libmtp
523 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
524 "/libmtp-" version ".tar.gz"))
527 "1p3r38nvdip40ab1h4scj3mzfjkx6kd14szjqyw9r6wz5pslr8zq"))))
528 (build-system gnu-build-system)
530 `(("pkg-config" ,pkg-config)))
532 `(("libgcrypt" ,libgcrypt)))
534 ;; libmtp.pc refers to all these.
535 `(("libusb" ,libusb)))
538 (list "--disable-static"
539 (string-append "--with-udev="
540 (assoc-ref %outputs "out")
542 (home-page "http://libmtp.sourceforge.net/")
543 (synopsis "Library implementing the Media Transfer Protocol")
544 (description "Libmtp implements an MTP (Media Transfer Protocol)
545 initiator, which means that it initiates MTP sessions with devices. The
546 devices responding are known as MTP responders. Libmtp runs on devices
547 with a USB host controller interface. It implements MTP Basic, which was
548 proposed for standardization.")
549 ;; COPYING contains lgpl2.1, while files headers give
550 ;; "GNU Lesser General Public License as published by the Free Software
551 ;; Foundation; either version 2 of the License, or (at your option) any
553 (license license:lgpl2.1+)))
561 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
562 "/gmtp-" version ".tar.gz"))
565 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
566 (build-system glib-or-gtk-build-system)
569 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
571 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
572 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
573 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
577 ("libvorbis" ,libvorbis)
578 ("libid3tag" ,libid3tag)
581 `(("pkg-config" ,pkg-config)))
582 (home-page "http://gmtp.sourceforge.net/")
583 (synopsis "Simple graphical MTP client")
584 (description "gMTP is a simple graphical client for the Media Transfer Protocol
585 (MTP), which allows media files to be transferred to and from many portable
587 (license license:bsd-3)))
589 (define-public hidapi
597 (url "https://github.com/libusb/hidapi.git")
598 (commit (string-append "hidapi-" version))))
599 (file-name (git-file-name name version))
601 (base32 "1p4g8lgwj4rki6lbn5l6rvwj0xlbn1xfh4d255bg5pvgczmwmc4i"))))
602 (build-system gnu-build-system)
607 `(("autoconf" ,autoconf)
608 ("automake" ,automake)
610 ("pkg-config" ,pkg-config)))
611 (home-page "https://github.com/libusb/hidapi")
612 (synopsis "HID API library")
614 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
616 ;; HIDAPI can be used under one of three licenses.
617 (license (list license:gpl3
619 (license:non-copyleft "file://LICENSE-orig.txt")))))
621 (define-public python-hidapi
623 (name "python-hidapi")
624 (version "0.7.99.post21")
628 (uri (pypi-uri "hidapi" version))
631 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
632 (modules '((guix build utils)))
634 ;; Remove bundled libraries.
636 (delete-file-recursively "hidapi")
638 (build-system python-build-system)
641 (modify-phases %standard-phases
642 (add-after 'unpack 'patch-configuration
643 (lambda* (#:key inputs #:allow-other-keys)
644 (substitute* "setup.py"
645 (("'/usr/include/libusb-1.0'")
646 (string-append "'" (assoc-ref inputs "libusb")
647 "/include/libusb-1.0'"))
648 (("'/usr/include/hidapi'")
649 (string-append "'" (assoc-ref inputs "hidapi")
650 "/include/hidapi'")))
652 ;; XXX Necessary because python-build-system drops the arguments.
655 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
658 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
660 (lambda* (#:key outputs #:allow-other-keys)
661 (invoke "python" "setup.py" "install" "--with-system-hidapi"
662 (string-append "--prefix=" (assoc-ref outputs "out"))
663 "--single-version-externally-managed" "--root=/"))))))
669 `(("python-cython" ,python-cython)))
670 (home-page "https://github.com/trezor/cython-hidapi")
671 (synopsis "Cython interface to hidapi")
672 (description "This package provides a Cython interface to @code{hidapi}.")
673 ;; The library can be used under either of these licenses.
674 (license (list license:gpl3
676 (license:non-copyleft
677 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
678 "You are free to use cython-hidapi code for any purpose.")))))
680 (define-public python2-hidapi
681 (package-with-python2 python-hidapi))