build-system/r: Update to Bioconductor 3.7.
[jackhill/guix/guix.git] / gnu / packages / android.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Stefan Handschuh <handschuh.stefan@googlemail.com>
3 ;;; Copyright © 2015 Kai-Chung Yan <seamlikok@gmail.com>
4 ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
6 ;;; Copyright © 2017 Hartmut Goebel <h.goebel@crazy-compilers.com>
7 ;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
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.
16 ;;;
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.
21 ;;;
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/>.
24
25 (define-module (gnu packages android)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system android-ndk)
31 #:use-module (guix build-system python)
32 #:use-module (guix build-system trivial)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages check)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages gnupg)
38 #:use-module (gnu packages pcre)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages selinux)
41 #:use-module (gnu packages ssh)
42 #:use-module (gnu packages version-control)
43 #:use-module (gnu packages tls)
44 #:use-module (gnu packages linux))
45
46 (define-public android-make-stub
47 (package
48 (name "android-make-stub")
49 (version "0.6.0")
50 (source
51 (origin
52 (method git-fetch)
53 (uri (git-reference
54 (url "https://github.com/daym/android-make-stub.git")
55 (commit (string-append "v" version))))
56 (file-name (string-append "android-make-stub-"
57 version "-checkout"))
58 (sha256
59 (base32
60 "0y1b2x96d37n6f1bp6dcx08bn08zac0cylmbfsx6mf2nahc02fhc"))))
61 (build-system gnu-build-system)
62 (arguments
63 `(#:tests? #f ; None exist.
64 #:phases
65 (modify-phases %standard-phases
66 (delete 'configure)
67 (delete 'build)
68 (replace 'install
69 (lambda* (#:key outputs #:allow-other-keys)
70 (let* ((out (assoc-ref outputs "out")))
71 (invoke "make" (string-append "prefix=" out) "install")
72 #t))))))
73 (home-page "https://github.com/daym/android-make-stub")
74 (synopsis "Stubs for the @command{make} system of the Android platform")
75 (description "@code{android-make-stub} provides stubs for the
76 @command{make} system of the Android platform. This allows us to
77 use their packages mostly unmodified in our Android NDK build system.")
78 (license license:asl2.0)))
79
80 (define-public android-googletest
81 (package (inherit googletest)
82 (name "android-googletest")
83 (arguments
84 `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")
85 #:phases
86 (modify-phases %standard-phases
87 (add-after 'install 'install-host-libraries
88 (lambda* (#:key outputs #:allow-other-keys)
89 (let* ((out (assoc-ref outputs "out"))
90 (lib (string-append out "/lib")))
91 (symlink "libgtest.so"
92 (string-append lib "/libgtest_host.so"))
93 (symlink "libgmock.so"
94 (string-append lib "/libgmock_host.so"))
95 #t))))))))
96
97 ;; The Makefiles that we add are largely based on the Debian
98 ;; packages. They are licensed under GPL-2 and have copyright:
99 ;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
100 ;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
101 ;; Big thanks to them for laying the groundwork.
102
103 ;; The version tag is consistent between all repositories.
104 (define (android-platform-version) "7.1.2_r6")
105
106 (define (android-platform-system-core version)
107 (origin
108 (method git-fetch)
109 (uri (git-reference
110 (url "https://android.googlesource.com/platform/system/core")
111 (commit (string-append "android-" version))))
112 (file-name (string-append "android-platform-system-core-"
113 version "-checkout"))
114 (sha256
115 (base32
116 "0xc2n7jxrf1iw9cc278pijdfjix2fkiig5ws27f6rwp40zg5mrgg"))
117 (patches
118 (search-patches "libbase-use-own-logging.patch"
119 "libbase-fix-includes.patch"
120 "libutils-remove-damaging-includes.patch"
121 "libutils-add-includes.patch"
122 "adb-add-libraries.patch"
123 "libziparchive-add-includes.patch"))))
124
125 (define (android-platform-system-extras version)
126 (origin
127 (method git-fetch)
128 (uri (git-reference
129 (url "https://android.googlesource.com/platform/system/extras")
130 (commit (string-append "android-" version))))
131 (file-name (string-append "android-platform-system-extras-"
132 version "-checkout"))
133 (sha256
134 (base32
135 "18130c23ybqcpgjc5v6f8kdbv2xn39hyiaj17dzldjb9rlwzcyy9"))))
136
137 (define (android-platform-bionic version)
138 (origin
139 (method git-fetch)
140 (uri (git-reference
141 (url "https://android.googlesource.com/platform/bionic")
142 (commit (string-append "android-" version))))
143 (file-name (string-append "android-platform-bionic-"
144 version "-checkout"))
145 (sha256
146 (base32
147 "0n9wkz3ynqw39if1ss9n32m66iga14nndf29hpm7g1aqn4wvvgzk"))))
148
149 (define (android-platform-external version subdirectory checksum)
150 (origin
151 (method git-fetch)
152 (uri (git-reference
153 (url
154 (string-append "https://android.googlesource.com/platform/external/"
155 subdirectory))
156 (commit (string-append "android-" version))))
157 (file-name (string-append "android-platform-system-external-" subdirectory "-"
158 version "-checkout"))
159 (sha256
160 (base32
161 checksum))))
162
163 (define android-liblog
164 (package
165 (name "android-liblog")
166 (version (android-platform-version))
167 (source (android-platform-system-core version))
168 (build-system android-ndk-build-system)
169 (arguments
170 `(#:make-flags '("LDLIBS=-lpthread")
171 #:phases
172 (modify-phases %standard-phases
173 (add-after 'unpack 'enter-source
174 (lambda _ (chdir "liblog") #t))
175 (add-after 'install 'ldconfig
176 (lambda* (#:key outputs #:allow-other-keys)
177 (let ((out (assoc-ref outputs "out")))
178 (symlink "liblog.so.0" (string-append out "/lib/liblog.so"))
179 #t))))))
180 (home-page "https://developer.android.com/")
181 (synopsis "Logging library from the Android platform.")
182 (description "@code{liblog} represents an interface to the volatile Android
183 Logging system for NDK (Native) applications and libraries and contain
184 interfaces for either writing or reading logs. The log buffers are divided up
185 in Main, System, Radio and Events sub-logs.")
186 (license license:asl2.0)))
187
188 (define android-libbase
189 (package
190 (name "android-libbase")
191 (version (android-platform-version))
192 (source (android-platform-system-core version))
193 (build-system android-ndk-build-system)
194 (arguments
195 `(#:tests? #f ; Test failure: logging.UNIMPLEMENTED
196 #:make-flags '("CXXFLAGS=-std=gnu++11")
197 #:phases
198 (modify-phases %standard-phases
199 (add-after 'unpack 'enter-source
200 (lambda _ (chdir "base") #t)))))
201 (inputs `(("android-liblog" ,android-liblog)))
202 (home-page "https://developer.android.com/")
203 (synopsis "Android platform base library")
204 (description "@code{libbase} is a library in common use by the
205 various Android core host applications.")
206 (license license:asl2.0)))
207
208 (define android-libcutils
209 (package
210 (name "android-libcutils")
211 (version (android-platform-version))
212 (source (android-platform-system-core version))
213 (build-system gnu-build-system)
214 (arguments
215 `(#:tests? #f ; TODO.
216 #:phases
217 (modify-phases %standard-phases
218 (add-after 'unpack 'enter-source
219 (lambda _ (chdir "libcutils") #t))
220 (add-after 'enter-source 'create-Makefile
221 (lambda _
222 ;; No useful makefile is shipped, so we create one.
223 (with-output-to-file "Makefile"
224 (lambda _
225 (display
226 (string-append
227 "NAME = libcutils\n"
228 "SOURCES = load_file.o socket_local_client_unix.o"
229 " socket_loopback_client_unix.o socket_network_client_unix.o"
230 " socket_loopback_server_unix.o socket_local_server_unix.o"
231 " sockets_unix.o socket_inaddr_any_server_unix.o"
232 " sockets.o\n"
233 "CC = gcc\n"
234
235 "CFLAGS += -fPIC\n"
236 "CXXFLAGS += -std=gnu++11 -fPIC\n"
237 "CPPFLAGS += -Iinclude -I../include\n"
238 "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
239
240 "build: $(SOURCES)\n"
241 " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)"
242 " $(LDFLAGS)\n"))
243 #t))))
244 (delete 'configure)
245 (replace 'install
246 (lambda* (#:key outputs #:allow-other-keys)
247 (let* ((out (assoc-ref outputs "out"))
248 (lib (string-append out "/lib"))
249 (include (string-append out "/include")))
250 (install-file "libcutils.so.0" lib)
251 (with-directory-excursion lib
252 (symlink "libcutils.so.0" "libcutils.so"))
253 (copy-recursively "../include/cutils"
254 (string-append include "/cutils"))
255 #t))))))
256 (home-page "https://developer.android.com/")
257 (synopsis "Android platform c utils library")
258 (description "@code{libcutils} is a library in common use by the
259 various Android core host applications.")
260 (license license:asl2.0)))
261
262 (define-public android-libsparse
263 (package
264 (name "android-libsparse")
265 (version (android-platform-version))
266 (source (android-platform-system-core version))
267 (build-system android-ndk-build-system)
268 (arguments
269 `(#:make-flags '("CFLAGS=-Wno-error"
270 "CXXFLAGS=-fpermissive -Wno-error")
271 #:phases
272 (modify-phases %standard-phases
273 (add-after 'unpack 'enter-source
274 (lambda _ (chdir "libsparse") #t)))))
275 (inputs
276 `(("zlib" ,zlib)))
277 (home-page "https://developer.android.com/")
278 (synopsis "Android platform sparse library")
279 (description "@code{android-libsparse} is a library in common use by the
280 various Android core host applications.")
281 (license license:asl2.0)))
282
283 (define-public android-libziparchive
284 (package
285 (name "android-libziparchive")
286 (version (android-platform-version))
287 (source (android-platform-system-core version))
288 (build-system android-ndk-build-system)
289 (arguments
290 `(#:make-flags '("CFLAGS=-Wno-error"
291 "CXXFLAGS=-fpermissive -Wno-error -std=gnu++11")
292 #:phases
293 (modify-phases %standard-phases
294 (add-after 'unpack 'enter-source
295 (lambda _ (chdir "libziparchive") #t))
296 (add-before 'check 'setenv
297 (lambda _
298 (setenv "ziparchive_tests_host_PARAMS" "--test_data_dir=testdata")
299 #t))
300 (add-after 'install 'install-headers
301 (lambda* (#:key inputs outputs #:allow-other-keys)
302 (let ((out (assoc-ref outputs "out")))
303 (copy-recursively "../include/ziparchive"
304 (string-append out "/include/ziparchive"))
305 #t))))))
306 (inputs
307 `(("zlib" ,zlib)))
308 (native-inputs
309 `(("android-libbase" ,android-libbase)
310 ("android-libutils" ,android-libutils)
311 ("android-liblog" ,android-liblog)))
312 (home-page "https://developer.android.com/")
313 (synopsis "Android platform ZIP library")
314 (description "@code{android-libziparchive} is a library in common use by the
315 various Android core host applications.")
316 (license license:asl2.0)))
317
318 (define-public adb
319 (package
320 (name "adb")
321 (version (android-platform-version))
322 (source (android-platform-system-core version))
323 (build-system android-ndk-build-system)
324 (arguments
325 `(#:tests? #f ; Test failure: sysdeps_poll.fd_count
326 #:make-flags
327 (list "CFLAGS=-Wno-error"
328 "CXXFLAGS=-fpermissive -Wno-error -std=gnu++14 -D_Nonnull= -D_Nullable= -I ."
329 (string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out") "/lib "
330 "-Wl,-rpath=" (assoc-ref %build-inputs "openssl") "/lib -L ."))
331 #:phases
332 (modify-phases %standard-phases
333 (add-after 'unpack 'enter-source
334 (lambda _ (chdir "adb") #t))
335 (add-after 'enter-source 'make-libs-available
336 (lambda* (#:key inputs outputs #:allow-other-keys)
337 (substitute* "Android.mk"
338 (("libcrypto_static") "libcrypto"))
339 #t))
340 (add-after 'install 'install-headers
341 (lambda* (#:key inputs outputs #:allow-other-keys)
342 (install-file "diagnose_usb.h" (string-append (assoc-ref outputs "out") "/include"))
343 #t)))))
344 (inputs
345 `(("android-libbase" ,android-libbase)
346 ("android-libcutils" ,android-libcutils)
347 ("android-liblog" ,android-liblog)
348 ("openssl" ,openssl)))
349 (home-page "https://developer.android.com/studio/command-line/adb.html")
350 (synopsis "Android Debug Bridge")
351 (description
352 "@command{adb} is a versatile command line tool that lets you communicate
353 with an emulator instance or connected Android device. It facilitates a variety
354 of device actions, such as installing and debugging apps, and it provides access
355 to a Unix shell that can run commands on the connected device or emulator.")
356 (license license:asl2.0)))
357
358 (define-public mkbootimg
359 (package
360 (name "mkbootimg")
361 (version (android-platform-version))
362 (source (origin
363 (inherit (android-platform-system-core version))))
364 (build-system python-build-system)
365 (arguments
366 `(#:tests? #f
367 #:phases
368 (modify-phases %standard-phases
369 (add-after 'unpack 'enter-source
370 (lambda _ (chdir "mkbootimg") #t))
371 (delete 'configure)
372 (delete 'build)
373 (replace 'install
374 (lambda* (#:key outputs #:allow-other-keys)
375 (let* ((out (assoc-ref outputs "out"))
376 (bin (string-append out "/bin"))
377 (include (string-append out "/include")))
378 (install-file "mkbootimg" bin)
379 (install-file "bootimg.h" include)
380 #t))))))
381 (home-page "https://developer.android.com/studio/command-line/adb.html")
382 (synopsis "Tool to create Android boot images")
383 (description "This package provides a tool to create Android Boot
384 Images.")
385 (license license:asl2.0)))
386
387 (define-public android-safe-iop
388 (package
389 (name "android-safe-iop")
390 (version (android-platform-version))
391 (source (android-platform-external version "safe-iop"
392 "1nyyrs463advjhlq8xx1lm37m4g5afv7gy0csxrj7biwwl0v13qw"))
393 (build-system android-ndk-build-system)
394 (arguments
395 `(#:make-flags '("CXXFLAGS=-fpermissive -Wno-error")
396 #:phases
397 (modify-phases %standard-phases
398 (add-before 'build 'patch-host
399 (lambda _
400 ;; TODO: Cross-compile.
401 (substitute* "Android.mk"
402 (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY"))
403 #t)))))
404 (home-page "https://developer.android.com/")
405 (synopsis "Safe integers in C")
406 (description "@code{android-safe-iop} provides a set of functions for
407 performing and checking safe integer operations. Ensure that integer
408 operations do not result in silent overflow.")
409 (license license:bsd-2)))
410
411 (define-public android-bionic-uapi
412 (package
413 (name "android-bionic-uapi")
414 (version (android-platform-version))
415 (source (android-platform-bionic version))
416 (build-system android-ndk-build-system)
417 (arguments
418 `(#:phases
419 (modify-phases %standard-phases
420 (add-after 'unpack 'enter-source
421 (lambda _ (chdir "libc") #t))
422 (replace 'check
423 (const #t))
424 (replace 'build
425 (const #t))
426 (replace 'install
427 (lambda* (#:key outputs #:allow-other-keys)
428 (let* ((out (assoc-ref outputs "out"))
429 (out-sys (string-append out "/include/sys")))
430 (mkdir-p out-sys)
431 (install-file "include/sys/system_properties.h" out-sys)
432 (install-file "include/sys/_system_properties.h" out-sys)
433 (copy-recursively "kernel/uapi" (string-append out "/include"))
434 #t))))))
435 (home-page "https://developer.android.com/")
436 (synopsis "Android Linux API that is safe for user space")
437 (description "@code{android-bionic-uapi} provides the part of the Linux API
438 that is safe to use for user space. It also includes
439 @code{system_properties.h} and @code{_system_properties.h}.")
440 (license license:asl2.0)))
441
442 (define-public android-libselinux
443 (package
444 (name "android-libselinux")
445 (version (android-platform-version))
446 (source
447 (android-platform-external version "libselinux"
448 "13m2q32gzdcs5d0zj1nwasjy1j8vsxsgbjg7m5sa9lfcjaj7nkm7"))
449 (build-system android-ndk-build-system)
450 (arguments
451 ;; See logd/Android.mk for the *_LOG_TAG values.
452 `(#:make-flags (list (string-append "CFLAGS=-Wno-error "
453 "-I core/include "
454 "-I core/libpackagelistparser/include "
455 "-DAUDITD_LOG_TAG=1003 "
456 "-DLOGD_LOG_TAG=1004 -D_GNU_SOURCE")
457 "LDFLAGS=-L . -lpcre")
458 #:phases
459 (modify-phases %standard-phases
460 (add-after 'unpack-core 'patch-HOST
461 (lambda _
462 ;; gettid duplicates otherwise.
463 (substitute* "src/procattr.c"
464 (("#ifdef HOST") "#ifdef XXX"))
465 #t)))))
466 (inputs
467 `(("openssl" ,openssl)))
468 (native-inputs
469 `(("android-bionic-uapi" ,android-bionic-uapi)
470 ;; pcre is inlined by our package.
471 ("pcre" ,pcre)))
472 (home-page "https://developer.android.com/")
473 (synopsis (package-synopsis libselinux))
474 (description (package-description libselinux))
475 (license (package-license libselinux))))
476
477 (define-public android-ext4-utils
478 (package
479 (name "android-ext4-utils")
480 (version (android-platform-version))
481 (source (android-platform-system-extras version))
482 (build-system android-ndk-build-system)
483 (arguments
484 `(#:make-flags
485 (list (string-append "CPPFLAGS="
486 ;"-Wno-error "
487 "-I "
488 (assoc-ref %build-inputs "android-libselinux")
489 "/include "
490 "-I " (assoc-ref %build-inputs "android-libsparse")
491 "/include "
492 "-I " (assoc-ref %build-inputs "android-libcutils")
493 "/include "
494 "-I " (assoc-ref %build-inputs "android-liblog") "/include "
495 "-I ../core/include")
496 "CFLAGS=-Wno-error"
497 "install-libext4_utils_host.a"
498 (string-append "prefix=" (assoc-ref %outputs "out")))
499 #:phases
500 (modify-phases %standard-phases
501 (add-after 'unpack 'unpack-core
502 (lambda* (#:key inputs #:allow-other-keys)
503 (mkdir-p "core")
504 (with-directory-excursion "core"
505 (invoke "tar" "axf" (assoc-ref inputs "android-core")
506 "--strip-components=1"))
507 #t))
508 (add-after 'unpack-core 'enter-source
509 (lambda _ (chdir "ext4_utils") #t))
510 (replace 'install
511 (lambda* (#:key inputs outputs #:allow-other-keys)
512 (let ((out (assoc-ref outputs "out")))
513 (copy-recursively "." (string-append out "/include")))
514 #t)))))
515 (inputs
516 `(("android-libcutils" ,android-libcutils)
517 ("android-liblog" ,android-liblog)
518 ("android-libselinux" ,android-libselinux)
519 ("android-libsparse" ,android-libsparse)
520 ("zlib" ,zlib)))
521 (native-inputs
522 `(("android-core" ,(android-platform-system-core version))))
523 (home-page "https://developer.android.com/")
524 (synopsis "Android ext4 filesystem utils")
525 (description "@code{android-ext4-utils} is a library in common use by the
526 Android core.")
527 (license license:asl2.0)))
528
529 (define-public android-f2fs-utils
530 (package
531 (name "android-f2fs-utils")
532 (version (android-platform-version))
533 (source (android-platform-system-extras version))
534 (build-system android-ndk-build-system)
535 (arguments
536 `(#:phases
537 (modify-phases %standard-phases
538 (add-after 'unpack 'enter-source
539 (lambda _ (chdir "f2fs_utils") #t))
540 (add-after 'install 'install-headers
541 (lambda* (#:key inputs outputs #:allow-other-keys)
542 (copy-recursively "." (string-append (assoc-ref outputs "out")
543 "/include"))
544 #t))
545 (add-after 'install 'install-shell-scripts
546 (lambda* (#:key outputs #:allow-other-keys)
547 (let* ((out (assoc-ref outputs "out"))
548 (bin (string-append out "/bin")))
549 (patch-shebang "mkf2fsuserimg.sh")
550 (substitute* "mkf2fsuserimg.sh"
551 (("make_f2fs") (string-append bin "/make_f2fs")))
552 (install-file "mkf2fsuserimg.sh" bin)
553 #t))))))
554 (inputs
555 `(("f2fs-tools" ,f2fs-tools-1.7)
556 ("android-libselinux" ,android-libselinux)
557 ("android-libsparse" ,android-libsparse)
558 ("android-libcutils" ,android-libcutils)
559 ("zlib" ,zlib)))
560 (home-page "https://developer.android.com/")
561 (synopsis "Android f2fs utils")
562 (description "@code{android-f2fs-utils} is a library in common use by the
563 Android core. It allows the user to create images for the @code{f2fs} Flash
564 file system.")
565 (license license:asl2.0)))
566
567 (define-public android-libutils
568 (package
569 (name "android-libutils")
570 (version (android-platform-version))
571 (source (android-platform-system-core version))
572 (build-system android-ndk-build-system)
573 (arguments
574 `(#:tests? #f ; TODO
575 #:make-flags '("CXXFLAGS=-std=gnu++11 -Wno-error")
576 #:phases
577 (modify-phases %standard-phases
578 (add-after 'unpack 'enter-source
579 (lambda _ (chdir "libutils") #t))
580
581 (add-after 'install 'install-headers
582 (lambda* (#:key inputs outputs #:allow-other-keys)
583 (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
584 (inputs
585 `(("android-safe-iop" ,android-safe-iop)
586 ("android-libcutils" ,android-libcutils)))
587 (native-inputs
588 `(("android-bionic-uapi" ,android-bionic-uapi)
589 ("android-liblog" ,android-liblog)))
590 (home-page "https://developer.android.com/")
591 (synopsis "Android utility library")
592 (description "@code{android-libutils} provides utilities for Android NDK developers.")
593 (license license:asl2.0)))
594
595 (define-public fastboot
596 (package
597 (name "fastboot")
598 (version (android-platform-version))
599 (source (android-platform-system-core version))
600 (build-system android-ndk-build-system)
601 (arguments
602 `(#:make-flags (list "CXXFLAGS=-std=gnu++11")
603 #:phases
604 (modify-phases %standard-phases
605 (add-after 'unpack 'enter-source
606 (lambda _
607 (chdir "fastboot")
608 #t))
609 (add-after 'enter-source 'patch-source
610 (lambda _
611 (substitute* "Android.mk"
612 (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
613 #t))
614 (replace 'install
615 (lambda* (#:key outputs #:allow-other-keys)
616 (let* ((out (assoc-ref outputs "out"))
617 (lib (string-append out "/lib"))
618 (bin (string-append out "/bin")))
619 (install-file "fastboot" bin)
620 #t))))))
621 (inputs
622 `(("adb" ,adb)
623 ("android-safe-iop" ,android-safe-iop)
624 ("android-ext4-utils" ,android-ext4-utils)
625 ("android-f2fs-utils" ,android-f2fs-utils)
626 ("android-libbase" ,android-libbase)
627 ("android-libcutils" ,android-libcutils)
628 ("android-liblog" ,android-liblog)
629 ("android-libutils" ,android-libutils)
630 ("android-libsparse" ,android-libsparse)
631 ("android-libziparchive" ,android-libziparchive)
632 ("android-libselinux" ,android-libselinux)
633 ("pcre" ,pcre)
634 ("mkbootimg" ,mkbootimg)
635 ("zlib" ,zlib)))
636 (native-inputs
637 `(("xz" ,xz)))
638 (home-page "https://developer.android.com/studio/command-line/")
639 (synopsis "Android image flasher")
640 (description
641 "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
642 (license license:asl2.0)))
643
644 (define-public android-udev-rules
645 (package
646 (name "android-udev-rules")
647 (version "20180112")
648 (source
649 (origin
650 (method git-fetch)
651 (uri (git-reference
652 (url "https://github.com/M0Rf30/android-udev-rules")
653 (commit version)))
654 (file-name (string-append name "-" version "-checkout"))
655 (sha256
656 (base32 "13gj79nnd04szqlrrzzkdr6wi1fky08pi7x8xfbg0jj3d3v0giah"))))
657 (build-system trivial-build-system)
658 (native-inputs `(("source" ,source)))
659 (arguments
660 '(#:modules ((guix build utils))
661 #:builder
662 (begin
663 (use-modules (guix build utils))
664 (let ((source (assoc-ref %build-inputs "source")))
665 (install-file (string-append source "/51-android.rules")
666 (string-append %output "/lib/udev/rules.d"))))))
667 (home-page "https://github.com/M0Rf30/android-udev-rules")
668 (synopsis "udev rules for Android devices")
669 (description "Provides a set of udev rules to allow using Android devices
670 with tools such as @command{adb} and @command{fastboot} without root
671 privileges. This package is intended to be added as a rule to the
672 @code{udev-service-type} in your @code{operating-system} configuration.
673 Additionally, an @code{adbusers} group must be defined and your user added to
674 it.
675
676 @emph{Simply installing this package will not have any effect.} It is meant
677 to be passed to the @code{udev} service.")
678 (license license:gpl3+)))
679
680 (define-public git-repo
681 (package
682 (name "git-repo")
683 (version "1.12.37")
684 (source
685 (origin
686 (method git-fetch)
687 (uri (git-reference
688 (url "https://gerrit.googlesource.com/git-repo")
689 (commit (string-append "v" version))))
690 (file-name (string-append "git-repo-" version "-checkout"))
691 (sha256
692 (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd"))))
693 (build-system python-build-system)
694 (arguments
695 `(#:python ,python-2 ; code says: "Python 3 support is … experimental."
696 #:phases
697 (modify-phases %standard-phases
698 (add-before 'build 'set-executable-paths
699 (lambda* (#:key inputs outputs #:allow-other-keys)
700 (let* ((out (assoc-ref outputs "out"))
701 (git (assoc-ref inputs "git"))
702 (gpg (assoc-ref inputs "gnupg"))
703 (ssh (assoc-ref inputs "ssh")))
704 (substitute* '("repo" "git_command.py")
705 (("^GIT = 'git' ")
706 (string-append "GIT = '" git "/bin/git' ")))
707 (substitute* "repo"
708 ((" cmd = \\['gpg',")
709 (string-append " cmd = ['" gpg "/bin/gpg',")))
710 (substitute* "git_config.py"
711 ((" command_base = \\['ssh',")
712 (string-append " command_base = ['" ssh "/bin/ssh',")))
713 #t)))
714 (add-before 'build 'do-not-clone-this-source
715 (lambda* (#:key outputs #:allow-other-keys)
716 (let* ((out (assoc-ref outputs "out"))
717 (repo-dir (string-append out "/share/" ,name)))
718 (substitute* "repo"
719 (("^def _FindRepo\\(\\):.*")
720 (format #f "
721 def _FindRepo():
722 '''Look for a repo installation, starting at the current directory.'''
723 # Use the installed version of git-repo.
724 repo_main = '~a/main.py'
725 curdir = os.getcwd()
726 olddir = None
727 while curdir != '/' and curdir != olddir:
728 dot_repo = os.path.join(curdir, repodir)
729 if os.path.isdir(dot_repo):
730 return (repo_main, dot_repo)
731 else:
732 olddir = curdir
733 curdir = os.path.dirname(curdir)
734 return None, ''
735
736 # The remaining of this function is dead code. It was used to
737 # find a git-checked-out version in the local project.\n" repo-dir))
738 ;; Neither clone, check out, nor verify the git repository
739 (("(^\\s+)_Clone\\(.*\\)") "")
740 (("(^\\s+)_Checkout\\(.*\\)") "")
741 ((" rev = _Verify\\(.*\\)") " rev = None"))
742 #t)))
743 (delete 'build) ; nothing to build
744 (replace 'check
745 (lambda _
746 (zero? (system* "python" "-m" "nose"))))
747 (replace 'install
748 (lambda* (#:key outputs #:allow-other-keys)
749 (let* ((out (assoc-ref outputs "out"))
750 (bin-dir (string-append out "/bin"))
751 (repo-dir (string-append out "/share/" ,name)))
752 (mkdir-p bin-dir)
753 (mkdir-p repo-dir)
754 (copy-recursively "." repo-dir)
755 (delete-file-recursively (string-append repo-dir "/tests"))
756 (symlink (string-append repo-dir "/repo")
757 (string-append bin-dir "/repo"))
758 #t))))))
759 (inputs
760 ;; TODO: Add git-remote-persistent-https once it is available in guix
761 `(("git" ,git)
762 ("gnupg" ,gnupg)
763 ("ssh" ,openssh)))
764 (native-inputs
765 `(("nose" ,python2-nose)))
766 (home-page "https://code.google.com/p/git-repo/")
767 (synopsis "Helps to manage many Git repositories.")
768 (description "Repo is a tool built on top of Git. Repo helps manage many
769 Git repositories, does the uploads to revision control systems, and automates
770 parts of the development workflow. Repo is not meant to replace Git, only to
771 make it easier to work with Git. The repo command is an executable Python
772 script that you can put anywhere in your path.")
773 (license license:asl2.0)))
774
775 (define-public abootimg
776 (package
777 (name "abootimg")
778 (version "0.6")
779 (source
780 (origin
781 (method url-fetch)
782 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
783 "abootimg_" version ".orig.tar.gz"))
784 (sha256
785 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
786 (build-system gnu-build-system)
787 (arguments
788 `(#:tests? #f
789 #:phases
790 (modify-phases %standard-phases
791 (replace 'configure
792 (lambda _
793 (setenv "CC" "gcc")
794 #t))
795 (replace 'install
796 (lambda* (#:key outputs #:allow-other-keys)
797 (let* ((out (assoc-ref outputs "out"))
798 (bin (string-append out "/bin")))
799 (install-file "abootimg" bin)
800 #t))))))
801 (inputs
802 `(("libblkid" ,util-linux)))
803 (home-page "https://ac100.grandou.net/abootimg")
804 (synopsis "Tool for manipulating Android Boot Images")
805 (description "This package provides a tool for manipulating old Android
806 Boot Images. @code{abootimg} can work directly on block devices, or, the
807 safest way, on a file image.")
808 (license license:gpl2+)))