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