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