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>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages libusb)
26 #:use-module (gnu packages)
27 #:use-module (guix licenses)
28 #:use-module (guix packages)
29 #:use-module (guix utils)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system ant)
33 #:use-module (guix build-system cmake)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system glib-or-gtk)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages autotools)
38 #:use-module (gnu packages gnupg)
39 #:use-module (gnu packages gtk)
40 #:use-module (gnu packages java)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages mp3)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages xiph))
54 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
55 "libusb-" version "/libusb-" version ".tar.bz2"))
58 "0jw2n5kdnrqvp7zh792fd6mypzzfap6jp4gfcmq4n6c1kb79rkkx"))))
59 (build-system gnu-build-system)
61 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
63 (arguments `(#:configure-flags '("--disable-udev")))
64 ;; (inputs `(("eudev" ,eudev)))
66 (home-page "http://libusb.info")
67 (synopsis "User-space USB library")
69 "Libusb is a library that gives applications easy access to USB
70 devices on various operating systems.")
73 (define-public libusb-compat
75 (name "libusb-compat")
80 (uri (string-append "mirror://sourceforge/libusb/"
81 name "-" (version-major+minor version) "/"
83 name "-" version ".tar.bz2"))
86 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
87 (build-system gnu-build-system)
89 `(("pkg-config" ,pkg-config)))
91 `(("libusb" ,libusb)))
92 (home-page "http://libusb.info")
93 (synopsis "Compatibility shim for libusb")
95 "Libusb-compat provides a shim allowing applications based on older
96 version of libusb to run with newer libusb.")
99 ;; required by 0xffff, which compiles with libusb-compat, but executes only
101 (define-public libusb-0.1
102 (package (inherit libusb)
107 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
108 version "/libusb-" version ".tar.gz"))
111 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
112 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
114 (define-public libusb4java
115 ;; There is no public release so we take the latest version from git.
116 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
120 (version (string-append "0-" revision "." (string-take commit 9)))
124 (url "https://github.com/usb4java/libusb4java.git")
128 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
129 (build-system cmake-build-system)
131 `(#:tests? #f ; there are no tests
133 (modify-phases %standard-phases
134 (add-before 'configure 'set-JAVA_HOME
135 (lambda* (#:key inputs #:allow-other-keys)
136 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
139 `(("libusb" ,libusb)))
141 `(("jdk" ,icedtea "jdk")))
142 (home-page "https://github.com/usb4java/libusb4java/")
143 (synopsis "JNI bindings to libusb")
145 "This package provides Java JNI bindings to the libusb library for use
149 (define-public java-usb4java
151 (name "java-usb4java")
155 (uri (string-append "https://github.com/usb4java/usb4java/"
156 "archive/usb4java-" version ".tar.gz"))
159 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
160 (build-system ant-build-system)
162 `(#:jar-name "usb4java.jar"
164 (modify-phases %standard-phases
165 ;; Usually, native libusb4java libraries for all supported systems
166 ;; would be included in the jar and extracted at runtime. Since we
167 ;; build everything from source we cannot just bundle pre-built
168 ;; binaries for other systems. Instead, we patch the loader to
169 ;; directly return the appropriate library for this system. The
170 ;; downside is that the jar will only work on the same architecture
171 ;; that it was built on.
172 (add-after 'unpack 'copy-libusb4java
173 (lambda* (#:key inputs #:allow-other-keys)
174 (substitute* "src/main/java/org/usb4java/Loader.java"
175 (("private static String extractLibrary" line)
177 line "(final String a, final String b) {"
179 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
181 "private static String _extractLibrary")))
183 (add-after 'unpack 'disable-broken-tests
185 (with-directory-excursion "src/test/java/org/usb4java"
186 ;; These tests should only be run when USB devices are present.
187 (substitute* '("LibUsbGlobalTest.java"
189 (("this.context = new Context\\(\\);")
190 "this.context = null;")
191 (("LibUsb.init") "//"))
192 (substitute* "DeviceListIteratorTest.java"
193 (("this.iterator.remove" line)
194 (string-append "assumeUsbTestsEnabled();" line))))
197 `(("libusb4java" ,libusb4java)
198 ("java-commons-lang3" ,java-commons-lang3)
199 ("java-junit" ,java-junit)
200 ("java-hamcrest-core" ,java-hamcrest-core)))
201 (home-page "http://usb4java.org/")
202 (synopsis "USB library for Java")
204 "This package provides a USB library for Java based on libusb and
205 implementing @code{javax.usb} (JSR-80).")
208 (define-public python-pyusb
210 (name "python-pyusb")
215 (uri (pypi-uri "PyUSB" version))
218 "0s2k4z06fapd5vp1gnrlf8a9sjpc03p9974lzw5k6ky39akzyd2v"))))
219 (build-system python-build-system)
221 `(#:tests? #f ;no tests
222 #:modules ((srfi srfi-1)
225 (guix build python-build-system))
227 (modify-phases %standard-phases
228 (add-after 'unpack 'fix-libusb-reference
229 (lambda* (#:key inputs #:allow-other-keys)
230 (substitute* "usb/libloader.py"
231 (("lib = locate_library\\(candidates, find_library\\)")
234 (find (negate symbolic-link?)
235 (find-files (assoc-ref inputs "libusb")
236 "^libusb-.*\\.so\\..*"))
240 `(("libusb" ,libusb)))
241 (home-page "http://walac.github.io/pyusb/")
242 (synopsis "Python bindings to the libusb library")
244 "PyUSB aims to be an easy to use Python module to access USB devices.")
247 (define-public python2-pyusb
248 (package-with-python2 python-pyusb))
250 (define-public libmtp
256 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
257 "/libmtp-" version ".tar.gz"))
260 "0h3dv9py5mmvxhfxmkr8ky4s80hgq3d66cmrfnnnlcdwpwpy0kj9"))))
261 (build-system gnu-build-system)
263 `(("pkg-config" ,pkg-config)))
265 ;; libmtp.pc refers to all these.
266 `(("libgcrypt" ,libgcrypt)
270 (list (string-append "--with-udev="
271 (assoc-ref %outputs "out")
273 (home-page "http://libmtp.sourceforge.net/")
274 (synopsis "Library implementing the Media Transfer Protocol")
275 (description "Libmtp implements an MTP (Media Transfer Protocol)
276 initiator, which means that it initiates MTP sessions with devices. The
277 devices responding are known as MTP responders. Libmtp runs on devices
278 with a USB host controller interface. It implements MTP Basic, which was
279 proposed for standardization.")
280 ;; COPYING contains lgpl2.1, while files headers give
281 ;; "GNU Lesser General Public License as published by the Free Software
282 ;; Foundation; either version 2 of the License, or (at your option) any
292 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
293 "/gmtp-" version ".tar.gz"))
296 "0fyi3pdl2g57vr0p46ip2wwzyap3l0by7iqaqygv0yxfcs79l6xj"))))
297 (build-system glib-or-gtk-build-system)
300 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
302 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
303 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
304 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
308 ("libvorbis" ,libvorbis)
309 ("libid3tag" ,libid3tag)
312 `(("pkg-config" ,pkg-config)))
313 (home-page "http://gmtp.sourceforge.net/")
314 (synopsis "Simple graphical MTP client")
315 (description "gMTP is a simple graphical client for the Media Transfer Protocol
316 (MTP), which allows media files to be transferred to and from many portable
320 (define-public hidapi
323 (version "0.8.0-rc1")
326 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
330 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
331 (build-system gnu-build-system)
334 (modify-phases %standard-phases
335 (add-after 'unpack 'bootstrap
337 (zero? (system* "autoreconf" "-vfi")))))))
342 `(("autoconf" ,autoconf)
343 ("automake" ,automake)
345 ("pkg-config" ,pkg-config)))
346 (home-page "http://www.signal11.us/oss/hidapi/")
347 (synopsis "HID API library")
349 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
351 ;; HIDAPI can be used under one of three licenses.
354 (non-copyleft "file://LICENSE-orig.txt")))))
356 (define-public python-hidapi
358 (name "python-hidapi")
359 (version "0.7.99.post21")
363 (uri (pypi-uri "hidapi" version))
366 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
367 (modules '((guix build utils)))
369 ;; Remove bundled libraries.
371 (delete-file-recursively "hidapi")
373 (build-system python-build-system)
376 (modify-phases %standard-phases
377 (add-after 'unpack 'patch-configuration
378 (lambda* (#:key inputs #:allow-other-keys)
379 (substitute* "setup.py"
380 (("'/usr/include/libusb-1.0'")
381 (string-append "'" (assoc-ref inputs "libusb")
382 "/include/libusb-1.0'"))
383 (("'/usr/include/hidapi'")
384 (string-append "'" (assoc-ref inputs "hidapi")
385 "/include/hidapi'")))
387 ;; XXX Necessary because python-build-system drops the arguments.
390 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
393 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
395 (lambda* (#:key outputs #:allow-other-keys)
396 (invoke "python" "setup.py" "install" "--with-system-hidapi"
397 (string-append "--prefix=" (assoc-ref outputs "out"))
398 "--single-version-externally-managed" "--root=/"))))))
404 `(("python-cython" ,python-cython)))
405 (home-page "https://github.com/trezor/cython-hidapi")
406 (synopsis "Cython interface to hidapi")
407 (description "This package provides a Cython interface to @code{hidapi}.")
408 ;; The library can be used under either of these licenses.
409 (license (list gpl3 bsd-3
411 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
412 "You are free to use cython-hidapi code for any purpose.")))))
414 (define-public python2-hidapi
415 (package-with-python2 python-hidapi))