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