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, 2020 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 "0amilbi5qncdnrds3ji21vbiz1wvdm1fwp5qrxnk49xkyy2jdzby"))))
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")
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")
171 (url "https://github.com/usb4java/usb4java")
172 (commit (string-append "usb4java-" version))))
173 (file-name (git-file-name name version))
176 "0aip6k24czz5g58qwb963mpick0b6ks774drfpdd8gcdvj9iv87j"))))
177 (build-system ant-build-system)
179 `(#:jar-name "usb4java.jar"
181 (modify-phases %standard-phases
182 ;; Usually, native libusb4java libraries for all supported systems
183 ;; would be included in the jar and extracted at runtime. Since we
184 ;; build everything from source we cannot just bundle pre-built
185 ;; binaries for other systems. Instead, we patch the loader to
186 ;; directly return the appropriate library for this system. The
187 ;; downside is that the jar will only work on the same architecture
188 ;; that it was built on.
189 (add-after 'unpack 'copy-libusb4java
190 (lambda* (#:key inputs #:allow-other-keys)
191 (substitute* "src/main/java/org/usb4java/Loader.java"
192 (("private static String extractLibrary" line)
194 line "(final String a, final String b) {"
196 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
198 "private static String _extractLibrary")))
200 (add-after 'unpack 'disable-broken-tests
202 (with-directory-excursion "src/test/java/org/usb4java"
203 ;; These tests should only be run when USB devices are present.
204 (substitute* '("LibUsbGlobalTest.java"
206 (("this.context = new Context\\(\\);")
207 "this.context = null;")
208 (("LibUsb.init") "//"))
209 (substitute* "DeviceListIteratorTest.java"
210 (("this.iterator.remove" line)
211 (string-append "assumeUsbTestsEnabled();" line))))
214 `(("libusb4java" ,libusb4java)
215 ("java-commons-lang3" ,java-commons-lang3)
216 ("java-junit" ,java-junit)
217 ("java-hamcrest-core" ,java-hamcrest-core)))
218 (home-page "http://usb4java.org/")
219 (synopsis "USB library for Java")
221 "This package provides a USB library for Java based on libusb and
222 implementing @code{javax.usb} (JSR-80).")
223 (license license:expat)))
225 (define-public python-libusb1
227 (name "python-libusb1")
232 (uri (pypi-uri "libusb1" version))
235 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
236 (build-system python-build-system)
238 `(#:modules ((srfi srfi-1)
240 (guix build python-build-system))
242 (modify-phases %standard-phases
243 (add-before 'install-license-files 'remove-incorrect-license
244 (lambda* (#:key out #:allow-other-keys)
245 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
246 ;; in source. Remove it so it does not get installed.
247 (delete-file "COPYING")
249 (add-after 'unpack 'fix-libusb-reference
250 (lambda* (#:key inputs #:allow-other-keys)
251 (substitute* "usb1/libusb1.py"
252 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
255 (find (negate symbolic-link?)
256 (find-files (assoc-ref inputs "libusb")
257 "^libusb.*\\.so\\..*"))
260 (inputs `(("libusb" ,libusb)))
261 (home-page "https://github.com/vpelletier/python-libusb1")
262 (synopsis "Pure-python wrapper for libusb-1.0")
263 (description "Libusb is a library that gives applications easy access to
264 USB devices on various operating systems. This package provides a Python
265 wrapper for accessing libusb-1.0.")
266 (license license:lgpl2.1+)))
268 (define-public python-pyusb
270 (name "python-pyusb")
275 (uri (pypi-uri "pyusb" version))
278 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
279 (build-system python-build-system)
281 `(#:tests? #f ; no tests
282 #:modules ((srfi srfi-1)
285 (guix build python-build-system))
287 (modify-phases %standard-phases
288 (add-after 'unpack 'fix-libusb-reference
289 (lambda* (#:key inputs #:allow-other-keys)
290 (substitute* "usb/libloader.py"
291 (("lib = locate_library\\(candidates, find_library\\)")
294 (find (negate symbolic-link?)
295 (find-files (assoc-ref inputs "libusb")
296 "^libusb-.*\\.so\\..*"))
300 `(("libusb" ,libusb)))
301 (home-page "https://pyusb.github.io/pyusb/")
302 (synopsis "Python bindings to the libusb library")
304 "PyUSB aims to be an easy to use Python module to access USB devices.")
305 (license license:bsd-3)))
307 (define-public python2-pyusb
308 (package-with-python2 python-pyusb))
310 (define-public python-capablerobot-usbhub
312 (name "python-capablerobot-usbhub")
317 (uri (pypi-uri "capablerobot_usbhub" version))
320 "1priic4iq2vn1rc711kzxwhxrwa508rkxrr193qdz2lw26kdhvix"))))
321 (build-system python-build-system)
324 (modify-phases %standard-phases
325 (add-after 'install 'install-udev-rules
326 (lambda* (#:key outputs #:allow-other-keys)
327 (let ((out (assoc-ref outputs "out")))
328 (mkdir-p (string-append out "/lib/udev/rules.d"))
329 (copy-file "50-capablerobot-usbhub.rules"
332 "50-capablerobot-usbhub.rules"))
335 `(("python-click" ,python-click)
336 ("python-construct" ,python-construct)
337 ("python-pyusb" ,python-pyusb)
338 ("python-pyyaml" ,python-pyyaml)))
340 "https://github.com/CapableRobot/CapableRobot_USBHub_Driver")
342 "Host side driver for the Capable Robot Programmable USB Hub")
344 "This package provides access to the internal state of the Capable Robot
345 USB Hub, allowing you to monitor and control the Hub from an upstream
346 computer. It also creates a transparent CircuitPython Bridge, allowing
347 unmodified CircuitPython code to run on the host computer and interact with
348 I2C and SPI devices attached to the USB Hub.")
349 (license license:expat)))
351 (define-public libplist
358 (uri (string-append "https://github.com/libimobiledevice"
359 "/libplist/releases/download/" version
360 "/libplist-" version ".tar.bz2"))
362 (base32 "16mxdwaw01x9a3adf0yj3bqjc7afpf2vm1n5hkgj3i3y6zjifmaa"))))
363 (build-system gnu-build-system)
365 `(;; Tests fail randomly when run in parallel because several of them write
366 ;; and read to/from the same file--e.g., "4.plist" is accessed by
367 ;; 'large.test' and 'largecmp.test'.
368 #:parallel-tests? #f))
370 `(("python" ,python)))
372 `(("autoconf" ,autoconf)
373 ("automake" ,automake)
375 ("pkg-config" ,pkg-config)
376 ("python-cython" ,python-cython))) ; to build Python bindings
377 (home-page "https://libimobiledevice.org/")
378 (synopsis "C library to handle Apple Property List files")
379 (description "This package provides a small portable C library to handle
380 Apple Property List files in binary or XML.")
381 (license license:lgpl2.1+)))
383 (define-public libusbmuxd
389 (uri (string-append "https://github.com/libimobiledevice"
390 "/libusbmuxd/releases/download/" version
391 "/libusbmuxd-" version ".tar.bz2"))
394 "084vg570g1qb506jd7axg6c080mfsmbf52v3lngzlknsaf2q0snc"))))
395 (build-system gnu-build-system)
397 `(("pkg-config" ,pkg-config)
398 ("libplist" ,libplist)))
399 (home-page "https://libimobiledevice.org/")
400 (synopsis "Library to multiplex connections from and to iOS devices")
401 (description "This package provides a client library to multiplex
402 connections from and to iOS devices by connecting to a socket provided by a
403 @code{usbmuxd} daemon.")
404 (license license:lgpl2.1+)))
406 (define-public libimobiledevice
408 (name "libimobiledevice")
412 (uri (string-append "https://github.com/libimobiledevice"
413 "/libimobiledevice/releases/download/"
414 version "/libimobiledevice-" version
418 "1xmhfnypg6j7shl73wfkrrn4mj9dh8qzaj3258q9zkb5cc669wjk"))))
419 (build-system gnu-build-system)
421 '(#:configure-flags '("PYTHON_VERSION=3")))
423 `(("openssl" ,openssl)
424 ("libplist" ,libplist)
425 ("libusbmuxd" ,libusbmuxd)))
427 `(("python" ,python)))
429 `(("pkg-config" ,pkg-config)
430 ("python-cython" ,python-cython)))
431 (home-page "https://libimobiledevice.org/")
432 (synopsis "Protocol library and tools to communicate with Apple devices")
433 (description "libimobiledevice is a software library that talks the
434 protocols to support Apple devices. It allows other software to easily access
435 the device's file system, retrieve information about the device and its
436 internals, backup/restore the device, manage installed applications, retrieve
437 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
438 music and video to the device.")
439 (license license:lgpl2.1+)))
447 (uri (string-append "https://github.com/libimobiledevice"
448 "/ifuse/releases/download/" version
449 "/ifuse-" version ".tar.bz2"))
452 "11wdv44qwia77sh38n36809ysaib52rwd4fvqwb5ybsbz4p70l1m"))))
455 ("libimobiledevice" ,libimobiledevice)))
457 `(("pkg-config" ,pkg-config)))
458 (build-system gnu-build-system)
459 (home-page "https://libimobiledevice.org/")
460 (synopsis "Mount iOS devices")
461 (description "This package provides @command{ifuse}, a command to mount
462 iOS devices and access their contents.")
463 (license license:lgpl2.1+)))
465 (define-public usbmuxd
471 (uri (string-append "https://github.com/libimobiledevice"
472 "/usbmuxd/releases/download/" version
473 "/usbmuxd-" version ".tar.bz2"))
476 "17idzpxrvkbff0jpynf35df95lh7wsm8vndynp63bxib2w09gv60"))))
478 `(("libplist" ,libplist)
480 ("libimobiledevice" ,libimobiledevice)))
482 `(("pkg-config" ,pkg-config)))
483 (build-system gnu-build-system)
484 (home-page "https://libimobiledevice.org/")
485 (synopsis "Multiplex connections over USB to an iOS device")
486 (description "This package provides the @code{usbmuxd} daemon
487 which multiplexes connections over USB to an iOS device. To
488 users, it means you can sync your music, contacts, photos, etc.
490 (license license:gpl2+)))
492 (define-public libmtp
498 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
499 "/libmtp-" version ".tar.gz"))
502 "1w41l93yi0dmw218daiw36rylkc8rammxx37csh1ij24q18gx03j"))))
503 (build-system gnu-build-system)
505 `(("pkg-config" ,pkg-config)))
507 `(("libgcrypt" ,libgcrypt)))
509 ;; libmtp.pc refers to all these.
510 `(("libusb" ,libusb)))
513 (list "--disable-static"
514 (string-append "--with-udev="
515 (assoc-ref %outputs "out")
517 (home-page "http://libmtp.sourceforge.net/")
518 (synopsis "Library implementing the Media Transfer Protocol")
519 (description "Libmtp implements an MTP (Media Transfer Protocol)
520 initiator, which means that it initiates MTP sessions with devices. The
521 devices responding are known as MTP responders. Libmtp runs on devices
522 with a USB host controller interface. It implements MTP Basic, which was
523 proposed for standardization.")
524 ;; COPYING contains lgpl2.1, while files headers give
525 ;; "GNU Lesser General Public License as published by the Free Software
526 ;; Foundation; either version 2 of the License, or (at your option) any
528 (license license:lgpl2.1+)))
536 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
537 "/gmtp-" version ".tar.gz"))
540 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
541 (build-system glib-or-gtk-build-system)
544 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
546 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
547 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
548 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
552 ("libvorbis" ,libvorbis)
553 ("libid3tag" ,libid3tag)
556 `(("pkg-config" ,pkg-config)))
557 (home-page "http://gmtp.sourceforge.net/")
558 (synopsis "Simple graphical MTP client")
559 (description "gMTP is a simple graphical client for the Media Transfer Protocol
560 (MTP), which allows media files to be transferred to and from many portable
562 (license license:bsd-3)))
564 (define-public hidapi
572 (url "https://github.com/libusb/hidapi")
573 (commit (string-append "hidapi-" version))))
574 (file-name (git-file-name name version))
576 (base32 "1nr4z4b10vpbh3ss525r7spz4i43zim2ba5qzfl15dgdxshxxivb"))))
577 (build-system gnu-build-system)
582 `(("autoconf" ,autoconf)
583 ("automake" ,automake)
585 ("pkg-config" ,pkg-config)))
586 (home-page "https://github.com/libusb/hidapi")
587 (synopsis "HID API library")
589 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
591 ;; HIDAPI can be used under one of three licenses.
592 (license (list license:gpl3
594 (license:non-copyleft "file://LICENSE-orig.txt")))))
596 (define-public python-hidapi
598 (name "python-hidapi")
599 (version "0.7.99.post21")
603 (uri (pypi-uri "hidapi" version))
606 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
607 (modules '((guix build utils)))
609 ;; Remove bundled libraries.
611 (delete-file-recursively "hidapi")
613 (build-system python-build-system)
616 (modify-phases %standard-phases
617 (add-after 'unpack 'patch-configuration
618 (lambda* (#:key inputs #:allow-other-keys)
619 (substitute* "setup.py"
620 (("'/usr/include/libusb-1.0'")
621 (string-append "'" (assoc-ref inputs "libusb")
622 "/include/libusb-1.0'"))
623 (("'/usr/include/hidapi'")
624 (string-append "'" (assoc-ref inputs "hidapi")
625 "/include/hidapi'")))
627 ;; XXX Necessary because python-build-system drops the arguments.
630 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
633 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
635 (lambda* (#:key outputs #:allow-other-keys)
636 (invoke "python" "setup.py" "install" "--with-system-hidapi"
637 (string-append "--prefix=" (assoc-ref outputs "out"))
638 "--single-version-externally-managed" "--root=/"))))))
644 `(("python-cython" ,python-cython)))
645 (home-page "https://github.com/trezor/cython-hidapi")
646 (synopsis "Cython interface to hidapi")
647 (description "This package provides a Cython interface to @code{hidapi}.")
648 ;; The library can be used under either of these licenses.
649 (license (list license:gpl3
651 (license:non-copyleft
652 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
653 "You are free to use cython-hidapi code for any purpose.")))))
655 (define-public python2-hidapi
656 (package-with-python2 python-hidapi))