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