Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / libusb.scm
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 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
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.
18 ;;;
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.
23 ;;;
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/>.
26
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))
50
51 (define-public libusb
52 (package
53 (name "libusb")
54 (version "1.0.22")
55 (source
56 (origin
57 (method url-fetch)
58 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
59 "libusb-" version "/libusb-" version ".tar.bz2"))
60 (sha256
61 (base32
62 "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm"))))
63 (build-system gnu-build-system)
64
65 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
66 ;; libusb.
67 (arguments `(#:configure-flags '("--disable-udev")))
68 ;; (inputs `(("eudev" ,eudev)))
69
70 (home-page "https://libusb.info")
71 (synopsis "User-space USB library")
72 (description
73 "Libusb is a library that gives applications easy access to USB
74 devices on various operating systems.")
75 (license license:lgpl2.1+)))
76
77 (define-public libusb-compat
78 (package
79 (name "libusb-compat")
80 (version "0.1.5")
81 (source
82 (origin
83 (method url-fetch)
84 (uri (string-append "mirror://sourceforge/libusb/"
85 name "-" (version-major+minor version) "/"
86 name "-" version "/"
87 name "-" version ".tar.bz2"))
88 (sha256
89 (base32
90 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
91 (build-system gnu-build-system)
92 (native-inputs
93 `(("pkg-config" ,pkg-config)))
94 (inputs
95 `(("libusb" ,libusb)))
96 (home-page "https://libusb.info")
97 (synopsis "Compatibility shim for libusb")
98 (description
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+)))
102
103 ;; required by 0xffff, which compiles with libusb-compat, but executes only
104 ;; with libusb-0.1
105 (define-public libusb-0.1
106 (package (inherit libusb)
107 (version "0.1.12")
108 (source
109 (origin
110 (method url-fetch)
111 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
112 version "/libusb-" version ".tar.gz"))
113 (sha256
114 (base32
115 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
116 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
117
118 (define-public libusb4java
119 ;; There is no public release so we take the latest version from git.
120 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
121 (revision "1"))
122 (package
123 (name "libusb4java")
124 (version (string-append "0-" revision "." (string-take commit 9)))
125 (source (origin
126 (method git-fetch)
127 (uri (git-reference
128 (url "https://github.com/usb4java/libusb4java.git")
129 (commit commit)))
130 (file-name (git-file-name name version))
131 (sha256
132 (base32
133 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
134 (build-system cmake-build-system)
135 (arguments
136 `(#:tests? #f ; there are no tests
137 #:phases
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
142 (lambda _
143 (substitute* "CMakeLists.txt"
144 (("-Werror") ""))
145 #t))
146 (add-before 'configure 'set-JAVA_HOME
147 (lambda* (#:key inputs #:allow-other-keys)
148 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
149 #t)))))
150 (inputs
151 `(("libusb" ,libusb)))
152 (native-inputs
153 `(("jdk" ,icedtea "jdk")))
154 (home-page "https://github.com/usb4java/libusb4java/")
155 (synopsis "JNI bindings to libusb")
156 (description
157 "This package provides Java JNI bindings to the libusb library for use
158 with usb4java.")
159 (license license:expat))))
160
161 (define-public java-usb4java
162 (package
163 (name "java-usb4java")
164 (version "1.2.0")
165 (source (origin
166 (method url-fetch)
167 (uri (string-append "https://github.com/usb4java/usb4java/"
168 "archive/usb4java-" version ".tar.gz"))
169 (sha256
170 (base32
171 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
172 (build-system ant-build-system)
173 (arguments
174 `(#:jar-name "usb4java.jar"
175 #:phases
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)
188 (string-append
189 line "(final String a, final String b) {"
190 "return \""
191 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
192 "\"; }\n"
193 "private static String _extractLibrary")))
194 #t))
195 (add-after 'unpack 'disable-broken-tests
196 (lambda _
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"
200 "TransferTest.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))))
207 #t)))))
208 (inputs
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")
215 (description
216 "This package provides a USB library for Java based on libusb and
217 implementing @code{javax.usb} (JSR-80).")
218 (license license:expat)))
219
220 (define-public python-libusb1
221 (package
222 (name "python-libusb1")
223 (version "1.6.4")
224 (source
225 (origin
226 (method url-fetch)
227 (uri (pypi-uri "libusb1" version))
228 (sha256
229 (base32
230 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
231 (build-system python-build-system)
232 (arguments
233 `(#:modules ((srfi srfi-1)
234 (guix build utils)
235 (guix build python-build-system))
236 #:phases
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")
243 #t))
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\\)")
248 (string-append
249 "libusb_path = \""
250 (find (negate symbolic-link?)
251 (find-files (assoc-ref inputs "libusb")
252 "^libusb.*\\.so\\..*"))
253 "\"")))
254 #t)))))
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+)))
262
263 (define-public python-pyusb
264 (package
265 (name "python-pyusb")
266 (version "1.0.2")
267 (source
268 (origin
269 (method url-fetch)
270 (uri (pypi-uri "pyusb" version))
271 (sha256
272 (base32
273 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
274 (build-system python-build-system)
275 (arguments
276 `(#:tests? #f ; no tests
277 #:modules ((srfi srfi-1)
278 (srfi srfi-26)
279 (guix build utils)
280 (guix build python-build-system))
281 #:phases
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\\)")
287 (string-append
288 "lib = \""
289 (find (negate symbolic-link?)
290 (find-files (assoc-ref inputs "libusb")
291 "^libusb-.*\\.so\\..*"))
292 "\"")))
293 #t)))))
294 (inputs
295 `(("libusb" ,libusb)))
296 (home-page "https://pyusb.github.io/pyusb/")
297 (synopsis "Python bindings to the libusb library")
298 (description
299 "PyUSB aims to be an easy to use Python module to access USB devices.")
300 (license license:bsd-3)))
301
302 (define-public python2-pyusb
303 (package-with-python2 python-pyusb))
304
305 (define-public libplist
306 (package
307 (name "libplist")
308 (version "2.0.0")
309 (source (origin
310 (method url-fetch)
311 (uri (string-append "https://www.libimobiledevice.org/downloads/"
312 "libplist-" version ".tar.bz2"))
313 (sha256
314 (base32
315 "00pnh9zf3iwdji2faccns7vagbmbrwbj9a8zp9s53a6rqaa9czis"))))
316 (build-system gnu-build-system)
317 (arguments
318 ;; Tests fail randomly when run in parallel because several of them write
319 ;; and read to/from the same file--e.g., "4.plist" is accessed by
320 ;; 'large.test' and 'largecmp.test'.
321 '(#:parallel-tests? #f))
322 (inputs
323 `(("python" ,python)))
324 (native-inputs
325 `(("pkg-config" ,pkg-config)
326 ("python-cython" ,python-cython)))
327 (home-page "https://www.libimobiledevice.org/")
328 (synopsis "C library to handle Apple Property List files")
329 (description "This package provides a small portable C library to handle
330 Apple Property List files in binary or XML.")
331 (license license:lgpl2.1+)))
332
333 (define-public libusbmuxd
334 (package
335 (name "libusbmuxd")
336 (version "1.0.10")
337 (source (origin
338 (method url-fetch)
339 (uri (string-append "https://www.libimobiledevice.org/downloads/"
340 "libusbmuxd-" version ".tar.bz2"))
341 (sha256
342 (base32
343 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
344 (build-system gnu-build-system)
345 (native-inputs
346 `(("pkg-config" ,pkg-config)
347 ("libplist" ,libplist)))
348 (home-page "https://www.libimobiledevice.org/")
349 (synopsis "Library to multiplex connections from and to iOS devices")
350 (description "This package provides a client library to multiplex
351 connections from and to iOS devices by connecting to a socket provided by a
352 @code{usbmuxd} daemon.")
353 (license license:lgpl2.1+)))
354
355 (define-public libimobiledevice
356 (package
357 (name "libimobiledevice")
358 (version "1.2.0")
359 (source (origin
360 (method url-fetch)
361 (uri (string-append "https://www.libimobiledevice.org/downloads/"
362 "libimobiledevice-" version ".tar.bz2"))
363 (sha256
364 (base32
365 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
366 (build-system gnu-build-system)
367 (arguments
368 `(#:configure-flags
369 (list (string-append "PYTHON_LDFLAGS=-L"
370 (assoc-ref %build-inputs "python")
371 "/lib -lpython"
372 ,(version-major+minor (package-version python))
373 "m"))))
374 (propagated-inputs
375 `(("openssl" ,openssl-1.0)
376 ("libplist" ,libplist)
377 ("libusbmuxd" ,libusbmuxd)))
378 (inputs
379 `(("python" ,python)))
380 (native-inputs
381 `(("pkg-config" ,pkg-config)
382 ("python-cython" ,python-cython)
383 ("libtool" ,libtool)))
384 (home-page "https://www.libimobiledevice.org/")
385 (synopsis "Protocol library and tools to communicate with Apple devices")
386 (description "libimobiledevice is a software library that talks the
387 protocols to support Apple devices. It allows other software to easily access
388 the device's file system, retrieve information about the device and its
389 internals, backup/restore the device, manage installed applications, retrieve
390 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
391 music and video to the device.")
392 (license license:lgpl2.1+)))
393
394 (define-public ifuse
395 (package
396 (name "ifuse")
397 (version "1.1.3")
398 (source (origin
399 (method url-fetch)
400 (uri (string-append "https://www.libimobiledevice.org/downloads/"
401 "ifuse-" version ".tar.bz2"))
402 (sha256
403 (base32
404 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
405 (inputs
406 `(("fuse" ,fuse)
407 ("libimobiledevice" ,libimobiledevice)))
408 (native-inputs
409 `(("pkg-config" ,pkg-config)))
410 (build-system gnu-build-system)
411 (home-page "https://www.libimobiledevice.org/")
412 (synopsis "Mount iOS devices")
413 (description "This package provides @command{ifuse}, a command to mount
414 iOS devices and access their contents.")
415 (license license:lgpl2.1+)))
416
417 (define-public usbmuxd
418 (package
419 (name "usbmuxd")
420 (version "1.1.0")
421 (source (origin
422 (method url-fetch)
423 (uri (string-append "https://www.libimobiledevice.org/downloads/"
424 "usbmuxd-" version ".tar.bz2"))
425 (sha256
426 (base32
427 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
428 (inputs
429 `(("libplist" ,libplist)
430 ("libusb" ,libusb)
431 ("libimobiledevice" ,libimobiledevice)))
432 (native-inputs
433 `(("pkg-config" ,pkg-config)))
434 (build-system gnu-build-system)
435 (home-page "https://www.libimobiledevice.org/")
436 (synopsis "Multiplex connections over USB to an iOS device")
437 (description "This package provides the @code{usbmuxd} daemon
438 which multiplexes connections over USB to an iOS device. To
439 users, it means you can sync your music, contacts, photos, etc.
440 over USB.")
441 (license license:gpl2+)))
442
443 (define-public libmtp
444 (package
445 (name "libmtp")
446 (version "1.1.16")
447 (source (origin
448 (method url-fetch)
449 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
450 "/libmtp-" version ".tar.gz"))
451 (sha256
452 (base32
453 "185vh9bds6dcy00ycggg69g4v7m3api40zv8vrcfb3fk3vfzjs2v"))))
454 (build-system gnu-build-system)
455 (native-inputs
456 `(("pkg-config" ,pkg-config)))
457 (propagated-inputs
458 ;; libmtp.pc refers to all these.
459 `(("libgcrypt" ,libgcrypt)
460 ("libusb" ,libusb)))
461 (arguments
462 `(#:configure-flags
463 (list (string-append "--with-udev="
464 (assoc-ref %outputs "out")
465 "/lib/udev"))))
466 (home-page "http://libmtp.sourceforge.net/")
467 (synopsis "Library implementing the Media Transfer Protocol")
468 (description "Libmtp implements an MTP (Media Transfer Protocol)
469 initiator, which means that it initiates MTP sessions with devices. The
470 devices responding are known as MTP responders. Libmtp runs on devices
471 with a USB host controller interface. It implements MTP Basic, which was
472 proposed for standardization.")
473 ;; COPYING contains lgpl2.1, while files headers give
474 ;; "GNU Lesser General Public License as published by the Free Software
475 ;; Foundation; either version 2 of the License, or (at your option) any
476 ;; later version."
477 (license license:lgpl2.1+)))
478
479 (define-public gmtp
480 (package
481 (name "gmtp")
482 (version "1.3.11")
483 (source (origin
484 (method url-fetch)
485 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
486 "/gmtp-" version ".tar.gz"))
487 (sha256
488 (base32
489 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
490 (build-system glib-or-gtk-build-system)
491 (arguments
492 '(#:configure-flags
493 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
494 (list
495 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
496 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
497 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
498 (inputs
499 `(("gtk+" ,gtk+)
500 ("flac" ,flac)
501 ("libvorbis" ,libvorbis)
502 ("libid3tag" ,libid3tag)
503 ("libmtp" ,libmtp)))
504 (native-inputs
505 `(("pkg-config" ,pkg-config)))
506 (home-page "http://gmtp.sourceforge.net/")
507 (synopsis "Simple graphical MTP client")
508 (description "gMTP is a simple graphical client for the Media Transfer Protocol
509 (MTP), which allows media files to be transferred to and from many portable
510 devices.")
511 (license license:bsd-3)))
512
513 (define-public hidapi
514 (package
515 (name "hidapi")
516 (version "0.8.0-rc1")
517 (source (origin
518 (method url-fetch)
519 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
520 version ".tar.gz"))
521 (sha256
522 (base32
523 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
524 (build-system gnu-build-system)
525 (inputs
526 `(("libusb" ,libusb)
527 ("udev" ,eudev)))
528 (native-inputs
529 `(("autoconf" ,autoconf)
530 ("automake" ,automake)
531 ("libtool" ,libtool)
532 ("pkg-config" ,pkg-config)))
533 (home-page "http://www.signal11.us/oss/hidapi/")
534 (synopsis "HID API library")
535 (description
536 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
537 HID-Class devices.")
538 ;; HIDAPI can be used under one of three licenses.
539 (license (list license:gpl3
540 license:bsd-3
541 (license:non-copyleft "file://LICENSE-orig.txt")))))
542
543 (define-public python-hidapi
544 (package
545 (name "python-hidapi")
546 (version "0.7.99.post21")
547 (source
548 (origin
549 (method url-fetch)
550 (uri (pypi-uri "hidapi" version))
551 (sha256
552 (base32
553 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
554 (modules '((guix build utils)))
555 (snippet
556 ;; Remove bundled libraries.
557 '(begin
558 (delete-file-recursively "hidapi")
559 #t))))
560 (build-system python-build-system)
561 (arguments
562 `(#:phases
563 (modify-phases %standard-phases
564 (add-after 'unpack 'patch-configuration
565 (lambda* (#:key inputs #:allow-other-keys)
566 (substitute* "setup.py"
567 (("'/usr/include/libusb-1.0'")
568 (string-append "'" (assoc-ref inputs "libusb")
569 "/include/libusb-1.0'"))
570 (("'/usr/include/hidapi'")
571 (string-append "'" (assoc-ref inputs "hidapi")
572 "/include/hidapi'")))
573 #t))
574 ;; XXX Necessary because python-build-system drops the arguments.
575 (replace 'build
576 (lambda _
577 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
578 (replace 'check
579 (lambda _
580 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
581 (replace 'install
582 (lambda* (#:key outputs #:allow-other-keys)
583 (invoke "python" "setup.py" "install" "--with-system-hidapi"
584 (string-append "--prefix=" (assoc-ref outputs "out"))
585 "--single-version-externally-managed" "--root=/"))))))
586 (inputs
587 `(("hidapi" ,hidapi)
588 ("libusb" ,libusb)
589 ("eudev" ,eudev)))
590 (native-inputs
591 `(("python-cython" ,python-cython)))
592 (home-page "https://github.com/trezor/cython-hidapi")
593 (synopsis "Cython interface to hidapi")
594 (description "This package provides a Cython interface to @code{hidapi}.")
595 ;; The library can be used under either of these licenses.
596 (license (list license:gpl3
597 license:bsd-3
598 (license:non-copyleft
599 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
600 "You are free to use cython-hidapi code for any purpose.")))))
601
602 (define-public python2-hidapi
603 (package-with-python2 python-hidapi))