gnu: Add libusbmuxd.
[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 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 xiph))
49
50 (define-public libusb
51 (package
52 (name "libusb")
53 (version "1.0.22")
54 (source
55 (origin
56 (method url-fetch)
57 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
58 "libusb-" version "/libusb-" version ".tar.bz2"))
59 (sha256
60 (base32
61 "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm"))))
62 (build-system gnu-build-system)
63
64 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
65 ;; libusb.
66 (arguments `(#:configure-flags '("--disable-udev")))
67 ;; (inputs `(("eudev" ,eudev)))
68
69 (home-page "https://libusb.info")
70 (synopsis "User-space USB library")
71 (description
72 "Libusb is a library that gives applications easy access to USB
73 devices on various operating systems.")
74 (license license:lgpl2.1+)))
75
76 (define-public libusb-compat
77 (package
78 (name "libusb-compat")
79 (version "0.1.5")
80 (source
81 (origin
82 (method url-fetch)
83 (uri (string-append "mirror://sourceforge/libusb/"
84 name "-" (version-major+minor version) "/"
85 name "-" version "/"
86 name "-" version ".tar.bz2"))
87 (sha256
88 (base32
89 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
90 (build-system gnu-build-system)
91 (native-inputs
92 `(("pkg-config" ,pkg-config)))
93 (inputs
94 `(("libusb" ,libusb)))
95 (home-page "https://libusb.info")
96 (synopsis "Compatibility shim for libusb")
97 (description
98 "Libusb-compat provides a shim allowing applications based on older
99 version of libusb to run with newer libusb.")
100 (license license:lgpl2.1+)))
101
102 ;; required by 0xffff, which compiles with libusb-compat, but executes only
103 ;; with libusb-0.1
104 (define-public libusb-0.1
105 (package (inherit libusb)
106 (version "0.1.12")
107 (source
108 (origin
109 (method url-fetch)
110 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
111 version "/libusb-" version ".tar.gz"))
112 (sha256
113 (base32
114 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
115 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
116
117 (define-public libusb4java
118 ;; There is no public release so we take the latest version from git.
119 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
120 (revision "1"))
121 (package
122 (name "libusb4java")
123 (version (string-append "0-" revision "." (string-take commit 9)))
124 (source (origin
125 (method git-fetch)
126 (uri (git-reference
127 (url "https://github.com/usb4java/libusb4java.git")
128 (commit commit)))
129 (file-name (git-file-name name version))
130 (sha256
131 (base32
132 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
133 (build-system cmake-build-system)
134 (arguments
135 `(#:tests? #f ; there are no tests
136 #:phases
137 (modify-phases %standard-phases
138 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
139 ;; fails because libusb4java uses a deprecated procedure.
140 (add-after 'unpack 'disable-Werror
141 (lambda _
142 (substitute* "CMakeLists.txt"
143 (("-Werror") ""))
144 #t))
145 (add-before 'configure 'set-JAVA_HOME
146 (lambda* (#:key inputs #:allow-other-keys)
147 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
148 #t)))))
149 (inputs
150 `(("libusb" ,libusb)))
151 (native-inputs
152 `(("jdk" ,icedtea "jdk")))
153 (home-page "https://github.com/usb4java/libusb4java/")
154 (synopsis "JNI bindings to libusb")
155 (description
156 "This package provides Java JNI bindings to the libusb library for use
157 with usb4java.")
158 (license license:expat))))
159
160 (define-public java-usb4java
161 (package
162 (name "java-usb4java")
163 (version "1.2.0")
164 (source (origin
165 (method url-fetch)
166 (uri (string-append "https://github.com/usb4java/usb4java/"
167 "archive/usb4java-" version ".tar.gz"))
168 (sha256
169 (base32
170 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
171 (build-system ant-build-system)
172 (arguments
173 `(#:jar-name "usb4java.jar"
174 #:phases
175 (modify-phases %standard-phases
176 ;; Usually, native libusb4java libraries for all supported systems
177 ;; would be included in the jar and extracted at runtime. Since we
178 ;; build everything from source we cannot just bundle pre-built
179 ;; binaries for other systems. Instead, we patch the loader to
180 ;; directly return the appropriate library for this system. The
181 ;; downside is that the jar will only work on the same architecture
182 ;; that it was built on.
183 (add-after 'unpack 'copy-libusb4java
184 (lambda* (#:key inputs #:allow-other-keys)
185 (substitute* "src/main/java/org/usb4java/Loader.java"
186 (("private static String extractLibrary" line)
187 (string-append
188 line "(final String a, final String b) {"
189 "return \""
190 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
191 "\"; }\n"
192 "private static String _extractLibrary")))
193 #t))
194 (add-after 'unpack 'disable-broken-tests
195 (lambda _
196 (with-directory-excursion "src/test/java/org/usb4java"
197 ;; These tests should only be run when USB devices are present.
198 (substitute* '("LibUsbGlobalTest.java"
199 "TransferTest.java")
200 (("this.context = new Context\\(\\);")
201 "this.context = null;")
202 (("LibUsb.init") "//"))
203 (substitute* "DeviceListIteratorTest.java"
204 (("this.iterator.remove" line)
205 (string-append "assumeUsbTestsEnabled();" line))))
206 #t)))))
207 (inputs
208 `(("libusb4java" ,libusb4java)
209 ("java-commons-lang3" ,java-commons-lang3)
210 ("java-junit" ,java-junit)
211 ("java-hamcrest-core" ,java-hamcrest-core)))
212 (home-page "http://usb4java.org/")
213 (synopsis "USB library for Java")
214 (description
215 "This package provides a USB library for Java based on libusb and
216 implementing @code{javax.usb} (JSR-80).")
217 (license license:expat)))
218
219 (define-public python-libusb1
220 (package
221 (name "python-libusb1")
222 (version "1.6.4")
223 (source
224 (origin
225 (method url-fetch)
226 (uri (pypi-uri "libusb1" version))
227 (sha256
228 (base32
229 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
230 (build-system python-build-system)
231 (arguments
232 `(#:modules ((srfi srfi-1)
233 (guix build utils)
234 (guix build python-build-system))
235 #:phases
236 (modify-phases %standard-phases
237 (add-before 'install-license-files 'remove-incorrect-license
238 (lambda* (#:key out #:allow-other-keys)
239 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
240 ;; in source. Remove it so it does not get installed.
241 (delete-file "COPYING")
242 #t))
243 (add-after 'unpack 'fix-libusb-reference
244 (lambda* (#:key inputs #:allow-other-keys)
245 (substitute* "usb1/libusb1.py"
246 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
247 (string-append
248 "libusb_path = \""
249 (find (negate symbolic-link?)
250 (find-files (assoc-ref inputs "libusb")
251 "^libusb.*\\.so\\..*"))
252 "\"")))
253 #t)))))
254 (inputs `(("libusb" ,libusb)))
255 (home-page "https://github.com/vpelletier/python-libusb1")
256 (synopsis "Pure-python wrapper for libusb-1.0")
257 (description "Libusb is a library that gives applications easy access to
258 USB devices on various operating systems. This package provides a Python
259 wrapper for accessing libusb-1.0.")
260 (license license:lgpl2.1+)))
261
262 (define-public python-pyusb
263 (package
264 (name "python-pyusb")
265 (version "1.0.2")
266 (source
267 (origin
268 (method url-fetch)
269 (uri (pypi-uri "pyusb" version))
270 (sha256
271 (base32
272 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
273 (build-system python-build-system)
274 (arguments
275 `(#:tests? #f ; no tests
276 #:modules ((srfi srfi-1)
277 (srfi srfi-26)
278 (guix build utils)
279 (guix build python-build-system))
280 #:phases
281 (modify-phases %standard-phases
282 (add-after 'unpack 'fix-libusb-reference
283 (lambda* (#:key inputs #:allow-other-keys)
284 (substitute* "usb/libloader.py"
285 (("lib = locate_library\\(candidates, find_library\\)")
286 (string-append
287 "lib = \""
288 (find (negate symbolic-link?)
289 (find-files (assoc-ref inputs "libusb")
290 "^libusb-.*\\.so\\..*"))
291 "\"")))
292 #t)))))
293 (inputs
294 `(("libusb" ,libusb)))
295 (home-page "https://pyusb.github.io/pyusb/")
296 (synopsis "Python bindings to the libusb library")
297 (description
298 "PyUSB aims to be an easy to use Python module to access USB devices.")
299 (license license:bsd-3)))
300
301 (define-public python2-pyusb
302 (package-with-python2 python-pyusb))
303
304 (define-public libplist
305 (package
306 (name "libplist")
307 (version "2.0.0")
308 (source (origin
309 (method url-fetch)
310 (uri (string-append "http://www.libimobiledevice.org/downloads/"
311 "libplist-" version ".tar.bz2"))
312 (sha256
313 (base32
314 "00pnh9zf3iwdji2faccns7vagbmbrwbj9a8zp9s53a6rqaa9czis"))))
315 (build-system gnu-build-system)
316 (inputs
317 `(("python" ,python)))
318 (native-inputs
319 `(("pkg-config" ,pkg-config)
320 ("python-cython" ,python-cython)))
321 (home-page "http://www.libimobiledevice.org/")
322 (synopsis "C library to handle Apple Property List files")
323 (description "This package provides a small portable C library to handle
324 Apple Property List files in binary or XML.")
325 (license license:lgpl2.1+)))
326
327 (define-public libusbmuxd
328 (package
329 (name "libusbmuxd")
330 (version "1.0.10")
331 (source (origin
332 (method url-fetch)
333 (uri (string-append "http://www.libimobiledevice.org/downloads/"
334 "libusbmuxd-" version ".tar.bz2"))
335 (sha256
336 (base32
337 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
338 (build-system gnu-build-system)
339 (native-inputs
340 `(("pkg-config" ,pkg-config)
341 ("libplist" ,libplist)))
342 (home-page "http://www.libimobiledevice.org/")
343 (synopsis "Library to multiplex connections from and to iOS devices")
344 (description "This package provides a client library to multiplex
345 connections from and to iOS devices by connecting to a socket provided by a
346 @code{usbmuxd} daemon.")
347 (license license:lgpl2.1+)))
348
349 (define-public libmtp
350 (package
351 (name "libmtp")
352 (version "1.1.16")
353 (source (origin
354 (method url-fetch)
355 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
356 "/libmtp-" version ".tar.gz"))
357 (sha256
358 (base32
359 "185vh9bds6dcy00ycggg69g4v7m3api40zv8vrcfb3fk3vfzjs2v"))))
360 (build-system gnu-build-system)
361 (native-inputs
362 `(("pkg-config" ,pkg-config)))
363 (propagated-inputs
364 ;; libmtp.pc refers to all these.
365 `(("libgcrypt" ,libgcrypt)
366 ("libusb" ,libusb)))
367 (arguments
368 `(#:configure-flags
369 (list (string-append "--with-udev="
370 (assoc-ref %outputs "out")
371 "/lib/udev"))))
372 (home-page "http://libmtp.sourceforge.net/")
373 (synopsis "Library implementing the Media Transfer Protocol")
374 (description "Libmtp implements an MTP (Media Transfer Protocol)
375 initiator, which means that it initiates MTP sessions with devices. The
376 devices responding are known as MTP responders. Libmtp runs on devices
377 with a USB host controller interface. It implements MTP Basic, which was
378 proposed for standardization.")
379 ;; COPYING contains lgpl2.1, while files headers give
380 ;; "GNU Lesser General Public License as published by the Free Software
381 ;; Foundation; either version 2 of the License, or (at your option) any
382 ;; later version."
383 (license license:lgpl2.1+)))
384
385 (define-public gmtp
386 (package
387 (name "gmtp")
388 (version "1.3.11")
389 (source (origin
390 (method url-fetch)
391 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
392 "/gmtp-" version ".tar.gz"))
393 (sha256
394 (base32
395 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
396 (build-system glib-or-gtk-build-system)
397 (arguments
398 '(#:configure-flags
399 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
400 (list
401 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
402 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
403 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
404 (inputs
405 `(("gtk+" ,gtk+)
406 ("flac" ,flac)
407 ("libvorbis" ,libvorbis)
408 ("libid3tag" ,libid3tag)
409 ("libmtp" ,libmtp)))
410 (native-inputs
411 `(("pkg-config" ,pkg-config)))
412 (home-page "http://gmtp.sourceforge.net/")
413 (synopsis "Simple graphical MTP client")
414 (description "gMTP is a simple graphical client for the Media Transfer Protocol
415 (MTP), which allows media files to be transferred to and from many portable
416 devices.")
417 (license license:bsd-3)))
418
419 (define-public hidapi
420 (package
421 (name "hidapi")
422 (version "0.8.0-rc1")
423 (source (origin
424 (method url-fetch)
425 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
426 version ".tar.gz"))
427 (sha256
428 (base32
429 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
430 (build-system gnu-build-system)
431 (inputs
432 `(("libusb" ,libusb)
433 ("udev" ,eudev)))
434 (native-inputs
435 `(("autoconf" ,autoconf)
436 ("automake" ,automake)
437 ("libtool" ,libtool)
438 ("pkg-config" ,pkg-config)))
439 (home-page "http://www.signal11.us/oss/hidapi/")
440 (synopsis "HID API library")
441 (description
442 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
443 HID-Class devices.")
444 ;; HIDAPI can be used under one of three licenses.
445 (license (list license:gpl3
446 license:bsd-3
447 (license:non-copyleft "file://LICENSE-orig.txt")))))
448
449 (define-public python-hidapi
450 (package
451 (name "python-hidapi")
452 (version "0.7.99.post21")
453 (source
454 (origin
455 (method url-fetch)
456 (uri (pypi-uri "hidapi" version))
457 (sha256
458 (base32
459 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
460 (modules '((guix build utils)))
461 (snippet
462 ;; Remove bundled libraries.
463 '(begin
464 (delete-file-recursively "hidapi")
465 #t))))
466 (build-system python-build-system)
467 (arguments
468 `(#:phases
469 (modify-phases %standard-phases
470 (add-after 'unpack 'patch-configuration
471 (lambda* (#:key inputs #:allow-other-keys)
472 (substitute* "setup.py"
473 (("'/usr/include/libusb-1.0'")
474 (string-append "'" (assoc-ref inputs "libusb")
475 "/include/libusb-1.0'"))
476 (("'/usr/include/hidapi'")
477 (string-append "'" (assoc-ref inputs "hidapi")
478 "/include/hidapi'")))
479 #t))
480 ;; XXX Necessary because python-build-system drops the arguments.
481 (replace 'build
482 (lambda _
483 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
484 (replace 'check
485 (lambda _
486 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
487 (replace 'install
488 (lambda* (#:key outputs #:allow-other-keys)
489 (invoke "python" "setup.py" "install" "--with-system-hidapi"
490 (string-append "--prefix=" (assoc-ref outputs "out"))
491 "--single-version-externally-managed" "--root=/"))))))
492 (inputs
493 `(("hidapi" ,hidapi)
494 ("libusb" ,libusb)
495 ("eudev" ,eudev)))
496 (native-inputs
497 `(("python-cython" ,python-cython)))
498 (home-page "https://github.com/trezor/cython-hidapi")
499 (synopsis "Cython interface to hidapi")
500 (description "This package provides a Cython interface to @code{hidapi}.")
501 ;; The library can be used under either of these licenses.
502 (license (list license:gpl3
503 license:bsd-3
504 (license:non-copyleft
505 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
506 "You are free to use cython-hidapi code for any purpose.")))))
507
508 (define-public python2-hidapi
509 (package-with-python2 python-hidapi))