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 libplist
314 (url "https://github.com/libimobiledevice/libplist.git")
316 (file-name (git-file-name name version))
318 (base32 "02vraf4j46bp746s0gz7vga2gv2dy3zd1v1bsy9x8algg9fpcb7n"))))
319 (build-system gnu-build-system)
321 `(;; Tests fail randomly when run in parallel because several of them write
322 ;; and read to/from the same file--e.g., "4.plist" is accessed by
323 ;; 'large.test' and 'largecmp.test'.
324 #:parallel-tests? #f))
326 `(("python" ,python)))
328 `(("autoconf" ,autoconf)
329 ("automake" ,automake)
331 ("pkg-config" ,pkg-config)
332 ("python-cython" ,python-cython))) ; to build Python bindings
333 (home-page "https://www.libimobiledevice.org/")
334 (synopsis "C library to handle Apple Property List files")
335 (description "This package provides a small portable C library to handle
336 Apple Property List files in binary or XML.")
337 (license license:lgpl2.1+)))
339 (define-public libusbmuxd
345 (uri (string-append "https://www.libimobiledevice.org/downloads/"
346 "libusbmuxd-" version ".tar.bz2"))
349 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
350 (build-system gnu-build-system)
352 `(("pkg-config" ,pkg-config)
353 ("libplist" ,libplist)))
354 (home-page "https://www.libimobiledevice.org/")
355 (synopsis "Library to multiplex connections from and to iOS devices")
356 (description "This package provides a client library to multiplex
357 connections from and to iOS devices by connecting to a socket provided by a
358 @code{usbmuxd} daemon.")
359 (license license:lgpl2.1+)))
361 ;; These patches are needed to build with Python 3.8.
362 (define %libimobiledevice-patches
365 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
366 "/commit/1ff3448d2e27f1bac8d2f0af8b8e952854860278.patch"))
367 (file-name "libimobiledevice-python-config.patch")
370 "1mkwhp8vvhajij29jk3w4rkgcfh8d8waf908drh3076k70hb6i8y")))
373 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
374 "/commit/eea4f1be9107c8ab621fd71460e47d0d38e55d71.patch"))
375 (file-name "libimobiledevice-python-3.8-compat.patch")
378 "1zz8v7kgwyq5ck1qp03l29pcmljygnjwls9d6q28nv5pkwa6848w")))))
380 (define-public libimobiledevice
382 (name "libimobiledevice")
386 (uri (string-append "https://www.libimobiledevice.org/downloads/"
387 "libimobiledevice-" version ".tar.bz2"))
388 ;; Note: Remove the 'force-bootstrap' phase and the autoconf
389 ;; inputs below when removing these patches.
390 (patches %libimobiledevice-patches)
393 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
394 (build-system gnu-build-system)
396 `(#:phases (modify-phases %standard-phases
397 (add-before 'bootstrap 'force-bootstrap
399 (delete-file "configure")
402 `(("openssl" ,openssl-1.0)
403 ("libplist" ,libplist)
404 ("libusbmuxd" ,libusbmuxd)))
406 `(("python" ,python)))
408 `(("pkg-config" ,pkg-config)
409 ("python-cython" ,python-cython)
411 ;; These are required because we patch and bootstrap the build system.
412 ("autoconf" ,autoconf)
413 ("automake" ,automake)
414 ("libtool" ,libtool)))
415 (home-page "https://www.libimobiledevice.org/")
416 (synopsis "Protocol library and tools to communicate with Apple devices")
417 (description "libimobiledevice is a software library that talks the
418 protocols to support Apple devices. It allows other software to easily access
419 the device's file system, retrieve information about the device and its
420 internals, backup/restore the device, manage installed applications, retrieve
421 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
422 music and video to the device.")
423 (license license:lgpl2.1+)))
431 (uri (string-append "https://www.libimobiledevice.org/downloads/"
432 "ifuse-" version ".tar.bz2"))
435 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
438 ("libimobiledevice" ,libimobiledevice)))
440 `(("pkg-config" ,pkg-config)))
441 (build-system gnu-build-system)
442 (home-page "https://www.libimobiledevice.org/")
443 (synopsis "Mount iOS devices")
444 (description "This package provides @command{ifuse}, a command to mount
445 iOS devices and access their contents.")
446 (license license:lgpl2.1+)))
448 (define-public usbmuxd
454 (uri (string-append "https://www.libimobiledevice.org/downloads/"
455 "usbmuxd-" version ".tar.bz2"))
458 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
460 `(("libplist" ,libplist)
462 ("libimobiledevice" ,libimobiledevice)))
464 `(("pkg-config" ,pkg-config)))
465 (build-system gnu-build-system)
466 (home-page "https://www.libimobiledevice.org/")
467 (synopsis "Multiplex connections over USB to an iOS device")
468 (description "This package provides the @code{usbmuxd} daemon
469 which multiplexes connections over USB to an iOS device. To
470 users, it means you can sync your music, contacts, photos, etc.
472 (license license:gpl2+)))
474 (define-public libmtp
480 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
481 "/libmtp-" version ".tar.gz"))
484 "1p3r38nvdip40ab1h4scj3mzfjkx6kd14szjqyw9r6wz5pslr8zq"))))
485 (build-system gnu-build-system)
487 `(("pkg-config" ,pkg-config)))
489 `(("libgcrypt" ,libgcrypt)))
491 ;; libmtp.pc refers to all these.
492 `(("libusb" ,libusb)))
495 (list "--disable-static"
496 (string-append "--with-udev="
497 (assoc-ref %outputs "out")
499 (home-page "http://libmtp.sourceforge.net/")
500 (synopsis "Library implementing the Media Transfer Protocol")
501 (description "Libmtp implements an MTP (Media Transfer Protocol)
502 initiator, which means that it initiates MTP sessions with devices. The
503 devices responding are known as MTP responders. Libmtp runs on devices
504 with a USB host controller interface. It implements MTP Basic, which was
505 proposed for standardization.")
506 ;; COPYING contains lgpl2.1, while files headers give
507 ;; "GNU Lesser General Public License as published by the Free Software
508 ;; Foundation; either version 2 of the License, or (at your option) any
510 (license license:lgpl2.1+)))
518 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
519 "/gmtp-" version ".tar.gz"))
522 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
523 (build-system glib-or-gtk-build-system)
526 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
528 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
529 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
530 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
534 ("libvorbis" ,libvorbis)
535 ("libid3tag" ,libid3tag)
538 `(("pkg-config" ,pkg-config)))
539 (home-page "http://gmtp.sourceforge.net/")
540 (synopsis "Simple graphical MTP client")
541 (description "gMTP is a simple graphical client for the Media Transfer Protocol
542 (MTP), which allows media files to be transferred to and from many portable
544 (license license:bsd-3)))
546 (define-public hidapi
554 (url "https://github.com/libusb/hidapi.git")
555 (commit (string-append "hidapi-" version))))
556 (file-name (git-file-name name version))
558 (base32 "1p4g8lgwj4rki6lbn5l6rvwj0xlbn1xfh4d255bg5pvgczmwmc4i"))))
559 (build-system gnu-build-system)
564 `(("autoconf" ,autoconf)
565 ("automake" ,automake)
567 ("pkg-config" ,pkg-config)))
568 (home-page "https://github.com/libusb/hidapi")
569 (synopsis "HID API library")
571 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
573 ;; HIDAPI can be used under one of three licenses.
574 (license (list license:gpl3
576 (license:non-copyleft "file://LICENSE-orig.txt")))))
578 (define-public python-hidapi
580 (name "python-hidapi")
581 (version "0.7.99.post21")
585 (uri (pypi-uri "hidapi" version))
588 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
589 (modules '((guix build utils)))
591 ;; Remove bundled libraries.
593 (delete-file-recursively "hidapi")
595 (build-system python-build-system)
598 (modify-phases %standard-phases
599 (add-after 'unpack 'patch-configuration
600 (lambda* (#:key inputs #:allow-other-keys)
601 (substitute* "setup.py"
602 (("'/usr/include/libusb-1.0'")
603 (string-append "'" (assoc-ref inputs "libusb")
604 "/include/libusb-1.0'"))
605 (("'/usr/include/hidapi'")
606 (string-append "'" (assoc-ref inputs "hidapi")
607 "/include/hidapi'")))
609 ;; XXX Necessary because python-build-system drops the arguments.
612 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
615 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
617 (lambda* (#:key outputs #:allow-other-keys)
618 (invoke "python" "setup.py" "install" "--with-system-hidapi"
619 (string-append "--prefix=" (assoc-ref outputs "out"))
620 "--single-version-externally-managed" "--root=/"))))))
626 `(("python-cython" ,python-cython)))
627 (home-page "https://github.com/trezor/cython-hidapi")
628 (synopsis "Cython interface to hidapi")
629 (description "This package provides a Cython interface to @code{hidapi}.")
630 ;; The library can be used under either of these licenses.
631 (license (list license:gpl3
633 (license:non-copyleft
634 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
635 "You are free to use cython-hidapi code for any purpose.")))))
637 (define-public python2-hidapi
638 (package-with-python2 python-hidapi))