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