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