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