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