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 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 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages android)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system android-ndk)
34 #:use-module (guix build-system python)
35 #:use-module (guix build-system trivial)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages docker)
41 #:use-module (gnu packages gcc)
42 #:use-module (gnu packages gnupg)
43 #:use-module (gnu packages java)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages pcre)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages python-crypto)
48 #:use-module (gnu packages python-web)
49 #:use-module (gnu packages python-xyz)
50 #:use-module (gnu packages selinux)
51 #:use-module (gnu packages serialization)
52 #:use-module (gnu packages ssh)
53 #:use-module (gnu packages tls)
54 #:use-module (gnu packages version-control)
55 #:use-module (gnu packages virtualization)
56 #:use-module (gnu packages xdisorg)
57 #:use-module (gnu packages xml))
58
59 (define-public android-make-stub
60 (package
61 (name "android-make-stub")
62 (version "0.6.0")
63 (source
64 (origin
65 (method git-fetch)
66 (uri (git-reference
67 (url "https://github.com/daym/android-make-stub.git")
68 (commit (string-append "v" version))))
69 (file-name (string-append "android-make-stub-"
70 version "-checkout"))
71 (sha256
72 (base32
73 "0y1b2x96d37n6f1bp6dcx08bn08zac0cylmbfsx6mf2nahc02fhc"))))
74 (build-system gnu-build-system)
75 (arguments
76 `(#:tests? #f ; None exist.
77 #:phases
78 (modify-phases %standard-phases
79 (delete 'configure)
80 (delete 'build)
81 (replace 'install
82 (lambda* (#:key outputs #:allow-other-keys)
83 (let* ((out (assoc-ref outputs "out")))
84 (invoke "make" (string-append "prefix=" out) "install")
85 #t))))))
86 (home-page "https://github.com/daym/android-make-stub")
87 (synopsis "Stubs for the @command{make} system of the Android platform")
88 (description "@code{android-make-stub} provides stubs for the
89 @command{make} system of the Android platform. This allows us to
90 use their packages mostly unmodified in our Android NDK build system.")
91 (license license:asl2.0)))
92
93 (define-public android-googletest
94 (package (inherit googletest)
95 (name "android-googletest")
96 (version "1.8.0")
97 (source
98 (origin
99 (method git-fetch)
100 (uri (git-reference
101 (url "https://github.com/google/googletest.git")
102 (commit (string-append "release-" version))))
103 (file-name (git-file-name name version))
104 (sha256
105 (base32
106 "0bjlljmbf8glnd9qjabx73w6pd7ibv43yiyngqvmvgxsabzr8399"))))
107 (arguments
108 `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")
109 #:phases
110 (modify-phases %standard-phases
111 (add-after 'install 'install-host-libraries
112 (lambda* (#:key outputs #:allow-other-keys)
113 (let* ((out (assoc-ref outputs "out"))
114 (lib (string-append out "/lib")))
115 (symlink "libgtest.so"
116 (string-append lib "/libgtest_host.so"))
117 (symlink "libgmock.so"
118 (string-append lib "/libgmock_host.so"))
119 #t))))))))
120
121 ;; The Makefiles that we add are largely based on the Debian
122 ;; packages. They are licensed under GPL-2 and have copyright:
123 ;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
124 ;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
125 ;; Big thanks to them for laying the groundwork.
126
127 ;; The version tag is consistent between all repositories.
128 (define (android-platform-version) "7.1.2_r36")
129
130 (define (android-platform-system-core version)
131 (origin
132 (method git-fetch)
133 (uri (git-reference
134 (url "https://android.googlesource.com/platform/system/core")
135 (commit (string-append "android-" version))))
136 (file-name (string-append "android-platform-system-core-"
137 version "-checkout"))
138 (sha256
139 (base32
140 "1krnc2b9zfkzpdgs1dcbji59nszlx2qr723pg89m52622czc06hg"))
141 (patches
142 (search-patches "libbase-use-own-logging.patch"
143 "libbase-fix-includes.patch"
144 "libutils-remove-damaging-includes.patch"
145 "libutils-add-includes.patch"
146 "adb-add-libraries.patch"
147 "libziparchive-add-includes.patch"))))
148
149 (define (android-platform-system-extras version)
150 (origin
151 (method git-fetch)
152 (uri (git-reference
153 (url "https://android.googlesource.com/platform/system/extras")
154 (commit (string-append "android-" version))))
155 (file-name (string-append "android-platform-system-extras-"
156 version "-checkout"))
157 (sha256
158 (base32
159 "18130c23ybqcpgjc5v6f8kdbv2xn39hyiaj17dzldjb9rlwzcyy9"))))
160
161 (define (android-platform-bionic version)
162 (origin
163 (method git-fetch)
164 (uri (git-reference
165 (url "https://android.googlesource.com/platform/bionic")
166 (commit (string-append "android-" version))))
167 (file-name (string-append "android-platform-bionic-"
168 version "-checkout"))
169 (sha256
170 (base32
171 "15r4s20d7vw022f8vrc3jbghmqwdcqzprl7i2bfvdkz8z76wc1ps"))))
172
173 (define (android-platform-external version subdirectory checksum)
174 (origin
175 (method git-fetch)
176 (uri (git-reference
177 (url
178 (string-append "https://android.googlesource.com/platform/external/"
179 subdirectory))
180 (commit (string-append "android-" version))))
181 (file-name (string-append "android-platform-system-external-" subdirectory "-"
182 version "-checkout"))
183 (sha256
184 (base32
185 checksum))))
186
187 (define android-liblog
188 (package
189 (name "android-liblog")
190 (version (android-platform-version))
191 (source (android-platform-system-core version))
192 (build-system android-ndk-build-system)
193 (arguments
194 `(#:make-flags '("LDLIBS=-lpthread")
195 #:phases
196 (modify-phases %standard-phases
197 (add-after 'unpack 'enter-source
198 (lambda _ (chdir "liblog") #t))
199 (add-after 'install 'ldconfig
200 (lambda* (#:key outputs #:allow-other-keys)
201 (let ((out (assoc-ref outputs "out")))
202 (symlink "liblog.so.0" (string-append out "/lib/liblog.so"))
203 #t))))))
204 (home-page "https://developer.android.com/")
205 (synopsis "Logging library from the Android platform.")
206 (description "@code{liblog} represents an interface to the volatile Android
207 Logging system for NDK (Native) applications and libraries and contain
208 interfaces for either writing or reading logs. The log buffers are divided up
209 in Main, System, Radio and Events sub-logs.")
210 (license license:asl2.0)))
211
212 (define android-libbase
213 (package
214 (name "android-libbase")
215 (version (android-platform-version))
216 (source (android-platform-system-core version))
217 (build-system android-ndk-build-system)
218 (arguments
219 `(#:tests? #f ; Test failure: logging.UNIMPLEMENTED
220 #:make-flags '("CXXFLAGS=-std=gnu++11")
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 += -std=gnu++11 -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 -std=gnu++11")
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 (package-synopsis libselinux))
505 (description (package-description libselinux))
506 (license (package-license libselinux))))
507
508 (define-public android-ext4-utils
509 (package
510 (name "android-ext4-utils")
511 (version (android-platform-version))
512 (source (android-platform-system-extras version))
513 (build-system android-ndk-build-system)
514 (arguments
515 `(#:make-flags
516 (list (string-append "CPPFLAGS="
517 ;"-Wno-error "
518 "-I "
519 (assoc-ref %build-inputs "android-libselinux")
520 "/include "
521 "-I " (assoc-ref %build-inputs "android-libsparse")
522 "/include "
523 "-I " (assoc-ref %build-inputs "android-libcutils")
524 "/include "
525 "-I " (assoc-ref %build-inputs "android-liblog") "/include "
526 "-I ../core/include")
527 "CFLAGS=-Wno-error"
528 "install-libext4_utils_host.a"
529 (string-append "prefix=" (assoc-ref %outputs "out")))
530 #:phases
531 (modify-phases %standard-phases
532 (add-after 'unpack 'unpack-core
533 (lambda* (#:key inputs #:allow-other-keys)
534 (mkdir-p "core")
535 (with-directory-excursion "core"
536 (invoke "tar" "axf" (assoc-ref inputs "android-core")
537 "--strip-components=1"))
538 #t))
539 (add-after 'unpack-core 'enter-source
540 (lambda _ (chdir "ext4_utils") #t))
541 (replace 'install
542 (lambda* (#:key inputs outputs #:allow-other-keys)
543 (let ((out (assoc-ref outputs "out")))
544 (copy-recursively "." (string-append out "/include")))
545 #t)))))
546 (inputs
547 `(("android-libcutils" ,android-libcutils)
548 ("android-liblog" ,android-liblog)
549 ("android-libselinux" ,android-libselinux)
550 ("android-libsparse" ,android-libsparse)
551 ("zlib" ,zlib)))
552 (native-inputs
553 `(("android-core" ,(android-platform-system-core version))))
554 (home-page "https://developer.android.com/")
555 (synopsis "Android ext4 file system utilities")
556 (description "@code{android-ext4-utils} is a library in common use by the
557 Android core.")
558 (license license:asl2.0)))
559
560 (define-public android-f2fs-utils
561 (package
562 (name "android-f2fs-utils")
563 (version (android-platform-version))
564 (source (android-platform-system-extras version))
565 (build-system android-ndk-build-system)
566 (arguments
567 `(#:phases
568 (modify-phases %standard-phases
569 (add-after 'unpack 'enter-source
570 (lambda _ (chdir "f2fs_utils") #t))
571 (add-after 'install 'install-headers
572 (lambda* (#:key inputs outputs #:allow-other-keys)
573 (copy-recursively "." (string-append (assoc-ref outputs "out")
574 "/include"))
575 #t))
576 (add-after 'install 'install-shell-scripts
577 (lambda* (#:key outputs #:allow-other-keys)
578 (let* ((out (assoc-ref outputs "out"))
579 (bin (string-append out "/bin")))
580 (patch-shebang "mkf2fsuserimg.sh")
581 (substitute* "mkf2fsuserimg.sh"
582 (("make_f2fs") (string-append bin "/make_f2fs")))
583 (install-file "mkf2fsuserimg.sh" bin)
584 #t))))))
585 (inputs
586 `(("f2fs-tools" ,f2fs-tools-1.7)
587 ("android-libselinux" ,android-libselinux)
588 ("android-libsparse" ,android-libsparse)
589 ("android-libcutils" ,android-libcutils)
590 ("zlib" ,zlib)))
591 (home-page "https://developer.android.com/")
592 (synopsis "Android f2fs utils")
593 (description "@code{android-f2fs-utils} is a library in common use by the
594 Android core. It allows the user to create images for the @code{f2fs} Flash
595 file system.")
596 (license license:asl2.0)))
597
598 (define-public android-libutils
599 (package
600 (name "android-libutils")
601 (version (android-platform-version))
602 (source (android-platform-system-core version))
603 (build-system android-ndk-build-system)
604 (arguments
605 `(#:tests? #f ; TODO
606 #:make-flags '("CXXFLAGS=-std=gnu++11 -Wno-error")
607 #:phases
608 (modify-phases %standard-phases
609 (add-after 'unpack 'enter-source
610 (lambda _ (chdir "libutils") #t))
611
612 (add-after 'install 'install-headers
613 (lambda* (#:key inputs outputs #:allow-other-keys)
614 (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
615 (inputs
616 `(("android-safe-iop" ,android-safe-iop)
617 ("android-libcutils" ,android-libcutils)))
618 (native-inputs
619 `(("android-bionic-uapi" ,android-bionic-uapi)
620 ("android-liblog" ,android-liblog)
621 ("gcc" ,gcc-5))) ; XXX: fails to build with GCC 7
622 (home-page "https://developer.android.com/")
623 (synopsis "Android utility library")
624 (description "@code{android-libutils} provides utilities for Android NDK developers.")
625 (license license:asl2.0)))
626
627 (define-public fastboot
628 (package
629 (name "fastboot")
630 (version (android-platform-version))
631 (source (android-platform-system-core version))
632 (build-system android-ndk-build-system)
633 (arguments
634 `(#:make-flags (list "CXXFLAGS=-std=gnu++11")
635 #:phases
636 (modify-phases %standard-phases
637 (add-after 'unpack 'enter-source
638 (lambda _
639 (chdir "fastboot")
640 #t))
641 (add-after 'enter-source 'patch-source
642 (lambda _
643 (substitute* "Android.mk"
644 (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
645 #t))
646 (replace 'install
647 (lambda* (#:key outputs #:allow-other-keys)
648 (let* ((out (assoc-ref outputs "out"))
649 (lib (string-append out "/lib"))
650 (bin (string-append out "/bin")))
651 (install-file "fastboot" bin)
652 #t))))))
653 (inputs
654 `(("adb" ,adb)
655 ("android-safe-iop" ,android-safe-iop)
656 ("android-ext4-utils" ,android-ext4-utils)
657 ("android-f2fs-utils" ,android-f2fs-utils)
658 ("android-libbase" ,android-libbase)
659 ("android-libcutils" ,android-libcutils)
660 ("android-liblog" ,android-liblog)
661 ("android-libutils" ,android-libutils)
662 ("android-libsparse" ,android-libsparse)
663 ("android-libziparchive" ,android-libziparchive)
664 ("android-libselinux" ,android-libselinux)
665 ("pcre" ,pcre)
666 ("mkbootimg" ,mkbootimg)
667 ("zlib" ,zlib)))
668 (native-inputs
669 `(("xz" ,xz)))
670 (home-page "https://developer.android.com/studio/command-line/")
671 (synopsis "Android image flasher")
672 (description
673 "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
674 (license license:asl2.0)))
675
676 (define-public android-udev-rules
677 (package
678 (name "android-udev-rules")
679 (version "20180112")
680 (source
681 (origin
682 (method git-fetch)
683 (uri (git-reference
684 (url "https://github.com/M0Rf30/android-udev-rules")
685 (commit version)))
686 (file-name (string-append name "-" version "-checkout"))
687 (sha256
688 (base32 "13gj79nnd04szqlrrzzkdr6wi1fky08pi7x8xfbg0jj3d3v0giah"))))
689 (build-system trivial-build-system)
690 (native-inputs `(("source" ,source)))
691 (arguments
692 '(#:modules ((guix build utils))
693 #:builder
694 (begin
695 (use-modules (guix build utils))
696 (let ((source (assoc-ref %build-inputs "source")))
697 (install-file (string-append source "/51-android.rules")
698 (string-append %output "/lib/udev/rules.d"))
699 #t))))
700 (home-page "https://github.com/M0Rf30/android-udev-rules")
701 (synopsis "udev rules for Android devices")
702 (description "Provides a set of udev rules to allow using Android devices
703 with tools such as @command{adb} and @command{fastboot} without root
704 privileges. This package is intended to be added as a rule to the
705 @code{udev-service-type} in your @code{operating-system} configuration.
706 Additionally, an @code{adbusers} group must be defined and your user added to
707 it.
708
709 @emph{Simply installing this package will not have any effect.} It is meant
710 to be passed to the @code{udev} service.")
711 (license license:gpl3+)))
712
713 (define-public git-repo
714 (package
715 (name "git-repo")
716 (version "1.12.37")
717 (source
718 (origin
719 (method git-fetch)
720 (uri (git-reference
721 (url "https://gerrit.googlesource.com/git-repo")
722 (commit (string-append "v" version))))
723 (file-name (string-append "git-repo-" version "-checkout"))
724 (sha256
725 (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd"))))
726 (build-system python-build-system)
727 (arguments
728 `(#:python ,python-2 ; code says: "Python 3 support is … experimental."
729 #:phases
730 (modify-phases %standard-phases
731 (add-before 'build 'set-executable-paths
732 (lambda* (#:key inputs outputs #:allow-other-keys)
733 (let* ((out (assoc-ref outputs "out"))
734 (git (assoc-ref inputs "git"))
735 (gpg (assoc-ref inputs "gnupg"))
736 (ssh (assoc-ref inputs "ssh")))
737 (substitute* '("repo" "git_command.py")
738 (("^GIT = 'git' ")
739 (string-append "GIT = '" git "/bin/git' ")))
740 (substitute* "repo"
741 ((" cmd = \\['gpg',")
742 (string-append " cmd = ['" gpg "/bin/gpg',")))
743 (substitute* "git_config.py"
744 ((" command_base = \\['ssh',")
745 (string-append " command_base = ['" ssh "/bin/ssh',")))
746 #t)))
747 (add-before 'build 'do-not-clone-this-source
748 (lambda* (#:key outputs #:allow-other-keys)
749 (let* ((out (assoc-ref outputs "out"))
750 (repo-dir (string-append out "/share/" ,name)))
751 (substitute* "repo"
752 (("^def _FindRepo\\(\\):.*")
753 (format #f "
754 def _FindRepo():
755 '''Look for a repo installation, starting at the current directory.'''
756 # Use the installed version of git-repo.
757 repo_main = '~a/main.py'
758 curdir = os.getcwd()
759 olddir = None
760 while curdir != '/' and curdir != olddir:
761 dot_repo = os.path.join(curdir, repodir)
762 if os.path.isdir(dot_repo):
763 return (repo_main, dot_repo)
764 else:
765 olddir = curdir
766 curdir = os.path.dirname(curdir)
767 return None, ''
768
769 # The remaining of this function is dead code. It was used to
770 # find a git-checked-out version in the local project.\n" repo-dir))
771 ;; Neither clone, check out, nor verify the git repository
772 (("(^\\s+)_Clone\\(.*\\)") "")
773 (("(^\\s+)_Checkout\\(.*\\)") "")
774 ((" rev = _Verify\\(.*\\)") " rev = None"))
775 #t)))
776 (delete 'build) ; nothing to build
777 (replace 'check
778 (lambda _
779 (invoke "python" "-m" "nose")))
780 (replace 'install
781 (lambda* (#:key outputs #:allow-other-keys)
782 (let* ((out (assoc-ref outputs "out"))
783 (bin-dir (string-append out "/bin"))
784 (repo-dir (string-append out "/share/" ,name)))
785 (mkdir-p bin-dir)
786 (mkdir-p repo-dir)
787 (copy-recursively "." repo-dir)
788 (delete-file-recursively (string-append repo-dir "/tests"))
789 (symlink (string-append repo-dir "/repo")
790 (string-append bin-dir "/repo"))
791 #t))))))
792 (inputs
793 ;; TODO: Add git-remote-persistent-https once it is available in guix
794 `(("git" ,git)
795 ("gnupg" ,gnupg)
796 ("ssh" ,openssh)))
797 (native-inputs
798 `(("nose" ,python2-nose)))
799 (home-page "https://code.google.com/p/git-repo/")
800 (synopsis "Helps to manage many Git repositories.")
801 (description "Repo is a tool built on top of Git. Repo helps manage many
802 Git repositories, does the uploads to revision control systems, and automates
803 parts of the development workflow. Repo is not meant to replace Git, only to
804 make it easier to work with Git. The repo command is an executable Python
805 script that you can put anywhere in your path.")
806 (license license:asl2.0)))
807
808 (define-public abootimg
809 (package
810 (name "abootimg")
811 (version "0.6")
812 (source
813 (origin
814 (method url-fetch)
815 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
816 "abootimg_" version ".orig.tar.gz"))
817 (sha256
818 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
819 (build-system gnu-build-system)
820 (arguments
821 `(#:tests? #f
822 #:phases
823 (modify-phases %standard-phases
824 (replace 'configure
825 (lambda _
826 (setenv "CC" "gcc")
827 #t))
828 (replace 'install
829 (lambda* (#:key outputs #:allow-other-keys)
830 (let* ((out (assoc-ref outputs "out"))
831 (bin (string-append out "/bin")))
832 (install-file "abootimg" bin)
833 #t))))))
834 (inputs
835 `(("libblkid" ,util-linux)))
836 (home-page "https://ac100.grandou.net/abootimg")
837 (synopsis "Tool for manipulating Android Boot Images")
838 (description "This package provides a tool for manipulating old Android
839 Boot Images. @code{abootimg} can work directly on block devices, or, the
840 safest way, on a file image.")
841 (license license:gpl2+)))
842
843 (define-public python-androguard
844 (package
845 (name "python-androguard")
846 (version "3.2.1")
847 (source
848 (origin
849 ;; The pypi release doesn't have the tests, but the tests use
850 ;; packaged binaries, so we skip them.
851 (method url-fetch)
852 (uri (pypi-uri "androguard" version))
853 (sha256
854 (base32
855 "0ndsw00pkyda4i2s3wi5ap8gbk6a9d23xhhxpdbk02padv8sxkfv"))))
856 (build-system python-build-system)
857 (arguments
858 '(#:phases
859 (modify-phases %standard-phases
860 (replace 'check
861 ;; Adapted from .travis.yml
862 (lambda _
863 (invoke "nosetests" "--with-coverage" "--with-timer"
864 "--timer-top-n" "50"))))))
865 (native-inputs
866 `(("python-codecov" ,python-codecov)
867 ("python-coverage" ,python-coverage)
868 ("python-mock" ,python-mock)
869 ("python-nose" ,python-nose)
870 ("python-nose-timer" ,python-nose-timer)))
871 (propagated-inputs
872 `(("python-asn1crypto" ,python-asn1crypto)
873 ("python-colorama" ,python-colorama)
874 ("python-future" ,python-future)
875 ("python-ipython" ,python-ipython)
876 ("python-lxml" ,python-lxml)
877 ("python-matplotlib" ,python-matplotlib)
878 ("python-networkx" ,python-networkx)
879 ("python-pygments" ,python-pygments)
880 ("python-pyperclip" ,python-pyperclip)))
881 (home-page "https://github.com/androguard/androguard")
882 (synopsis "Python tool to play with Android files")
883 (description
884 "Androguard is a full Python tool to manipulate Android files. It is
885 useful for reverse engineering, analysis of Android applications and more.")
886 (license license:asl2.0)))
887
888 (define-public fdroidserver
889 (package
890 (name "fdroidserver")
891 (version "1.1.1")
892 (source
893 (origin
894 (method url-fetch)
895 (uri (pypi-uri "fdroidserver" version))
896 (sha256
897 (base32
898 "0fp7q8faicx6i6wxm717qqaham3jpilb23mvynpz6v73z7hm6wcg"))))
899 (build-system python-build-system)
900 (arguments
901 `(#:phases
902 (modify-phases %standard-phases
903 (add-after 'unpack 'fix-versioning
904 (lambda _
905 (substitute* "setup.py"
906 (("0.2.1") ,(package-version python-pyasn1-modules)))
907 #t)))))
908 (propagated-inputs
909 `(("python-androguard" ,python-androguard)
910 ("python-apache-libcloud" ,python-apache-libcloud)
911 ("python-clint" ,python-clint)
912 ("python-defusedxml" ,python-defusedxml)
913 ("python-docker-py" ,python-docker-py)
914 ("python-gitpython" ,python-gitpython)
915 ("python-mwclient" ,python-mwclient)
916 ("python-paramiko" ,python-paramiko)
917 ("python-pillow" ,python-pillow)
918 ("python-pyasn1" ,python-pyasn1)
919 ("python-pyasn1-modules" ,python-pyasn1-modules)
920 ("python-pyyaml" ,python-pyyaml)
921 ("python-qrcode" ,python-qrcode)
922 ("python-ruamel.yaml" ,python-ruamel.yaml)
923 ("python-requests" ,python-requests)
924 ("python-vagrant" ,python-vagrant)))
925 (native-inputs
926 `(("python-babel" ,python-babel)
927 ("python-bcrypt" ,python-bcrypt)
928 ("python-docker-pycreds" ,python-docker-pycreds)
929 ("python-pynacl" ,python-pynacl)
930 ("python-websocket-client" ,python-websocket-client)))
931 (home-page "https://f-droid.org")
932 (synopsis "F-Droid server tools")
933 (description
934 "The F-Droid server tools provide various scripts and tools that are used
935 to maintain F-Droid, the repository of free Android applications. You can use
936 these same tools to create your own additional or alternative repository for
937 publishing, or to assist in creating, testing and submitting metadata to the
938 main repository.")
939 (license license:agpl3+)))
940
941 (define-public enjarify
942 (package
943 (name "enjarify")
944 (version "1.0.3")
945 (home-page "https://github.com/Storyyeller/enjarify")
946 (source
947 (origin
948 (method git-fetch)
949 (uri (git-reference
950 (url home-page)
951 (commit version)))
952 (file-name (git-file-name name version))
953 (patches
954 (search-patches "enjarify-setup-py.patch"))
955 (sha256
956 (base32
957 "1nam7h1g4f1h6jla4qcjjagnyvd24dv6d5445w04q8hx07nxdapk"))))
958 (build-system python-build-system)
959 (arguments
960 `(#:phases
961 (modify-phases %standard-phases
962 (add-after 'unpack 'enjarify-wrapper-inherit-pythonpath
963 ;; enjarify sets PYTHONPATH from a shell script, overwriting
964 ;; PYTHONPATH set from guix. Comment out this line.
965 (lambda _
966 (substitute* "enjarify.sh"
967 (("export PYTHONPATH") "# export PYTHONPATH"))
968 #t))
969 (add-before 'check 'fixup-expected-test-results
970 ;; Upstream adjusted this test in commit:
971 ;; 3ae884a6485af82d300515813f537685b08dd800
972 (lambda _
973 (substitute* "tests/test2/expected.txt"
974 (("^20") "0"))
975 #t))
976 (add-before 'check 'drop-java-xss-argument
977 ;; Upstream removed this argument in order to support 32-bit
978 ;; architectures. commit: 4be0111d879aa95fdc0d9f24fe529f8c664d4093
979 (lambda _
980 (substitute* "enjarify/runtests.py"
981 (("java -Xss515m") "java "))
982 #t))
983 (add-after 'install 'install-enjarify-wrapper
984 (lambda* (#:key outputs #:allow-other-keys)
985 (let* ((out (assoc-ref outputs "out")))
986 (mkdir-p (string-append out "/bin/"))
987 (copy-file "enjarify.sh" (string-append out "/bin/enjarify"))
988 #t))))))
989 (native-inputs `(("openjdk" ,openjdk12)))
990 (synopsis "Translate Dalvik bytecode to equivalent Java bytecode")
991 (description "Android applications are Java programs that run on a
992 customized virtual machine, which is part of the Android operating system, the
993 Dalvik VM. Their bytecode differs from the bytecode of normal Java
994 applications. Enjarify can translate the Dalvik bytecode back to equivalent
995 Java bytecode, which simplifies the analysis of Android applications.")
996 (license license:asl2.0)))