gnu: 0ad-data: Avoid top-level references to 'font-bitstream-vera'.
[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>
4;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
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>
b7db2c66 8;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
2b1e80d2 9;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
8cad7adb 10;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
89c943df 11;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
5315fcfd
JL
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)
6ef5162d 30 #:use-module (guix download)
5315fcfd
JL
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
116c69d9 33 #:use-module (guix build-system android-ndk)
c1151ecf 34 #:use-module (guix build-system python)
0ad03eae 35 #:use-module (guix build-system trivial)
5315fcfd
JL
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (gnu packages)
ac257f12 38 #:use-module (gnu packages check)
16c2be0b 39 #:use-module (gnu packages compression)
76e206e6 40 #:use-module (gnu packages docker)
a747ae60 41 #:use-module (gnu packages gcc)
c1151ecf 42 #:use-module (gnu packages gnupg)
68620d62 43 #:use-module (gnu packages java)
8cad7adb 44 #:use-module (gnu packages linux)
c87ca40f 45 #:use-module (gnu packages pcre)
c1151ecf 46 #:use-module (gnu packages python)
2b1e80d2 47 #:use-module (gnu packages python-crypto)
76e206e6 48 #:use-module (gnu packages python-web)
44d10b1f 49 #:use-module (gnu packages python-xyz)
c87ca40f 50 #:use-module (gnu packages selinux)
76e206e6 51 #:use-module (gnu packages serialization)
c1151ecf 52 #:use-module (gnu packages ssh)
6ef5162d 53 #:use-module (gnu packages tls)
2b1e80d2 54 #:use-module (gnu packages version-control)
76e206e6 55 #:use-module (gnu packages virtualization)
2b1e80d2 56 #:use-module (gnu packages xdisorg)
8cad7adb 57 #:use-module (gnu packages xml))
5315fcfd 58
74c0ee66 59(define-public android-make-stub
74c0ee66
DM
60 (package
61 (name "android-make-stub")
b87fc9ab 62 (version "0.6.0")
74c0ee66
DM
63 (source
64 (origin
65 (method git-fetch)
66 (uri (git-reference
67 (url "https://github.com/daym/android-make-stub.git")
8bbf99ae 68 (commit (string-append "v" version))))
74c0ee66
DM
69 (file-name (string-append "android-make-stub-"
70 version "-checkout"))
71 (sha256
72 (base32
b87fc9ab 73 "0y1b2x96d37n6f1bp6dcx08bn08zac0cylmbfsx6mf2nahc02fhc"))))
74c0ee66
DM
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
90use their packages mostly unmodified in our Android NDK build system.")
8bbf99ae 91 (license license:asl2.0)))
74c0ee66 92
c6ee92c4
DM
93(define-public android-googletest
94 (package (inherit googletest)
95 (name "android-googletest")
89c943df
RW
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"))))
c6ee92c4
DM
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
5315fcfd
JL
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.
aaff78be 128(define (android-platform-version) "7.1.2_r36")
5315fcfd
JL
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
aaff78be 140 "1krnc2b9zfkzpdgs1dcbji59nszlx2qr723pg89m52622czc06hg"))
b98d4478
DM
141 (patches
142 (search-patches "libbase-use-own-logging.patch"
143 "libbase-fix-includes.patch"
be906ad1
DM
144 "libutils-remove-damaging-includes.patch"
145 "libutils-add-includes.patch"
16c2be0b
DM
146 "adb-add-libraries.patch"
147 "libziparchive-add-includes.patch"))))
5315fcfd 148
2d804f92
DM
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
cc39d592
DM
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
aaff78be 171 "15r4s20d7vw022f8vrc3jbghmqwdcqzprl7i2bfvdkz8z76wc1ps"))))
5315fcfd 172
7b592cfb
DM
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
8272e5e0 187(define android-liblog
5315fcfd 188 (package
8272e5e0 189 (name "android-liblog")
5315fcfd
JL
190 (version (android-platform-version))
191 (source (android-platform-system-core version))
116c69d9 192 (build-system android-ndk-build-system)
5315fcfd 193 (arguments
5c45730a 194 `(#:make-flags '("LDLIBS=-lpthread")
5315fcfd
JL
195 #:phases
196 (modify-phases %standard-phases
197 (add-after 'unpack 'enter-source
198 (lambda _ (chdir "liblog") #t))
81abe370 199 (add-after 'install 'ldconfig
5315fcfd 200 (lambda* (#:key outputs #:allow-other-keys)
81abe370
DM
201 (let ((out (assoc-ref outputs "out")))
202 (symlink "liblog.so.0" (string-append out "/lib/liblog.so"))
5315fcfd
JL
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
207Logging system for NDK (Native) applications and libraries and contain
208interfaces for either writing or reading logs. The log buffers are divided up
209in Main, System, Radio and Events sub-logs.")
210 (license license:asl2.0)))
211
01a2389a 212(define android-libbase
5315fcfd 213 (package
01a2389a 214 (name "android-libbase")
5315fcfd 215 (version (android-platform-version))
b98d4478 216 (source (android-platform-system-core version))
11cb109b 217 (build-system android-ndk-build-system)
5315fcfd 218 (arguments
c774d8e1 219 `(#:tests? #f ; Test failure: logging.UNIMPLEMENTED
5315fcfd
JL
220 #:phases
221 (modify-phases %standard-phases
222 (add-after 'unpack 'enter-source
11cb109b 223 (lambda _ (chdir "base") #t)))))
8272e5e0 224 (inputs `(("android-liblog" ,android-liblog)))
5315fcfd
JL
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
228various Android core host applications.")
229 (license license:asl2.0)))
230
3385db34 231(define android-libcutils
5315fcfd 232 (package
3385db34 233 (name "android-libcutils")
5315fcfd
JL
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"
0fe041bd 259 "CXXFLAGS += -fPIC\n"
5315fcfd
JL
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"))
cbf83e00
DM
271 (lib (string-append out "/lib"))
272 (include (string-append out "/include")))
5315fcfd
JL
273 (install-file "libcutils.so.0" lib)
274 (with-directory-excursion lib
275 (symlink "libcutils.so.0" "libcutils.so"))
cbf83e00
DM
276 (copy-recursively "../include/cutils"
277 (string-append include "/cutils"))
5315fcfd
JL
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
282various Android core host applications.")
283 (license license:asl2.0)))
284
092f88a6
DM
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
23e70a69 292 `(#:make-flags '("CFLAGS=-Wno-error"
092f88a6
DM
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
303various Android core host applications.")
304 (license license:asl2.0)))
305
16c2be0b
DM
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
e55e6d30 313 `(#:make-flags '("CFLAGS=-Wno-error"
0fe041bd 314 "CXXFLAGS=-fpermissive -Wno-error")
16c2be0b
DM
315 #:phases
316 (modify-phases %standard-phases
317 (add-after 'unpack 'enter-source
318 (lambda _ (chdir "libziparchive") #t))
e55e6d30
DM
319 (add-before 'check 'setenv
320 (lambda _
321 (setenv "ziparchive_tests_host_PARAMS" "--test_data_dir=testdata")
322 #t))
16c2be0b
DM
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)))
e55e6d30
DM
331 (native-inputs
332 `(("android-libbase" ,android-libbase)
333 ("android-libutils" ,android-libutils)
334 ("android-liblog" ,android-liblog)))
16c2be0b
DM
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
338various Android core host applications.")
339 (license license:asl2.0)))
340
5315fcfd
JL
341(define-public adb
342 (package
343 (name "adb")
344 (version (android-platform-version))
b98d4478 345 (source (android-platform-system-core version))
f6e75b0d 346 (build-system android-ndk-build-system)
5315fcfd 347 (arguments
362f3bf3 348 `(#:tests? #f ; Test failure: sysdeps_poll.fd_count
f6e75b0d
DM
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
5315fcfd
JL
355 (modify-phases %standard-phases
356 (add-after 'unpack 'enter-source
357 (lambda _ (chdir "adb") #t))
5ff6e067
MB
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))
f6e75b0d
DM
365 (add-after 'enter-source 'make-libs-available
366 (lambda* (#:key inputs outputs #:allow-other-keys)
367 (substitute* "Android.mk"
368 (("libcrypto_static") "libcrypto"))
5315fcfd 369 #t))
f6e75b0d
DM
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)))))
5315fcfd 374 (inputs
01a2389a 375 `(("android-libbase" ,android-libbase)
3385db34 376 ("android-libcutils" ,android-libcutils)
8272e5e0 377 ("android-liblog" ,android-liblog)
e960c20a 378 ("openssl" ,openssl-1.0)))
5315fcfd
JL
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
383with an emulator instance or connected Android device. It facilitates a variety
384of device actions, such as installing and debugging apps, and it provides access
385to a Unix shell that can run commands on the connected device or emulator.")
386 (license license:asl2.0)))
c1151ecf 387
7175abaa
DM
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"))
3724d375
DM
406 (bin (string-append out "/bin"))
407 (include (string-append out "/include")))
7175abaa 408 (install-file "mkbootimg" bin)
3724d375 409 (install-file "bootimg.h" include)
7175abaa
DM
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
414Images.")
415 (license license:asl2.0)))
416
7b592cfb
DM
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
437performing and checking safe integer operations. Ensure that integer
438operations do not result in silent overflow.")
439 (license license:bsd-2)))
440
cc39d592
DM
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
468that 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
c87ca40f
DM
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
c87ca40f
DM
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)
2d804f92
DM
500 ;; pcre is inlined by our package.
501 ("pcre" ,pcre)))
c87ca40f
DM
502 (home-page "https://developer.android.com/")
503 (synopsis (package-synopsis libselinux))
504 (description (package-description libselinux))
505 (license (package-license libselinux))))
506
2d804f92
DM
507(define-public android-ext4-utils
508 (package
509 (name "android-ext4-utils")
510 (version (android-platform-version))
511 (source (android-platform-system-extras version))
512 (build-system android-ndk-build-system)
513 (arguments
d3324a4b 514 `(#:make-flags
2d804f92
DM
515 (list (string-append "CPPFLAGS="
516 ;"-Wno-error "
517 "-I "
518 (assoc-ref %build-inputs "android-libselinux")
519 "/include "
520 "-I " (assoc-ref %build-inputs "android-libsparse")
521 "/include "
3385db34 522 "-I " (assoc-ref %build-inputs "android-libcutils")
2d804f92 523 "/include "
8272e5e0 524 "-I " (assoc-ref %build-inputs "android-liblog") "/include "
2d804f92
DM
525 "-I ../core/include")
526 "CFLAGS=-Wno-error"
527 "install-libext4_utils_host.a"
528 (string-append "prefix=" (assoc-ref %outputs "out")))
529 #:phases
530 (modify-phases %standard-phases
531 (add-after 'unpack 'unpack-core
532 (lambda* (#:key inputs #:allow-other-keys)
533 (mkdir-p "core")
534 (with-directory-excursion "core"
535 (invoke "tar" "axf" (assoc-ref inputs "android-core")
536 "--strip-components=1"))
537 #t))
538 (add-after 'unpack-core 'enter-source
539 (lambda _ (chdir "ext4_utils") #t))
540 (replace 'install
541 (lambda* (#:key inputs outputs #:allow-other-keys)
542 (let ((out (assoc-ref outputs "out")))
543 (copy-recursively "." (string-append out "/include")))
544 #t)))))
545 (inputs
3385db34 546 `(("android-libcutils" ,android-libcutils)
8272e5e0 547 ("android-liblog" ,android-liblog)
2d804f92
DM
548 ("android-libselinux" ,android-libselinux)
549 ("android-libsparse" ,android-libsparse)
550 ("zlib" ,zlib)))
551 (native-inputs
552 `(("android-core" ,(android-platform-system-core version))))
553 (home-page "https://developer.android.com/")
52beae7b 554 (synopsis "Android ext4 file system utilities")
2d804f92
DM
555 (description "@code{android-ext4-utils} is a library in common use by the
556Android core.")
557 (license license:asl2.0)))
558
055e6fb3
DM
559(define-public android-f2fs-utils
560 (package
561 (name "android-f2fs-utils")
562 (version (android-platform-version))
563 (source (android-platform-system-extras version))
564 (build-system android-ndk-build-system)
565 (arguments
9e8f0ff2 566 `(#:phases
055e6fb3
DM
567 (modify-phases %standard-phases
568 (add-after 'unpack 'enter-source
569 (lambda _ (chdir "f2fs_utils") #t))
570 (add-after 'install 'install-headers
571 (lambda* (#:key inputs outputs #:allow-other-keys)
572 (copy-recursively "." (string-append (assoc-ref outputs "out")
573 "/include"))
a73489e8
DM
574 #t))
575 (add-after 'install 'install-shell-scripts
576 (lambda* (#:key outputs #:allow-other-keys)
577 (let* ((out (assoc-ref outputs "out"))
578 (bin (string-append out "/bin")))
579 (patch-shebang "mkf2fsuserimg.sh")
580 (substitute* "mkf2fsuserimg.sh"
581 (("make_f2fs") (string-append bin "/make_f2fs")))
582 (install-file "mkf2fsuserimg.sh" bin)
583 #t))))))
055e6fb3
DM
584 (inputs
585 `(("f2fs-tools" ,f2fs-tools-1.7)
586 ("android-libselinux" ,android-libselinux)
587 ("android-libsparse" ,android-libsparse)
3385db34 588 ("android-libcutils" ,android-libcutils)
055e6fb3
DM
589 ("zlib" ,zlib)))
590 (home-page "https://developer.android.com/")
51eb4a6e
DM
591 (synopsis "Android f2fs utils")
592 (description "@code{android-f2fs-utils} is a library in common use by the
593Android core. It allows the user to create images for the @code{f2fs} Flash
594file system.")
055e6fb3
DM
595 (license license:asl2.0)))
596
be906ad1
DM
597(define-public android-libutils
598 (package
599 (name "android-libutils")
600 (version (android-platform-version))
601 (source (android-platform-system-core version))
602 (build-system android-ndk-build-system)
603 (arguments
604 `(#:tests? #f ; TODO
605 #:make-flags '("CXXFLAGS=-std=gnu++11 -Wno-error")
606 #:phases
607 (modify-phases %standard-phases
608 (add-after 'unpack 'enter-source
609 (lambda _ (chdir "libutils") #t))
610
611 (add-after 'install 'install-headers
612 (lambda* (#:key inputs outputs #:allow-other-keys)
613 (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
614 (inputs
615 `(("android-safe-iop" ,android-safe-iop)
3385db34 616 ("android-libcutils" ,android-libcutils)))
be906ad1 617 (native-inputs
cc59bf70 618 `(("android-bionic-uapi" ,android-bionic-uapi)
a747ae60
RW
619 ("android-liblog" ,android-liblog)
620 ("gcc" ,gcc-5))) ; XXX: fails to build with GCC 7
be906ad1
DM
621 (home-page "https://developer.android.com/")
622 (synopsis "Android utility library")
623 (description "@code{android-libutils} provides utilities for Android NDK developers.")
624 (license license:asl2.0)))
625
455b8fed
DM
626(define-public fastboot
627 (package
628 (name "fastboot")
629 (version (android-platform-version))
8297f01e 630 (source (android-platform-system-core version))
455b8fed
DM
631 (build-system android-ndk-build-system)
632 (arguments
0fe041bd 633 `(#:phases
455b8fed 634 (modify-phases %standard-phases
455b8fed
DM
635 (add-after 'unpack 'enter-source
636 (lambda _
8297f01e
DM
637 (chdir "fastboot")
638 #t))
639 (add-after 'enter-source 'patch-source
640 (lambda _
641 (substitute* "Android.mk"
642 (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
455b8fed 643 #t))
455b8fed
DM
644 (replace 'install
645 (lambda* (#:key outputs #:allow-other-keys)
646 (let* ((out (assoc-ref outputs "out"))
647 (lib (string-append out "/lib"))
648 (bin (string-append out "/bin")))
649 (install-file "fastboot" bin)
b913d1ea 650 #t))))))
455b8fed
DM
651 (inputs
652 `(("adb" ,adb)
653 ("android-safe-iop" ,android-safe-iop)
654 ("android-ext4-utils" ,android-ext4-utils)
655 ("android-f2fs-utils" ,android-f2fs-utils)
01a2389a 656 ("android-libbase" ,android-libbase)
3385db34 657 ("android-libcutils" ,android-libcutils)
8272e5e0 658 ("android-liblog" ,android-liblog)
455b8fed
DM
659 ("android-libutils" ,android-libutils)
660 ("android-libsparse" ,android-libsparse)
661 ("android-libziparchive" ,android-libziparchive)
662 ("android-libselinux" ,android-libselinux)
663 ("pcre" ,pcre)
664 ("mkbootimg" ,mkbootimg)
455b8fed
DM
665 ("zlib" ,zlib)))
666 (native-inputs
8297f01e 667 `(("xz" ,xz)))
455b8fed
DM
668 (home-page "https://developer.android.com/studio/command-line/")
669 (synopsis "Android image flasher")
670 (description
671 "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
672 (license license:asl2.0)))
673
0ad03eae
MC
674(define-public android-udev-rules
675 (package
676 (name "android-udev-rules")
b7db2c66 677 (version "20191103")
0ad03eae
MC
678 (source
679 (origin
680 (method git-fetch)
681 (uri (git-reference
682 (url "https://github.com/M0Rf30/android-udev-rules")
683 (commit version)))
105b5e16 684 (file-name (git-file-name name version))
0ad03eae 685 (sha256
b7db2c66 686 (base32 "0x2f2sv0x0ry7kccp47s0hlxps3hbpg37dj3xjjgpdm5hmn2cjq3"))))
0ad03eae
MC
687 (build-system trivial-build-system)
688 (native-inputs `(("source" ,source)))
689 (arguments
690 '(#:modules ((guix build utils))
691 #:builder
692 (begin
693 (use-modules (guix build utils))
694 (let ((source (assoc-ref %build-inputs "source")))
695 (install-file (string-append source "/51-android.rules")
e3cfef22
MW
696 (string-append %output "/lib/udev/rules.d"))
697 #t))))
0ad03eae
MC
698 (home-page "https://github.com/M0Rf30/android-udev-rules")
699 (synopsis "udev rules for Android devices")
700 (description "Provides a set of udev rules to allow using Android devices
701with tools such as @command{adb} and @command{fastboot} without root
702privileges. This package is intended to be added as a rule to the
703@code{udev-service-type} in your @code{operating-system} configuration.
704Additionally, an @code{adbusers} group must be defined and your user added to
705it.
706
707@emph{Simply installing this package will not have any effect.} It is meant
708to be passed to the @code{udev} service.")
709 (license license:gpl3+)))
710
c1151ecf
HG
711(define-public git-repo
712 (package
713 (name "git-repo")
714 (version "1.12.37")
715 (source
716 (origin
717 (method git-fetch)
718 (uri (git-reference
719 (url "https://gerrit.googlesource.com/git-repo")
720 (commit (string-append "v" version))))
721 (file-name (string-append "git-repo-" version "-checkout"))
722 (sha256
723 (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd"))))
724 (build-system python-build-system)
725 (arguments
726 `(#:python ,python-2 ; code says: "Python 3 support is … experimental."
727 #:phases
728 (modify-phases %standard-phases
729 (add-before 'build 'set-executable-paths
730 (lambda* (#:key inputs outputs #:allow-other-keys)
731 (let* ((out (assoc-ref outputs "out"))
732 (git (assoc-ref inputs "git"))
733 (gpg (assoc-ref inputs "gnupg"))
734 (ssh (assoc-ref inputs "ssh")))
735 (substitute* '("repo" "git_command.py")
736 (("^GIT = 'git' ")
737 (string-append "GIT = '" git "/bin/git' ")))
738 (substitute* "repo"
739 ((" cmd = \\['gpg',")
740 (string-append " cmd = ['" gpg "/bin/gpg',")))
741 (substitute* "git_config.py"
742 ((" command_base = \\['ssh',")
743 (string-append " command_base = ['" ssh "/bin/ssh',")))
744 #t)))
745 (add-before 'build 'do-not-clone-this-source
746 (lambda* (#:key outputs #:allow-other-keys)
747 (let* ((out (assoc-ref outputs "out"))
748 (repo-dir (string-append out "/share/" ,name)))
749 (substitute* "repo"
750 (("^def _FindRepo\\(\\):.*")
751 (format #f "
752def _FindRepo():
753 '''Look for a repo installation, starting at the current directory.'''
754 # Use the installed version of git-repo.
755 repo_main = '~a/main.py'
756 curdir = os.getcwd()
757 olddir = None
758 while curdir != '/' and curdir != olddir:
759 dot_repo = os.path.join(curdir, repodir)
760 if os.path.isdir(dot_repo):
761 return (repo_main, dot_repo)
762 else:
763 olddir = curdir
764 curdir = os.path.dirname(curdir)
765 return None, ''
766
767 # The remaining of this function is dead code. It was used to
768 # find a git-checked-out version in the local project.\n" repo-dir))
769 ;; Neither clone, check out, nor verify the git repository
770 (("(^\\s+)_Clone\\(.*\\)") "")
771 (("(^\\s+)_Checkout\\(.*\\)") "")
772 ((" rev = _Verify\\(.*\\)") " rev = None"))
773 #t)))
774 (delete 'build) ; nothing to build
775 (replace 'check
776 (lambda _
562a0776 777 (invoke "python" "-m" "nose")))
c1151ecf
HG
778 (replace 'install
779 (lambda* (#:key outputs #:allow-other-keys)
780 (let* ((out (assoc-ref outputs "out"))
781 (bin-dir (string-append out "/bin"))
782 (repo-dir (string-append out "/share/" ,name)))
783 (mkdir-p bin-dir)
784 (mkdir-p repo-dir)
785 (copy-recursively "." repo-dir)
786 (delete-file-recursively (string-append repo-dir "/tests"))
787 (symlink (string-append repo-dir "/repo")
788 (string-append bin-dir "/repo"))
789 #t))))))
790 (inputs
791 ;; TODO: Add git-remote-persistent-https once it is available in guix
792 `(("git" ,git)
793 ("gnupg" ,gnupg)
c695fb76 794 ("ssh" ,openssh)))
c1151ecf
HG
795 (native-inputs
796 `(("nose" ,python2-nose)))
797 (home-page "https://code.google.com/p/git-repo/")
798 (synopsis "Helps to manage many Git repositories.")
799 (description "Repo is a tool built on top of Git. Repo helps manage many
800Git repositories, does the uploads to revision control systems, and automates
801parts of the development workflow. Repo is not meant to replace Git, only to
802make it easier to work with Git. The repo command is an executable Python
803script that you can put anywhere in your path.")
804 (license license:asl2.0)))
6ef5162d
DM
805
806(define-public abootimg
807 (package
808 (name "abootimg")
809 (version "0.6")
810 (source
811 (origin
812 (method url-fetch)
813 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
814 "abootimg_" version ".orig.tar.gz"))
815 (sha256
816 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
817 (build-system gnu-build-system)
818 (arguments
819 `(#:tests? #f
820 #:phases
821 (modify-phases %standard-phases
822 (replace 'configure
823 (lambda _
824 (setenv "CC" "gcc")
825 #t))
826 (replace 'install
827 (lambda* (#:key outputs #:allow-other-keys)
828 (let* ((out (assoc-ref outputs "out"))
829 (bin (string-append out "/bin")))
830 (install-file "abootimg" bin)
831 #t))))))
832 (inputs
833 `(("libblkid" ,util-linux)))
834 (home-page "https://ac100.grandou.net/abootimg")
835 (synopsis "Tool for manipulating Android Boot Images")
836 (description "This package provides a tool for manipulating old Android
837Boot Images. @code{abootimg} can work directly on block devices, or, the
838safest way, on a file image.")
839 (license license:gpl2+)))
2b1e80d2
EF
840
841(define-public python-androguard
842 (package
843 (name "python-androguard")
844 (version "3.2.1")
845 (source
846 (origin
847 ;; The pypi release doesn't have the tests, but the tests use
848 ;; packaged binaries, so we skip them.
849 (method url-fetch)
850 (uri (pypi-uri "androguard" version))
851 (sha256
852 (base32
853 "0ndsw00pkyda4i2s3wi5ap8gbk6a9d23xhhxpdbk02padv8sxkfv"))))
854 (build-system python-build-system)
855 (arguments
856 '(#:phases
857 (modify-phases %standard-phases
858 (replace 'check
859 ;; Adapted from .travis.yml
860 (lambda _
861 (invoke "nosetests" "--with-coverage" "--with-timer"
862 "--timer-top-n" "50"))))))
863 (native-inputs
864 `(("python-codecov" ,python-codecov)
865 ("python-coverage" ,python-coverage)
866 ("python-mock" ,python-mock)
867 ("python-nose" ,python-nose)
868 ("python-nose-timer" ,python-nose-timer)))
869 (propagated-inputs
870 `(("python-asn1crypto" ,python-asn1crypto)
871 ("python-colorama" ,python-colorama)
872 ("python-future" ,python-future)
873 ("python-ipython" ,python-ipython)
874 ("python-lxml" ,python-lxml)
875 ("python-matplotlib" ,python-matplotlib)
876 ("python-networkx" ,python-networkx)
877 ("python-pygments" ,python-pygments)
878 ("python-pyperclip" ,python-pyperclip)))
879 (home-page "https://github.com/androguard/androguard")
880 (synopsis "Python tool to play with Android files")
881 (description
882 "Androguard is a full Python tool to manipulate Android files. It is
883useful for reverse engineering, analysis of Android applications and more.")
884 (license license:asl2.0)))
76e206e6
EF
885
886(define-public fdroidserver
887 (package
888 (name "fdroidserver")
8cad7adb 889 (version "1.1.1")
76e206e6
EF
890 (source
891 (origin
892 (method url-fetch)
893 (uri (pypi-uri "fdroidserver" version))
894 (sha256
895 (base32
8cad7adb 896 "0fp7q8faicx6i6wxm717qqaham3jpilb23mvynpz6v73z7hm6wcg"))))
76e206e6
EF
897 (build-system python-build-system)
898 (arguments
899 `(#:phases
900 (modify-phases %standard-phases
901 (add-after 'unpack 'fix-versioning
902 (lambda _
903 (substitute* "setup.py"
904 (("0.2.1") ,(package-version python-pyasn1-modules)))
905 #t)))))
906 (propagated-inputs
907 `(("python-androguard" ,python-androguard)
908 ("python-apache-libcloud" ,python-apache-libcloud)
909 ("python-clint" ,python-clint)
8cad7adb 910 ("python-defusedxml" ,python-defusedxml)
76e206e6
EF
911 ("python-docker-py" ,python-docker-py)
912 ("python-gitpython" ,python-gitpython)
913 ("python-mwclient" ,python-mwclient)
914 ("python-paramiko" ,python-paramiko)
915 ("python-pillow" ,python-pillow)
916 ("python-pyasn1" ,python-pyasn1)
917 ("python-pyasn1-modules" ,python-pyasn1-modules)
918 ("python-pyyaml" ,python-pyyaml)
919 ("python-qrcode" ,python-qrcode)
920 ("python-ruamel.yaml" ,python-ruamel.yaml)
921 ("python-requests" ,python-requests)
922 ("python-vagrant" ,python-vagrant)))
923 (native-inputs
924 `(("python-babel" ,python-babel)
925 ("python-bcrypt" ,python-bcrypt)
926 ("python-docker-pycreds" ,python-docker-pycreds)
927 ("python-pynacl" ,python-pynacl)
928 ("python-websocket-client" ,python-websocket-client)))
929 (home-page "https://f-droid.org")
930 (synopsis "F-Droid server tools")
931 (description
932 "The F-Droid server tools provide various scripts and tools that are used
933to maintain F-Droid, the repository of free Android applications. You can use
934these same tools to create your own additional or alternative repository for
935publishing, or to assist in creating, testing and submitting metadata to the
936main repository.")
937 (license license:agpl3+)))
68620d62
VC
938
939(define-public enjarify
940 (package
941 (name "enjarify")
942 (version "1.0.3")
943 (home-page "https://github.com/Storyyeller/enjarify")
944 (source
945 (origin
946 (method git-fetch)
947 (uri (git-reference
948 (url home-page)
949 (commit version)))
950 (file-name (git-file-name name version))
951 (patches
952 (search-patches "enjarify-setup-py.patch"))
953 (sha256
954 (base32
955 "1nam7h1g4f1h6jla4qcjjagnyvd24dv6d5445w04q8hx07nxdapk"))))
956 (build-system python-build-system)
957 (arguments
958 `(#:phases
959 (modify-phases %standard-phases
960 (add-after 'unpack 'enjarify-wrapper-inherit-pythonpath
961 ;; enjarify sets PYTHONPATH from a shell script, overwriting
962 ;; PYTHONPATH set from guix. Comment out this line.
963 (lambda _
964 (substitute* "enjarify.sh"
965 (("export PYTHONPATH") "# export PYTHONPATH"))
966 #t))
967 (add-before 'check 'fixup-expected-test-results
968 ;; Upstream adjusted this test in commit:
969 ;; 3ae884a6485af82d300515813f537685b08dd800
970 (lambda _
971 (substitute* "tests/test2/expected.txt"
972 (("^20") "0"))
973 #t))
974 (add-before 'check 'drop-java-xss-argument
975 ;; Upstream removed this argument in order to support 32-bit
976 ;; architectures. commit: 4be0111d879aa95fdc0d9f24fe529f8c664d4093
977 (lambda _
978 (substitute* "enjarify/runtests.py"
979 (("java -Xss515m") "java "))
980 #t))
981 (add-after 'install 'install-enjarify-wrapper
982 (lambda* (#:key outputs #:allow-other-keys)
983 (let* ((out (assoc-ref outputs "out")))
984 (mkdir-p (string-append out "/bin/"))
985 (copy-file "enjarify.sh" (string-append out "/bin/enjarify"))
986 #t))))))
3eb4adc2 987 (native-inputs `(("openjdk" ,openjdk12)))
68620d62
VC
988 (synopsis "Translate Dalvik bytecode to equivalent Java bytecode")
989 (description "Android applications are Java programs that run on a
990customized virtual machine, which is part of the Android operating system, the
991Dalvik VM. Their bytecode differs from the bytecode of normal Java
992applications. Enjarify can translate the Dalvik bytecode back to equivalent
993Java bytecode, which simplifies the analysis of Android applications.")
994 (license license:asl2.0)))