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>
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) #:prefix license:)
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 python-xyz)
48 #:use-module (gnu packages tls)
49 #:use-module (gnu packages xiph))
58 (uri (string-append "https://github.com/libusb/libusb/"
59 "releases/download/v" version
60 "/libusb-" version ".tar.bz2"))
62 (base32 "13dd2a9x290d1q8nb1lqiaf36grcvns5ripk5k2xm0lajmpc04fv"))))
63 (build-system gnu-build-system)
65 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
67 (arguments `(#:configure-flags '("--disable-udev")))
68 ;; (inputs `(("eudev" ,eudev)))
70 (home-page "https://libusb.info")
71 (synopsis "User-space USB library")
73 "Libusb is a library that gives applications easy access to USB
74 devices on various operating systems.")
75 (license license:lgpl2.1+)))
77 (define-public libusb-compat
79 (name "libusb-compat")
84 (uri (string-append "mirror://sourceforge/libusb/"
85 "libusb-compat-" (version-major+minor version) "/"
86 "libusb-compat-" version "/"
87 "libusb-compat-" version ".tar.bz2"))
90 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
91 (build-system gnu-build-system)
93 `(("pkg-config" ,pkg-config)))
95 `(("libusb" ,libusb)))
96 (home-page "https://libusb.info")
97 (synopsis "Compatibility shim for libusb")
99 "Libusb-compat provides a shim allowing applications based on older
100 version of libusb to run with newer libusb.")
101 (license license:lgpl2.1+)))
103 ;; required by 0xffff, which compiles with libusb-compat, but executes only
105 (define-public libusb-0.1
106 (package (inherit libusb)
111 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
112 version "/libusb-" version ".tar.gz"))
115 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
116 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
118 (define-public libusb4java
119 ;; There is no public release so we take the latest version from git.
120 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
124 (version (string-append "0-" revision "." (string-take commit 9)))
128 (url "https://github.com/usb4java/libusb4java.git")
130 (file-name (git-file-name name version))
133 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
134 (build-system cmake-build-system)
136 `(#:tests? #f ; there are no tests
138 (modify-phases %standard-phases
139 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
140 ;; fails because libusb4java uses a deprecated procedure.
141 (add-after 'unpack 'disable-Werror
143 (substitute* "CMakeLists.txt"
146 (add-before 'configure 'set-JAVA_HOME
147 (lambda* (#:key inputs #:allow-other-keys)
148 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
151 `(("libusb" ,libusb)))
153 `(("jdk" ,icedtea "jdk")))
154 (home-page "https://github.com/usb4java/libusb4java/")
155 (synopsis "JNI bindings to libusb")
157 "This package provides Java JNI bindings to the libusb library for use
159 (license license:expat))))
161 (define-public java-usb4java
163 (name "java-usb4java")
167 (uri (string-append "https://github.com/usb4java/usb4java/"
168 "archive/usb4java-" version ".tar.gz"))
171 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
172 (build-system ant-build-system)
174 `(#:jar-name "usb4java.jar"
176 (modify-phases %standard-phases
177 ;; Usually, native libusb4java libraries for all supported systems
178 ;; would be included in the jar and extracted at runtime. Since we
179 ;; build everything from source we cannot just bundle pre-built
180 ;; binaries for other systems. Instead, we patch the loader to
181 ;; directly return the appropriate library for this system. The
182 ;; downside is that the jar will only work on the same architecture
183 ;; that it was built on.
184 (add-after 'unpack 'copy-libusb4java
185 (lambda* (#:key inputs #:allow-other-keys)
186 (substitute* "src/main/java/org/usb4java/Loader.java"
187 (("private static String extractLibrary" line)
189 line "(final String a, final String b) {"
191 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
193 "private static String _extractLibrary")))
195 (add-after 'unpack 'disable-broken-tests
197 (with-directory-excursion "src/test/java/org/usb4java"
198 ;; These tests should only be run when USB devices are present.
199 (substitute* '("LibUsbGlobalTest.java"
201 (("this.context = new Context\\(\\);")
202 "this.context = null;")
203 (("LibUsb.init") "//"))
204 (substitute* "DeviceListIteratorTest.java"
205 (("this.iterator.remove" line)
206 (string-append "assumeUsbTestsEnabled();" line))))
209 `(("libusb4java" ,libusb4java)
210 ("java-commons-lang3" ,java-commons-lang3)
211 ("java-junit" ,java-junit)
212 ("java-hamcrest-core" ,java-hamcrest-core)))
213 (home-page "http://usb4java.org/")
214 (synopsis "USB library for Java")
216 "This package provides a USB library for Java based on libusb and
217 implementing @code{javax.usb} (JSR-80).")
218 (license license:expat)))
220 (define-public python-libusb1
222 (name "python-libusb1")
227 (uri (pypi-uri "libusb1" version))
230 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
231 (build-system python-build-system)
233 `(#:modules ((srfi srfi-1)
235 (guix build python-build-system))
237 (modify-phases %standard-phases
238 (add-before 'install-license-files 'remove-incorrect-license
239 (lambda* (#:key out #:allow-other-keys)
240 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
241 ;; in source. Remove it so it does not get installed.
242 (delete-file "COPYING")
244 (add-after 'unpack 'fix-libusb-reference
245 (lambda* (#:key inputs #:allow-other-keys)
246 (substitute* "usb1/libusb1.py"
247 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
250 (find (negate symbolic-link?)
251 (find-files (assoc-ref inputs "libusb")
252 "^libusb.*\\.so\\..*"))
255 (inputs `(("libusb" ,libusb)))
256 (home-page "https://github.com/vpelletier/python-libusb1")
257 (synopsis "Pure-python wrapper for libusb-1.0")
258 (description "Libusb is a library that gives applications easy access to
259 USB devices on various operating systems. This package provides a Python
260 wrapper for accessing libusb-1.0.")
261 (license license:lgpl2.1+)))
263 (define-public python-pyusb
265 (name "python-pyusb")
270 (uri (pypi-uri "pyusb" version))
273 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
274 (build-system python-build-system)
276 `(#:tests? #f ; no tests
277 #:modules ((srfi srfi-1)
280 (guix build python-build-system))
282 (modify-phases %standard-phases
283 (add-after 'unpack 'fix-libusb-reference
284 (lambda* (#:key inputs #:allow-other-keys)
285 (substitute* "usb/libloader.py"
286 (("lib = locate_library\\(candidates, find_library\\)")
289 (find (negate symbolic-link?)
290 (find-files (assoc-ref inputs "libusb")
291 "^libusb-.*\\.so\\..*"))
295 `(("libusb" ,libusb)))
296 (home-page "https://pyusb.github.io/pyusb/")
297 (synopsis "Python bindings to the libusb library")
299 "PyUSB aims to be an easy to use Python module to access USB devices.")
300 (license license:bsd-3)))
302 (define-public python2-pyusb
303 (package-with-python2 python-pyusb))
305 (define-public libplist
313 (url "https://github.com/libimobiledevice/libplist.git")
315 (file-name (git-file-name name version))
317 (base32 "02vraf4j46bp746s0gz7vga2gv2dy3zd1v1bsy9x8algg9fpcb7n"))))
318 (build-system gnu-build-system)
321 (modify-phases %standard-phases
322 (add-before 'bootstrap 'configure-later
323 ;; Don't run ./configure during bootstrap.
325 (setenv "NOCONFIGURE" "set")
327 ;; Tests fail randomly when run in parallel because several of them write
328 ;; and read to/from the same file--e.g., "4.plist" is accessed by
329 ;; 'large.test' and 'largecmp.test'.
330 #:parallel-tests? #f))
332 `(("python" ,python)))
334 `(("autoconf" ,autoconf)
335 ("automake" ,automake)
337 ("pkg-config" ,pkg-config)
338 ("python-cython" ,python-cython))) ; to build Python bindings
339 (home-page "https://www.libimobiledevice.org/")
340 (synopsis "C library to handle Apple Property List files")
341 (description "This package provides a small portable C library to handle
342 Apple Property List files in binary or XML.")
343 (license license:lgpl2.1+)))
345 (define-public libusbmuxd
351 (uri (string-append "https://www.libimobiledevice.org/downloads/"
352 "libusbmuxd-" version ".tar.bz2"))
355 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
356 (build-system gnu-build-system)
358 `(("pkg-config" ,pkg-config)
359 ("libplist" ,libplist)))
360 (home-page "https://www.libimobiledevice.org/")
361 (synopsis "Library to multiplex connections from and to iOS devices")
362 (description "This package provides a client library to multiplex
363 connections from and to iOS devices by connecting to a socket provided by a
364 @code{usbmuxd} daemon.")
365 (license license:lgpl2.1+)))
367 (define-public libimobiledevice
369 (name "libimobiledevice")
373 (uri (string-append "https://www.libimobiledevice.org/downloads/"
374 "libimobiledevice-" version ".tar.bz2"))
377 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
378 (build-system gnu-build-system)
381 (list (string-append "PYTHON_LDFLAGS=-L"
382 (assoc-ref %build-inputs "python")
384 ,(version-major+minor (package-version python))
387 `(("openssl" ,openssl-1.0)
388 ("libplist" ,libplist)
389 ("libusbmuxd" ,libusbmuxd)))
391 `(("python" ,python)))
393 `(("pkg-config" ,pkg-config)
394 ("python-cython" ,python-cython)
395 ("libtool" ,libtool)))
396 (home-page "https://www.libimobiledevice.org/")
397 (synopsis "Protocol library and tools to communicate with Apple devices")
398 (description "libimobiledevice is a software library that talks the
399 protocols to support Apple devices. It allows other software to easily access
400 the device's file system, retrieve information about the device and its
401 internals, backup/restore the device, manage installed applications, retrieve
402 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
403 music and video to the device.")
404 (license license:lgpl2.1+)))
412 (uri (string-append "https://www.libimobiledevice.org/downloads/"
413 "ifuse-" version ".tar.bz2"))
416 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
419 ("libimobiledevice" ,libimobiledevice)))
421 `(("pkg-config" ,pkg-config)))
422 (build-system gnu-build-system)
423 (home-page "https://www.libimobiledevice.org/")
424 (synopsis "Mount iOS devices")
425 (description "This package provides @command{ifuse}, a command to mount
426 iOS devices and access their contents.")
427 (license license:lgpl2.1+)))
429 (define-public usbmuxd
435 (uri (string-append "https://www.libimobiledevice.org/downloads/"
436 "usbmuxd-" version ".tar.bz2"))
439 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
441 `(("libplist" ,libplist)
443 ("libimobiledevice" ,libimobiledevice)))
445 `(("pkg-config" ,pkg-config)))
446 (build-system gnu-build-system)
447 (home-page "https://www.libimobiledevice.org/")
448 (synopsis "Multiplex connections over USB to an iOS device")
449 (description "This package provides the @code{usbmuxd} daemon
450 which multiplexes connections over USB to an iOS device. To
451 users, it means you can sync your music, contacts, photos, etc.
453 (license license:gpl2+)))
455 (define-public libmtp
461 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
462 "/libmtp-" version ".tar.gz"))
465 "1p3r38nvdip40ab1h4scj3mzfjkx6kd14szjqyw9r6wz5pslr8zq"))))
466 (build-system gnu-build-system)
468 `(("pkg-config" ,pkg-config)))
470 `(("libgcrypt" ,libgcrypt)))
472 ;; libmtp.pc refers to all these.
473 `(("libusb" ,libusb)))
476 (list "--disable-static"
477 (string-append "--with-udev="
478 (assoc-ref %outputs "out")
480 (home-page "http://libmtp.sourceforge.net/")
481 (synopsis "Library implementing the Media Transfer Protocol")
482 (description "Libmtp implements an MTP (Media Transfer Protocol)
483 initiator, which means that it initiates MTP sessions with devices. The
484 devices responding are known as MTP responders. Libmtp runs on devices
485 with a USB host controller interface. It implements MTP Basic, which was
486 proposed for standardization.")
487 ;; COPYING contains lgpl2.1, while files headers give
488 ;; "GNU Lesser General Public License as published by the Free Software
489 ;; Foundation; either version 2 of the License, or (at your option) any
491 (license license:lgpl2.1+)))
499 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
500 "/gmtp-" version ".tar.gz"))
503 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
504 (build-system glib-or-gtk-build-system)
507 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
509 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
510 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
511 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
515 ("libvorbis" ,libvorbis)
516 ("libid3tag" ,libid3tag)
519 `(("pkg-config" ,pkg-config)))
520 (home-page "http://gmtp.sourceforge.net/")
521 (synopsis "Simple graphical MTP client")
522 (description "gMTP is a simple graphical client for the Media Transfer Protocol
523 (MTP), which allows media files to be transferred to and from many portable
525 (license license:bsd-3)))
527 (define-public hidapi
535 (url "https://github.com/libusb/hidapi.git")
536 (commit (string-append "hidapi-" version))))
537 (file-name (git-file-name name version))
539 (base32 "1p4g8lgwj4rki6lbn5l6rvwj0xlbn1xfh4d255bg5pvgczmwmc4i"))))
540 (build-system gnu-build-system)
545 `(("autoconf" ,autoconf)
546 ("automake" ,automake)
548 ("pkg-config" ,pkg-config)))
549 (home-page "https://github.com/libusb/hidapi")
550 (synopsis "HID API library")
552 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
554 ;; HIDAPI can be used under one of three licenses.
555 (license (list license:gpl3
557 (license:non-copyleft "file://LICENSE-orig.txt")))))
559 (define-public python-hidapi
561 (name "python-hidapi")
562 (version "0.7.99.post21")
566 (uri (pypi-uri "hidapi" version))
569 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
570 (modules '((guix build utils)))
572 ;; Remove bundled libraries.
574 (delete-file-recursively "hidapi")
576 (build-system python-build-system)
579 (modify-phases %standard-phases
580 (add-after 'unpack 'patch-configuration
581 (lambda* (#:key inputs #:allow-other-keys)
582 (substitute* "setup.py"
583 (("'/usr/include/libusb-1.0'")
584 (string-append "'" (assoc-ref inputs "libusb")
585 "/include/libusb-1.0'"))
586 (("'/usr/include/hidapi'")
587 (string-append "'" (assoc-ref inputs "hidapi")
588 "/include/hidapi'")))
590 ;; XXX Necessary because python-build-system drops the arguments.
593 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
596 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
598 (lambda* (#:key outputs #:allow-other-keys)
599 (invoke "python" "setup.py" "install" "--with-system-hidapi"
600 (string-append "--prefix=" (assoc-ref outputs "out"))
601 "--single-version-externally-managed" "--root=/"))))))
607 `(("python-cython" ,python-cython)))
608 (home-page "https://github.com/trezor/cython-hidapi")
609 (synopsis "Cython interface to hidapi")
610 (description "This package provides a Cython interface to @code{hidapi}.")
611 ;; The library can be used under either of these licenses.
612 (license (list license:gpl3
614 (license:non-copyleft
615 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
616 "You are free to use cython-hidapi code for any purpose.")))))
618 (define-public python2-hidapi
619 (package-with-python2 python-hidapi))