gnu: android: Export android-liblog.
[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 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")
69 (commit (string-append "v" version))))
70 (file-name (string-append "android-make-stub-"
71 version "-checkout"))
72 (sha256
73 (base32
74 "0y1b2x96d37n6f1bp6dcx08bn08zac0cylmbfsx6mf2nahc02fhc"))))
75 (build-system gnu-build-system)
76 (arguments
77 `(#:tests? #f ; None exist.
78 #:phases
79 (modify-phases %standard-phases
80 (delete 'configure)
81 (delete 'build)
82 (replace 'install
83 (lambda* (#:key outputs #:allow-other-keys)
84 (let* ((out (assoc-ref outputs "out")))
85 (invoke "make" (string-append "prefix=" out) "install")
86 #t))))))
87 (home-page "https://github.com/daym/android-make-stub")
88 (synopsis "Stubs for the @command{make} system of the Android platform")
89 (description "@code{android-make-stub} provides stubs for the
90 @command{make} system of the Android platform. This allows us to
91 use their packages mostly unmodified in our Android NDK build system.")
92 (license license:asl2.0)))
93
94 (define-public android-googletest
95 (package (inherit googletest)
96 (name "android-googletest")
97 (version "1.8.0")
98 (source
99 (origin
100 (method git-fetch)
101 (uri (git-reference
102 (url "https://github.com/google/googletest")
103 (commit (string-append "release-" version))))
104 (file-name (git-file-name name version))
105 (sha256
106 (base32
107 "0bjlljmbf8glnd9qjabx73w6pd7ibv43yiyngqvmvgxsabzr8399"))))
108 (arguments
109 `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")
110 #:phases
111 (modify-phases %standard-phases
112 (add-after 'install 'install-host-libraries
113 (lambda* (#:key outputs #:allow-other-keys)
114 (let* ((out (assoc-ref outputs "out"))
115 (lib (string-append out "/lib")))
116 (symlink "libgtest.so"
117 (string-append lib "/libgtest_host.so"))
118 (symlink "libgmock.so"
119 (string-append lib "/libgmock_host.so"))
120 #t))))))))
121
122 ;; The Makefiles that we add are largely based on the Debian
123 ;; packages. They are licensed under GPL-2 and have copyright:
124 ;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
125 ;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
126 ;; Big thanks to them for laying the groundwork.
127
128 ;; The version tag is consistent between all repositories.
129 (define (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-public android-liblog
189 (package
190 (name "android-liblog")
191 (version (android-platform-version))
192 (source (android-platform-system-core version))
193 (build-system android-ndk-build-system)
194 (arguments
195 `(#:make-flags '("LDLIBS=-lpthread")
196 #:phases
197 (modify-phases %standard-phases
198 (add-after 'unpack 'enter-source
199 (lambda _ (chdir "liblog") #t))
200 (add-after 'install 'ldconfig
201 (lambda* (#:key outputs #:allow-other-keys)
202 (let ((out (assoc-ref outputs "out")))
203 (symlink "liblog.so.0" (string-append out "/lib/liblog.so"))
204 #t))))))
205 (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-public 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 'set-paths 'augment-CPLUS_INCLUDE_PATH
615 (lambda* (#:key inputs #:allow-other-keys)
616 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
617 ;; shadowing the version of GCC provided in native-inputs.
618 (let ((gcc (assoc-ref inputs "gcc")))
619 (setenv "CPLUS_INCLUDE_PATH"
620 (string-join
621 (delete (string-append gcc "/include/c++")
622 (string-split (getenv "CPLUS_INCLUDE_PATH")
623 #\:))
624 ":"))
625 #t)))
626 (add-after 'unpack 'enter-source
627 (lambda _ (chdir "libutils") #t))
628 (add-after 'install 'install-headers
629 (lambda* (#:key inputs outputs #:allow-other-keys)
630 (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
631 (inputs
632 `(("android-safe-iop" ,android-safe-iop)
633 ("android-libcutils" ,android-libcutils)))
634 (native-inputs
635 `(("android-bionic-uapi" ,android-bionic-uapi)
636 ("android-liblog" ,android-liblog)
637 ("gcc@5" ,gcc-5))) ; XXX: fails to build with GCC 7
638 (home-page "https://developer.android.com/")
639 (synopsis "Android utility library")
640 (description "@code{android-libutils} provides utilities for Android NDK developers.")
641 (license license:asl2.0)))
642
643 (define-public fastboot
644 (package
645 (name "fastboot")
646 (version (android-platform-version))
647 (source (android-platform-system-core version))
648 (build-system android-ndk-build-system)
649 (arguments
650 `(#:phases
651 (modify-phases %standard-phases
652 (add-after 'unpack 'enter-source
653 (lambda _
654 (chdir "fastboot")
655 #t))
656 (add-after 'enter-source 'patch-source
657 (lambda _
658 (substitute* "Android.mk"
659 (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
660 #t))
661 (replace 'install
662 (lambda* (#:key outputs #:allow-other-keys)
663 (let* ((out (assoc-ref outputs "out"))
664 (lib (string-append out "/lib"))
665 (bin (string-append out "/bin")))
666 (install-file "fastboot" bin)
667 #t))))))
668 (inputs
669 `(("adb" ,adb)
670 ("android-safe-iop" ,android-safe-iop)
671 ("android-ext4-utils" ,android-ext4-utils)
672 ("android-f2fs-utils" ,android-f2fs-utils)
673 ("android-libbase" ,android-libbase)
674 ("android-libcutils" ,android-libcutils)
675 ("android-liblog" ,android-liblog)
676 ("android-libutils" ,android-libutils)
677 ("android-libsparse" ,android-libsparse)
678 ("android-libziparchive" ,android-libziparchive)
679 ("android-libselinux" ,android-libselinux)
680 ("pcre" ,pcre)
681 ("mkbootimg" ,mkbootimg)
682 ("zlib" ,zlib)))
683 (native-inputs
684 `(("xz" ,xz)))
685 (home-page "https://developer.android.com/studio/command-line/")
686 (synopsis "Android image flasher")
687 (description
688 "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
689 (license license:asl2.0)))
690
691 (define-public android-udev-rules
692 (package
693 (name "android-udev-rules")
694 (version "20191103")
695 (source
696 (origin
697 (method git-fetch)
698 (uri (git-reference
699 (url "https://github.com/M0Rf30/android-udev-rules")
700 (commit version)))
701 (file-name (git-file-name name version))
702 (sha256
703 (base32 "0x2f2sv0x0ry7kccp47s0hlxps3hbpg37dj3xjjgpdm5hmn2cjq3"))))
704 (build-system trivial-build-system)
705 (native-inputs `(("source" ,source)))
706 (arguments
707 '(#:modules ((guix build utils))
708 #:builder
709 (begin
710 (use-modules (guix build utils))
711 (let ((source (assoc-ref %build-inputs "source")))
712 (install-file (string-append source "/51-android.rules")
713 (string-append %output "/lib/udev/rules.d"))
714 #t))))
715 (home-page "https://github.com/M0Rf30/android-udev-rules")
716 (synopsis "udev rules for Android devices")
717 (description "Provides a set of udev rules to allow using Android devices
718 with tools such as @command{adb} and @command{fastboot} without root
719 privileges. This package is intended to be added as a rule to the
720 @code{udev-service-type} in your @code{operating-system} configuration.
721 Additionally, an @code{adbusers} group must be defined and your user added to
722 it.
723
724 @emph{Simply installing this package will not have any effect.} It is meant
725 to be passed to the @code{udev} service.")
726 (license license:gpl3+)))
727
728 (define-public git-repo
729 (package
730 (name "git-repo")
731 (version "2.4.1")
732 (source
733 (origin
734 (method git-fetch)
735 (uri (git-reference
736 (url "https://gerrit.googlesource.com/git-repo")
737 (commit (string-append "v" version))))
738 (file-name (string-append "git-repo-" version "-checkout"))
739 (sha256
740 (base32 "0khg1731927gvin73dcbw1657kbfq4k7agla5rpzqcnwkk5agzg3"))))
741 (build-system python-build-system)
742 (arguments
743 `(#:phases
744 (modify-phases %standard-phases
745 (add-before 'build 'set-executable-paths
746 (lambda* (#:key inputs outputs #:allow-other-keys)
747 (let* ((out (assoc-ref outputs "out"))
748 (git (assoc-ref inputs "git"))
749 (ssh (assoc-ref inputs "ssh")))
750 (substitute* '("repo" "git_command.py")
751 (("^GIT = 'git'")
752 (string-append "GIT = '" git "/bin/git'")))
753 (substitute* "git_config.py"
754 ((" command_base = \\['ssh',")
755 (string-append " command_base = ['" ssh "/bin/ssh',")))
756 #t)))
757 (add-before 'build 'do-not-self-update
758 (lambda* (#:key outputs #:allow-other-keys)
759 ;; Setting the REPO_MAIN variable to an absolute file name is
760 ;; enough to have _FindRepo return the store main.py file. The
761 ;; self update mechanism is activated with the call to _Init() in
762 ;; main(), so we bypass it.
763
764 ;; Ticket requesting upstream to provide a mean to disable the
765 ;; self update mechanism:
766 ;; https://bugs.chromium.org/p/gerrit/issues/detail?id=12407.
767 (let* ((out (assoc-ref outputs "out"))
768 (repo-main (string-append out "/share/git-repo/main.py")))
769 (substitute* "repo"
770 (("^REPO_MAIN = .*")
771 (format #f "REPO_MAIN = ~s~%" repo-main))
772 ((" _Init\\(args, gitc_init=\\(cmd ==.*" all)
773 (string-append "True #" all)))
774 ;; Prevent repo from trying to git describe its version from
775 ;; the (disabled) self updated copy.
776 (substitute* "git_command.py"
777 (("ver = getattr\\(RepoSourceVersion.*")
778 (format #f "ver = ~s~%" ,version)))
779 (substitute* "subcmds/version.py"
780 (("rp_ver = .*")
781 (format #f "rp_ver = ~s~%" ,version)))
782 ;; Prevent repo from adding its (disabled) self update copy to
783 ;; the list of projects to fetch when using 'repo sync'.
784 (substitute* "subcmds/sync.py"
785 (("to_fetch\\.extend\\(all_projects\\).*" all)
786 (string-append "#" all))
787 (("self\\._Fetch\\(to_fetch")
788 "self._Fetch(all_projects")
789 (("_PostRepoFetch\\(rp, opt\\.repo_verify).*" all)
790 (string-append "#" all))))))
791 (delete 'build) ; nothing to build
792 (add-before 'check 'configure-git
793 (lambda _
794 (setenv "HOME" (getcwd))
795 (invoke "git" "config" "--global" "user.email" "you@example.com")
796 (invoke "git" "config" "--global" "user.name" "Your Name")))
797 (replace 'check
798 (lambda _
799 (invoke "./run_tests")))
800 (replace 'install
801 (lambda* (#:key outputs #:allow-other-keys)
802 (let* ((out (assoc-ref outputs "out"))
803 (bin-dir (string-append out "/bin"))
804 (repo-dir (string-append out "/share/" ,name)))
805 (mkdir-p bin-dir)
806 (mkdir-p repo-dir)
807 (copy-recursively "." repo-dir)
808 (delete-file-recursively (string-append repo-dir "/tests"))
809 (symlink (string-append repo-dir "/repo")
810 (string-append bin-dir "/repo"))
811 #t))))))
812 (inputs
813 ;; TODO: Add git-remote-persistent-https once it is available in guix
814 `(("git" ,git)
815 ("ssh" ,openssh)))
816 (native-inputs
817 `(("pytest" ,python-pytest)))
818 (home-page "https://code.google.com/p/git-repo/")
819 (synopsis "Helps to manage many Git repositories.")
820 (description "Repo is a tool built on top of Git. Repo helps manage many
821 Git repositories, does the uploads to revision control systems, and automates
822 parts of the development workflow. Repo is not meant to replace Git, only to
823 make it easier to work with Git. The repo command is an executable Python
824 script that you can put anywhere in your path.")
825 (license license:asl2.0)))
826
827 (define-public abootimg
828 (package
829 (name "abootimg")
830 (version "0.6")
831 (source
832 (origin
833 (method url-fetch)
834 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
835 "abootimg_" version ".orig.tar.gz"))
836 (sha256
837 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
838 (build-system gnu-build-system)
839 (arguments
840 `(#:tests? #f
841 #:phases
842 (modify-phases %standard-phases
843 (replace 'configure
844 (lambda _
845 (setenv "CC" "gcc")
846 #t))
847 (replace 'install
848 (lambda* (#:key outputs #:allow-other-keys)
849 (let* ((out (assoc-ref outputs "out"))
850 (bin (string-append out "/bin")))
851 (install-file "abootimg" bin)
852 #t))))))
853 (inputs
854 `(("libblkid" ,util-linux "lib")))
855 (home-page "https://ac100.grandou.net/abootimg")
856 (synopsis "Tool for manipulating Android Boot Images")
857 (description "This package provides a tool for manipulating old Android
858 Boot Images. @code{abootimg} can work directly on block devices, or, the
859 safest way, on a file image.")
860 (license license:gpl2+)))
861
862 (define-public python-androguard
863 (package
864 (name "python-androguard")
865 (version "3.2.1")
866 (source
867 (origin
868 ;; The pypi release doesn't have the tests, but the tests use
869 ;; packaged binaries, so we skip them.
870 (method url-fetch)
871 (uri (pypi-uri "androguard" version))
872 (sha256
873 (base32
874 "0ndsw00pkyda4i2s3wi5ap8gbk6a9d23xhhxpdbk02padv8sxkfv"))))
875 (build-system python-build-system)
876 (arguments
877 '(#:phases
878 (modify-phases %standard-phases
879 (replace 'check
880 ;; Adapted from .travis.yml
881 (lambda _
882 (invoke "nosetests" "--with-coverage" "--with-timer"
883 "--timer-top-n" "50"))))))
884 (native-inputs
885 `(("python-codecov" ,python-codecov)
886 ("python-coverage" ,python-coverage)
887 ("python-mock" ,python-mock)
888 ("python-nose" ,python-nose)
889 ("python-nose-timer" ,python-nose-timer)))
890 (propagated-inputs
891 `(("python-asn1crypto" ,python-asn1crypto)
892 ("python-colorama" ,python-colorama)
893 ("python-future" ,python-future)
894 ("python-ipython" ,python-ipython)
895 ("python-lxml" ,python-lxml)
896 ("python-matplotlib" ,python-matplotlib)
897 ("python-networkx" ,python-networkx)
898 ("python-pygments" ,python-pygments)
899 ("python-pyperclip" ,python-pyperclip)))
900 (home-page "https://github.com/androguard/androguard")
901 (synopsis "Python tool to play with Android files")
902 (description
903 "Androguard is a full Python tool to manipulate Android files. It is
904 useful for reverse engineering, analysis of Android applications and more.")
905 (license license:asl2.0)))
906
907 (define-public fdroidserver
908 (package
909 (name "fdroidserver")
910 (version "1.1.1")
911 (source
912 (origin
913 (method url-fetch)
914 (uri (pypi-uri "fdroidserver" version))
915 (sha256
916 (base32
917 "0fp7q8faicx6i6wxm717qqaham3jpilb23mvynpz6v73z7hm6wcg"))))
918 (build-system python-build-system)
919 (arguments
920 `(#:phases
921 (modify-phases %standard-phases
922 (add-after 'unpack 'fix-versioning
923 (lambda _
924 (substitute* "setup.py"
925 (("0.2.1") ,(package-version python-pyasn1-modules)))
926 #t)))))
927 (propagated-inputs
928 `(("python-androguard" ,python-androguard)
929 ("python-apache-libcloud" ,python-apache-libcloud)
930 ("python-clint" ,python-clint)
931 ("python-defusedxml" ,python-defusedxml)
932 ("python-docker-py" ,python-docker-py)
933 ("python-gitpython" ,python-gitpython)
934 ("python-mwclient" ,python-mwclient)
935 ("python-paramiko" ,python-paramiko)
936 ("python-pillow" ,python-pillow)
937 ("python-pyasn1" ,python-pyasn1)
938 ("python-pyasn1-modules" ,python-pyasn1-modules)
939 ("python-pyyaml" ,python-pyyaml)
940 ("python-qrcode" ,python-qrcode)
941 ("python-ruamel.yaml" ,python-ruamel.yaml)
942 ("python-requests" ,python-requests)
943 ("python-vagrant" ,python-vagrant)))
944 (native-inputs
945 `(("python-babel" ,python-babel)
946 ("python-bcrypt" ,python-bcrypt)
947 ("python-docker-pycreds" ,python-docker-pycreds)
948 ("python-pynacl" ,python-pynacl)
949 ("python-websocket-client" ,python-websocket-client)))
950 (home-page "https://f-droid.org")
951 (synopsis "F-Droid server tools")
952 (description
953 "The F-Droid server tools provide various scripts and tools that are used
954 to maintain F-Droid, the repository of free Android applications. You can use
955 these same tools to create your own additional or alternative repository for
956 publishing, or to assist in creating, testing and submitting metadata to the
957 main repository.")
958 (license license:agpl3+)))
959
960 (define-public enjarify
961 (package
962 (name "enjarify")
963 (version "1.0.3")
964 (home-page "https://github.com/Storyyeller/enjarify")
965 (source
966 (origin
967 (method git-fetch)
968 (uri (git-reference
969 (url home-page)
970 (commit version)))
971 (file-name (git-file-name name version))
972 (patches
973 (search-patches "enjarify-setup-py.patch"))
974 (sha256
975 (base32
976 "1nam7h1g4f1h6jla4qcjjagnyvd24dv6d5445w04q8hx07nxdapk"))))
977 (build-system python-build-system)
978 (arguments
979 `(#:phases
980 (modify-phases %standard-phases
981 (add-after 'unpack 'enjarify-wrapper-inherit-pythonpath
982 ;; enjarify sets PYTHONPATH from a shell script, overwriting
983 ;; PYTHONPATH set from guix. Comment out this line.
984 (lambda _
985 (substitute* "enjarify.sh"
986 (("export PYTHONPATH") "# export PYTHONPATH"))
987 #t))
988 (add-before 'check 'fixup-expected-test-results
989 ;; Upstream adjusted this test in commit:
990 ;; 3ae884a6485af82d300515813f537685b08dd800
991 (lambda _
992 (substitute* "tests/test2/expected.txt"
993 (("^20") "0"))
994 #t))
995 (add-before 'check 'drop-java-xss-argument
996 ;; Upstream removed this argument in order to support 32-bit
997 ;; architectures. commit: 4be0111d879aa95fdc0d9f24fe529f8c664d4093
998 (lambda _
999 (substitute* "enjarify/runtests.py"
1000 (("java -Xss515m") "java "))
1001 #t))
1002 (add-after 'install 'install-enjarify-wrapper
1003 (lambda* (#:key outputs #:allow-other-keys)
1004 (let* ((out (assoc-ref outputs "out")))
1005 (mkdir-p (string-append out "/bin/"))
1006 (copy-file "enjarify.sh" (string-append out "/bin/enjarify"))
1007 #t))))))
1008 (native-inputs `(("openjdk" ,openjdk12)))
1009 (synopsis "Translate Dalvik bytecode to equivalent Java bytecode")
1010 (description "Android applications are Java programs that run on a
1011 customized virtual machine, which is part of the Android operating system, the
1012 Dalvik VM. Their bytecode differs from the bytecode of normal Java
1013 applications. Enjarify can translate the Dalvik bytecode back to equivalent
1014 Java bytecode, which simplifies the analysis of Android applications.")
1015 (license license:asl2.0)))