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