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