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>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages libusb)
27 #:use-module (gnu packages)
28 #:use-module (guix licenses)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix build-system ant)
34 #:use-module (guix build-system cmake)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system glib-or-gtk)
37 #:use-module (guix build-system python)
38 #:use-module (gnu packages autotools)
39 #:use-module (gnu packages gnupg)
40 #:use-module (gnu packages gtk)
41 #:use-module (gnu packages java)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages mp3)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages xiph))
55 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
56 "libusb-" version "/libusb-" version ".tar.bz2"))
59 "0jw2n5kdnrqvp7zh792fd6mypzzfap6jp4gfcmq4n6c1kb79rkkx"))))
60 (build-system gnu-build-system)
62 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
64 (arguments `(#:configure-flags '("--disable-udev")))
65 ;; (inputs `(("eudev" ,eudev)))
67 (home-page "http://libusb.info")
68 (synopsis "User-space USB library")
70 "Libusb is a library that gives applications easy access to USB
71 devices on various operating systems.")
74 (define-public libusb-compat
76 (name "libusb-compat")
81 (uri (string-append "mirror://sourceforge/libusb/"
82 name "-" (version-major+minor version) "/"
84 name "-" version ".tar.bz2"))
87 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
88 (build-system gnu-build-system)
90 `(("pkg-config" ,pkg-config)))
92 `(("libusb" ,libusb)))
93 (home-page "http://libusb.info")
94 (synopsis "Compatibility shim for libusb")
96 "Libusb-compat provides a shim allowing applications based on older
97 version of libusb to run with newer libusb.")
100 ;; required by 0xffff, which compiles with libusb-compat, but executes only
102 (define-public libusb-0.1
103 (package (inherit libusb)
108 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
109 version "/libusb-" version ".tar.gz"))
112 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
113 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
115 (define-public libusb4java
116 ;; There is no public release so we take the latest version from git.
117 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
121 (version (string-append "0-" revision "." (string-take commit 9)))
125 (url "https://github.com/usb4java/libusb4java.git")
127 (file-name (git-file-name name version))
130 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
131 (build-system cmake-build-system)
133 `(#:tests? #f ; there are no tests
135 (modify-phases %standard-phases
136 (add-before 'configure 'set-JAVA_HOME
137 (lambda* (#:key inputs #:allow-other-keys)
138 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
141 `(("libusb" ,libusb)))
143 `(("jdk" ,icedtea "jdk")))
144 (home-page "https://github.com/usb4java/libusb4java/")
145 (synopsis "JNI bindings to libusb")
147 "This package provides Java JNI bindings to the libusb library for use
151 (define-public java-usb4java
153 (name "java-usb4java")
157 (uri (string-append "https://github.com/usb4java/usb4java/"
158 "archive/usb4java-" version ".tar.gz"))
161 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
162 (build-system ant-build-system)
164 `(#:jar-name "usb4java.jar"
166 (modify-phases %standard-phases
167 ;; Usually, native libusb4java libraries for all supported systems
168 ;; would be included in the jar and extracted at runtime. Since we
169 ;; build everything from source we cannot just bundle pre-built
170 ;; binaries for other systems. Instead, we patch the loader to
171 ;; directly return the appropriate library for this system. The
172 ;; downside is that the jar will only work on the same architecture
173 ;; that it was built on.
174 (add-after 'unpack 'copy-libusb4java
175 (lambda* (#:key inputs #:allow-other-keys)
176 (substitute* "src/main/java/org/usb4java/Loader.java"
177 (("private static String extractLibrary" line)
179 line "(final String a, final String b) {"
181 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
183 "private static String _extractLibrary")))
185 (add-after 'unpack 'disable-broken-tests
187 (with-directory-excursion "src/test/java/org/usb4java"
188 ;; These tests should only be run when USB devices are present.
189 (substitute* '("LibUsbGlobalTest.java"
191 (("this.context = new Context\\(\\);")
192 "this.context = null;")
193 (("LibUsb.init") "//"))
194 (substitute* "DeviceListIteratorTest.java"
195 (("this.iterator.remove" line)
196 (string-append "assumeUsbTestsEnabled();" line))))
199 `(("libusb4java" ,libusb4java)
200 ("java-commons-lang3" ,java-commons-lang3)
201 ("java-junit" ,java-junit)
202 ("java-hamcrest-core" ,java-hamcrest-core)))
203 (home-page "http://usb4java.org/")
204 (synopsis "USB library for Java")
206 "This package provides a USB library for Java based on libusb and
207 implementing @code{javax.usb} (JSR-80).")
210 (define-public python-pyusb
212 (name "python-pyusb")
217 (uri (pypi-uri "PyUSB" version))
220 "0s2k4z06fapd5vp1gnrlf8a9sjpc03p9974lzw5k6ky39akzyd2v"))))
221 (build-system python-build-system)
223 `(#:tests? #f ;no tests
224 #:modules ((srfi srfi-1)
227 (guix build python-build-system))
229 (modify-phases %standard-phases
230 (add-after 'unpack 'fix-libusb-reference
231 (lambda* (#:key inputs #:allow-other-keys)
232 (substitute* "usb/libloader.py"
233 (("lib = locate_library\\(candidates, find_library\\)")
236 (find (negate symbolic-link?)
237 (find-files (assoc-ref inputs "libusb")
238 "^libusb-.*\\.so\\..*"))
242 `(("libusb" ,libusb)))
243 (home-page "http://walac.github.io/pyusb/")
244 (synopsis "Python bindings to the libusb library")
246 "PyUSB aims to be an easy to use Python module to access USB devices.")
249 (define-public python2-pyusb
250 (package-with-python2 python-pyusb))
252 (define-public libmtp
258 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
259 "/libmtp-" version ".tar.gz"))
262 "1s0jyhypxmj0j8s003ba1n74x63h1rw8am9q4z2ip3xyjvid65rq"))))
263 (build-system gnu-build-system)
265 `(("pkg-config" ,pkg-config)))
267 ;; libmtp.pc refers to all these.
268 `(("libgcrypt" ,libgcrypt)
272 (list (string-append "--with-udev="
273 (assoc-ref %outputs "out")
275 (home-page "http://libmtp.sourceforge.net/")
276 (synopsis "Library implementing the Media Transfer Protocol")
277 (description "Libmtp implements an MTP (Media Transfer Protocol)
278 initiator, which means that it initiates MTP sessions with devices. The
279 devices responding are known as MTP responders. Libmtp runs on devices
280 with a USB host controller interface. It implements MTP Basic, which was
281 proposed for standardization.")
282 ;; COPYING contains lgpl2.1, while files headers give
283 ;; "GNU Lesser General Public License as published by the Free Software
284 ;; Foundation; either version 2 of the License, or (at your option) any
294 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
295 "/gmtp-" version ".tar.gz"))
298 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
299 (build-system glib-or-gtk-build-system)
302 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
304 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
305 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
306 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
310 ("libvorbis" ,libvorbis)
311 ("libid3tag" ,libid3tag)
314 `(("pkg-config" ,pkg-config)))
315 (home-page "http://gmtp.sourceforge.net/")
316 (synopsis "Simple graphical MTP client")
317 (description "gMTP is a simple graphical client for the Media Transfer Protocol
318 (MTP), which allows media files to be transferred to and from many portable
322 (define-public hidapi
325 (version "0.8.0-rc1")
328 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
332 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
333 (build-system gnu-build-system)
336 (modify-phases %standard-phases
337 (add-after 'unpack 'bootstrap
339 (zero? (system* "autoreconf" "-vfi")))))))
344 `(("autoconf" ,autoconf)
345 ("automake" ,automake)
347 ("pkg-config" ,pkg-config)))
348 (home-page "http://www.signal11.us/oss/hidapi/")
349 (synopsis "HID API library")
351 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
353 ;; HIDAPI can be used under one of three licenses.
356 (non-copyleft "file://LICENSE-orig.txt")))))
358 (define-public python-hidapi
360 (name "python-hidapi")
361 (version "0.7.99.post21")
365 (uri (pypi-uri "hidapi" version))
368 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
369 (modules '((guix build utils)))
371 ;; Remove bundled libraries.
373 (delete-file-recursively "hidapi")
375 (build-system python-build-system)
378 (modify-phases %standard-phases
379 (add-after 'unpack 'patch-configuration
380 (lambda* (#:key inputs #:allow-other-keys)
381 (substitute* "setup.py"
382 (("'/usr/include/libusb-1.0'")
383 (string-append "'" (assoc-ref inputs "libusb")
384 "/include/libusb-1.0'"))
385 (("'/usr/include/hidapi'")
386 (string-append "'" (assoc-ref inputs "hidapi")
387 "/include/hidapi'")))
389 ;; XXX Necessary because python-build-system drops the arguments.
392 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
395 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
397 (lambda* (#:key outputs #:allow-other-keys)
398 (invoke "python" "setup.py" "install" "--with-system-hidapi"
399 (string-append "--prefix=" (assoc-ref outputs "out"))
400 "--single-version-externally-managed" "--root=/"))))))
406 `(("python-cython" ,python-cython)))
407 (home-page "https://github.com/trezor/cython-hidapi")
408 (synopsis "Cython interface to hidapi")
409 (description "This package provides a Cython interface to @code{hidapi}.")
410 ;; The library can be used under either of these licenses.
411 (license (list gpl3 bsd-3
413 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
414 "You are free to use cython-hidapi code for any purpose.")))))
416 (define-public python2-hidapi
417 (package-with-python2 python-hidapi))