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