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