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