gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[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>
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
68 (url "https://github.com/daym/android-make-stub.git")
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
102 (url "https://github.com/google/googletest.git")
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
614 (add-after 'unpack 'enter-source
615 (lambda _ (chdir "libutils") #t))
616
617 (add-after 'install 'install-headers
618 (lambda* (#:key inputs outputs #:allow-other-keys)
619 (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
620 (inputs
621 `(("android-safe-iop" ,android-safe-iop)
3385db34 622 ("android-libcutils" ,android-libcutils)))
be906ad1 623 (native-inputs
cc59bf70 624 `(("android-bionic-uapi" ,android-bionic-uapi)
a747ae60
RW
625 ("android-liblog" ,android-liblog)
626 ("gcc" ,gcc-5))) ; XXX: fails to build with GCC 7
be906ad1
DM
627 (home-page "https://developer.android.com/")
628 (synopsis "Android utility library")
629 (description "@code{android-libutils} provides utilities for Android NDK developers.")
630 (license license:asl2.0)))
631
455b8fed
DM
632(define-public fastboot
633 (package
634 (name "fastboot")
635 (version (android-platform-version))
8297f01e 636 (source (android-platform-system-core version))
455b8fed
DM
637 (build-system android-ndk-build-system)
638 (arguments
0fe041bd 639 `(#:phases
455b8fed 640 (modify-phases %standard-phases
455b8fed
DM
641 (add-after 'unpack 'enter-source
642 (lambda _
8297f01e
DM
643 (chdir "fastboot")
644 #t))
645 (add-after 'enter-source 'patch-source
646 (lambda _
647 (substitute* "Android.mk"
648 (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
455b8fed 649 #t))
455b8fed
DM
650 (replace 'install
651 (lambda* (#:key outputs #:allow-other-keys)
652 (let* ((out (assoc-ref outputs "out"))
653 (lib (string-append out "/lib"))
654 (bin (string-append out "/bin")))
655 (install-file "fastboot" bin)
b913d1ea 656 #t))))))
455b8fed
DM
657 (inputs
658 `(("adb" ,adb)
659 ("android-safe-iop" ,android-safe-iop)
660 ("android-ext4-utils" ,android-ext4-utils)
661 ("android-f2fs-utils" ,android-f2fs-utils)
01a2389a 662 ("android-libbase" ,android-libbase)
3385db34 663 ("android-libcutils" ,android-libcutils)
8272e5e0 664 ("android-liblog" ,android-liblog)
455b8fed
DM
665 ("android-libutils" ,android-libutils)
666 ("android-libsparse" ,android-libsparse)
667 ("android-libziparchive" ,android-libziparchive)
668 ("android-libselinux" ,android-libselinux)
669 ("pcre" ,pcre)
670 ("mkbootimg" ,mkbootimg)
455b8fed
DM
671 ("zlib" ,zlib)))
672 (native-inputs
8297f01e 673 `(("xz" ,xz)))
455b8fed
DM
674 (home-page "https://developer.android.com/studio/command-line/")
675 (synopsis "Android image flasher")
676 (description
677 "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
678 (license license:asl2.0)))
679
0ad03eae
MC
680(define-public android-udev-rules
681 (package
682 (name "android-udev-rules")
b7db2c66 683 (version "20191103")
0ad03eae
MC
684 (source
685 (origin
686 (method git-fetch)
687 (uri (git-reference
688 (url "https://github.com/M0Rf30/android-udev-rules")
689 (commit version)))
105b5e16 690 (file-name (git-file-name name version))
0ad03eae 691 (sha256
b7db2c66 692 (base32 "0x2f2sv0x0ry7kccp47s0hlxps3hbpg37dj3xjjgpdm5hmn2cjq3"))))
0ad03eae
MC
693 (build-system trivial-build-system)
694 (native-inputs `(("source" ,source)))
695 (arguments
696 '(#:modules ((guix build utils))
697 #:builder
698 (begin
699 (use-modules (guix build utils))
700 (let ((source (assoc-ref %build-inputs "source")))
701 (install-file (string-append source "/51-android.rules")
e3cfef22
MW
702 (string-append %output "/lib/udev/rules.d"))
703 #t))))
0ad03eae
MC
704 (home-page "https://github.com/M0Rf30/android-udev-rules")
705 (synopsis "udev rules for Android devices")
706 (description "Provides a set of udev rules to allow using Android devices
707with tools such as @command{adb} and @command{fastboot} without root
708privileges. This package is intended to be added as a rule to the
709@code{udev-service-type} in your @code{operating-system} configuration.
710Additionally, an @code{adbusers} group must be defined and your user added to
711it.
712
713@emph{Simply installing this package will not have any effect.} It is meant
714to be passed to the @code{udev} service.")
715 (license license:gpl3+)))
716
c1151ecf
HG
717(define-public git-repo
718 (package
719 (name "git-repo")
0c015608 720 (version "2.4.1")
c1151ecf
HG
721 (source
722 (origin
723 (method git-fetch)
724 (uri (git-reference
725 (url "https://gerrit.googlesource.com/git-repo")
726 (commit (string-append "v" version))))
727 (file-name (string-append "git-repo-" version "-checkout"))
728 (sha256
0c015608 729 (base32 "0khg1731927gvin73dcbw1657kbfq4k7agla5rpzqcnwkk5agzg3"))))
c1151ecf
HG
730 (build-system python-build-system)
731 (arguments
af52ba64 732 `(#:phases
c1151ecf
HG
733 (modify-phases %standard-phases
734 (add-before 'build 'set-executable-paths
735 (lambda* (#:key inputs outputs #:allow-other-keys)
736 (let* ((out (assoc-ref outputs "out"))
737 (git (assoc-ref inputs "git"))
c1151ecf
HG
738 (ssh (assoc-ref inputs "ssh")))
739 (substitute* '("repo" "git_command.py")
af52ba64
MC
740 (("^GIT = 'git'")
741 (string-append "GIT = '" git "/bin/git'")))
c1151ecf
HG
742 (substitute* "git_config.py"
743 ((" command_base = \\['ssh',")
744 (string-append " command_base = ['" ssh "/bin/ssh',")))
745 #t)))
e64c5a8f 746 (add-before 'build 'do-not-self-update
c1151ecf 747 (lambda* (#:key outputs #:allow-other-keys)
e64c5a8f
MC
748 ;; Setting the REPO_MAIN variable to an absolute file name is
749 ;; enough to have _FindRepo return the store main.py file. The
750 ;; self update mechanism is activated with the call to _Init() in
751 ;; main(), so we bypass it.
752
753 ;; Ticket requesting upstream to provide a mean to disable the
754 ;; self update mechanism:
755 ;; https://bugs.chromium.org/p/gerrit/issues/detail?id=12407.
c1151ecf 756 (let* ((out (assoc-ref outputs "out"))
e64c5a8f 757 (repo-main (string-append out "/share/git-repo/main.py")))
c1151ecf 758 (substitute* "repo"
e64c5a8f
MC
759 (("^REPO_MAIN = .*")
760 (format #f "REPO_MAIN = ~s~%" repo-main))
761 ((" _Init\\(args, gitc_init=\\(cmd ==.*" all)
762 (string-append "True #" all)))
763 ;; Prevent repo from trying to git describe its version from
764 ;; the (disabled) self updated copy.
765 (substitute* "git_command.py"
766 (("ver = getattr\\(RepoSourceVersion.*")
767 (format #f "ver = ~s~%" ,version)))
768 (substitute* "subcmds/version.py"
769 (("rp_ver = .*")
770 (format #f "rp_ver = ~s~%" ,version)))
771 ;; Prevent repo from adding its (disabled) self update copy to
772 ;; the list of projects to fetch when using 'repo sync'.
773 (substitute* "subcmds/sync.py"
774 (("to_fetch\\.extend\\(all_projects\\).*" all)
775 (string-append "#" all))
776 (("self\\._Fetch\\(to_fetch")
777 "self._Fetch(all_projects")
778 (("_PostRepoFetch\\(rp, opt\\.repo_verify).*" all)
779 (string-append "#" all))))))
c1151ecf 780 (delete 'build) ; nothing to build
af52ba64
MC
781 (add-before 'check 'configure-git
782 (lambda _
783 (setenv "HOME" (getcwd))
784 (invoke "git" "config" "--global" "user.email" "you@example.com")
785 (invoke "git" "config" "--global" "user.name" "Your Name")))
c1151ecf
HG
786 (replace 'check
787 (lambda _
af52ba64 788 (invoke "./run_tests")))
c1151ecf
HG
789 (replace 'install
790 (lambda* (#:key outputs #:allow-other-keys)
791 (let* ((out (assoc-ref outputs "out"))
792 (bin-dir (string-append out "/bin"))
793 (repo-dir (string-append out "/share/" ,name)))
794 (mkdir-p bin-dir)
795 (mkdir-p repo-dir)
796 (copy-recursively "." repo-dir)
797 (delete-file-recursively (string-append repo-dir "/tests"))
798 (symlink (string-append repo-dir "/repo")
799 (string-append bin-dir "/repo"))
800 #t))))))
801 (inputs
802 ;; TODO: Add git-remote-persistent-https once it is available in guix
803 `(("git" ,git)
c695fb76 804 ("ssh" ,openssh)))
c1151ecf 805 (native-inputs
af52ba64 806 `(("pytest" ,python-pytest)))
c1151ecf
HG
807 (home-page "https://code.google.com/p/git-repo/")
808 (synopsis "Helps to manage many Git repositories.")
809 (description "Repo is a tool built on top of Git. Repo helps manage many
810Git repositories, does the uploads to revision control systems, and automates
811parts of the development workflow. Repo is not meant to replace Git, only to
812make it easier to work with Git. The repo command is an executable Python
813script that you can put anywhere in your path.")
814 (license license:asl2.0)))
6ef5162d
DM
815
816(define-public abootimg
817 (package
818 (name "abootimg")
819 (version "0.6")
820 (source
821 (origin
822 (method url-fetch)
823 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
824 "abootimg_" version ".orig.tar.gz"))
825 (sha256
826 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
827 (build-system gnu-build-system)
828 (arguments
829 `(#:tests? #f
830 #:phases
831 (modify-phases %standard-phases
832 (replace 'configure
833 (lambda _
834 (setenv "CC" "gcc")
835 #t))
836 (replace 'install
837 (lambda* (#:key outputs #:allow-other-keys)
838 (let* ((out (assoc-ref outputs "out"))
839 (bin (string-append out "/bin")))
840 (install-file "abootimg" bin)
841 #t))))))
842 (inputs
843 `(("libblkid" ,util-linux)))
844 (home-page "https://ac100.grandou.net/abootimg")
845 (synopsis "Tool for manipulating Android Boot Images")
846 (description "This package provides a tool for manipulating old Android
847Boot Images. @code{abootimg} can work directly on block devices, or, the
848safest way, on a file image.")
849 (license license:gpl2+)))
2b1e80d2
EF
850
851(define-public python-androguard
852 (package
853 (name "python-androguard")
854 (version "3.2.1")
855 (source
856 (origin
857 ;; The pypi release doesn't have the tests, but the tests use
858 ;; packaged binaries, so we skip them.
859 (method url-fetch)
860 (uri (pypi-uri "androguard" version))
861 (sha256
862 (base32
863 "0ndsw00pkyda4i2s3wi5ap8gbk6a9d23xhhxpdbk02padv8sxkfv"))))
864 (build-system python-build-system)
865 (arguments
866 '(#:phases
867 (modify-phases %standard-phases
868 (replace 'check
869 ;; Adapted from .travis.yml
870 (lambda _
871 (invoke "nosetests" "--with-coverage" "--with-timer"
872 "--timer-top-n" "50"))))))
873 (native-inputs
874 `(("python-codecov" ,python-codecov)
875 ("python-coverage" ,python-coverage)
876 ("python-mock" ,python-mock)
877 ("python-nose" ,python-nose)
878 ("python-nose-timer" ,python-nose-timer)))
879 (propagated-inputs
880 `(("python-asn1crypto" ,python-asn1crypto)
881 ("python-colorama" ,python-colorama)
882 ("python-future" ,python-future)
883 ("python-ipython" ,python-ipython)
884 ("python-lxml" ,python-lxml)
885 ("python-matplotlib" ,python-matplotlib)
886 ("python-networkx" ,python-networkx)
887 ("python-pygments" ,python-pygments)
888 ("python-pyperclip" ,python-pyperclip)))
889 (home-page "https://github.com/androguard/androguard")
890 (synopsis "Python tool to play with Android files")
891 (description
892 "Androguard is a full Python tool to manipulate Android files. It is
893useful for reverse engineering, analysis of Android applications and more.")
894 (license license:asl2.0)))
76e206e6
EF
895
896(define-public fdroidserver
897 (package
898 (name "fdroidserver")
8cad7adb 899 (version "1.1.1")
76e206e6
EF
900 (source
901 (origin
902 (method url-fetch)
903 (uri (pypi-uri "fdroidserver" version))
904 (sha256
905 (base32
8cad7adb 906 "0fp7q8faicx6i6wxm717qqaham3jpilb23mvynpz6v73z7hm6wcg"))))
76e206e6
EF
907 (build-system python-build-system)
908 (arguments
909 `(#:phases
910 (modify-phases %standard-phases
911 (add-after 'unpack 'fix-versioning
912 (lambda _
913 (substitute* "setup.py"
914 (("0.2.1") ,(package-version python-pyasn1-modules)))
915 #t)))))
916 (propagated-inputs
917 `(("python-androguard" ,python-androguard)
918 ("python-apache-libcloud" ,python-apache-libcloud)
919 ("python-clint" ,python-clint)
8cad7adb 920 ("python-defusedxml" ,python-defusedxml)
76e206e6
EF
921 ("python-docker-py" ,python-docker-py)
922 ("python-gitpython" ,python-gitpython)
923 ("python-mwclient" ,python-mwclient)
924 ("python-paramiko" ,python-paramiko)
925 ("python-pillow" ,python-pillow)
926 ("python-pyasn1" ,python-pyasn1)
927 ("python-pyasn1-modules" ,python-pyasn1-modules)
928 ("python-pyyaml" ,python-pyyaml)
929 ("python-qrcode" ,python-qrcode)
930 ("python-ruamel.yaml" ,python-ruamel.yaml)
931 ("python-requests" ,python-requests)
932 ("python-vagrant" ,python-vagrant)))
933 (native-inputs
934 `(("python-babel" ,python-babel)
935 ("python-bcrypt" ,python-bcrypt)
936 ("python-docker-pycreds" ,python-docker-pycreds)
937 ("python-pynacl" ,python-pynacl)
938 ("python-websocket-client" ,python-websocket-client)))
939 (home-page "https://f-droid.org")
940 (synopsis "F-Droid server tools")
941 (description
942 "The F-Droid server tools provide various scripts and tools that are used
943to maintain F-Droid, the repository of free Android applications. You can use
944these same tools to create your own additional or alternative repository for
945publishing, or to assist in creating, testing and submitting metadata to the
946main repository.")
947 (license license:agpl3+)))
68620d62
VC
948
949(define-public enjarify
950 (package
951 (name "enjarify")
952 (version "1.0.3")
953 (home-page "https://github.com/Storyyeller/enjarify")
954 (source
955 (origin
956 (method git-fetch)
957 (uri (git-reference
958 (url home-page)
959 (commit version)))
960 (file-name (git-file-name name version))
961 (patches
962 (search-patches "enjarify-setup-py.patch"))
963 (sha256
964 (base32
965 "1nam7h1g4f1h6jla4qcjjagnyvd24dv6d5445w04q8hx07nxdapk"))))
966 (build-system python-build-system)
967 (arguments
968 `(#:phases
969 (modify-phases %standard-phases
970 (add-after 'unpack 'enjarify-wrapper-inherit-pythonpath
971 ;; enjarify sets PYTHONPATH from a shell script, overwriting
972 ;; PYTHONPATH set from guix. Comment out this line.
973 (lambda _
974 (substitute* "enjarify.sh"
975 (("export PYTHONPATH") "# export PYTHONPATH"))
976 #t))
977 (add-before 'check 'fixup-expected-test-results
978 ;; Upstream adjusted this test in commit:
979 ;; 3ae884a6485af82d300515813f537685b08dd800
980 (lambda _
981 (substitute* "tests/test2/expected.txt"
982 (("^20") "0"))
983 #t))
984 (add-before 'check 'drop-java-xss-argument
985 ;; Upstream removed this argument in order to support 32-bit
986 ;; architectures. commit: 4be0111d879aa95fdc0d9f24fe529f8c664d4093
987 (lambda _
988 (substitute* "enjarify/runtests.py"
989 (("java -Xss515m") "java "))
990 #t))
991 (add-after 'install 'install-enjarify-wrapper
992 (lambda* (#:key outputs #:allow-other-keys)
993 (let* ((out (assoc-ref outputs "out")))
994 (mkdir-p (string-append out "/bin/"))
995 (copy-file "enjarify.sh" (string-append out "/bin/enjarify"))
996 #t))))))
3eb4adc2 997 (native-inputs `(("openjdk" ,openjdk12)))
68620d62
VC
998 (synopsis "Translate Dalvik bytecode to equivalent Java bytecode")
999 (description "Android applications are Java programs that run on a
1000customized virtual machine, which is part of the Android operating system, the
1001Dalvik VM. Their bytecode differs from the bytecode of normal Java
1002applications. Enjarify can translate the Dalvik bytecode back to equivalent
1003Java bytecode, which simplifies the analysis of Android applications.")
1004 (license license:asl2.0)))