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