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 HG |
37 | #:use-module (gnu packages gnupg) |
38 | #:use-module (gnu packages python) | |
39 | #:use-module (gnu packages ssh) | |
40 | #:use-module (gnu packages version-control) | |
6ef5162d DM |
41 | #:use-module (gnu packages tls) |
42 | #:use-module (gnu packages linux)) | |
5315fcfd | 43 | |
74c0ee66 DM |
44 | (define-public android-make-stub |
45 | (let ((commit "v0.1") | |
46 | (revision "21")) | |
47 | (package | |
48 | (name "android-make-stub") | |
49 | (version "0.1") | |
50 | (source | |
51 | (origin | |
52 | (method git-fetch) | |
53 | (uri (git-reference | |
54 | (url "https://github.com/daym/android-make-stub.git") | |
55 | (commit commit))) | |
56 | (file-name (string-append "android-make-stub-" | |
57 | version "-checkout")) | |
58 | (sha256 | |
59 | (base32 | |
60 | "1ni4szpcx2clf3lpzrybabwk7bgvsl6ynng7xxfc49y4jkdkk4sh")))) | |
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.") | |
78 | (license license:asl2.0)))) | |
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" | |
16c2be0b DM |
103 | "adb-add-libraries.patch" |
104 | "libziparchive-add-includes.patch")))) | |
5315fcfd JL |
105 | |
106 | (define liblog | |
107 | (package | |
108 | (name "liblog") | |
109 | (version (android-platform-version)) | |
110 | (source (android-platform-system-core version)) | |
116c69d9 | 111 | (build-system android-ndk-build-system) |
5315fcfd JL |
112 | (arguments |
113 | `(#:tests? #f ; TODO. | |
114 | #:make-flags '("CC=gcc") | |
115 | #:phases | |
116 | (modify-phases %standard-phases | |
117 | (add-after 'unpack 'enter-source | |
116c69d9 | 118 | (lambda _ (chdir "liblog") #t))))) |
5315fcfd JL |
119 | (home-page "https://developer.android.com/") |
120 | (synopsis "Logging library from the Android platform.") | |
121 | (description "@code{liblog} represents an interface to the volatile Android | |
122 | Logging system for NDK (Native) applications and libraries and contain | |
123 | interfaces for either writing or reading logs. The log buffers are divided up | |
124 | in Main, System, Radio and Events sub-logs.") | |
125 | (license license:asl2.0))) | |
126 | ||
127 | (define libbase | |
128 | (package | |
129 | (name "libbase") | |
130 | (version (android-platform-version)) | |
b98d4478 | 131 | (source (android-platform-system-core version)) |
11cb109b | 132 | (build-system android-ndk-build-system) |
5315fcfd JL |
133 | (arguments |
134 | `(#:tests? #f ; TODO. | |
11cb109b | 135 | #:make-flags '("CXXFLAGS=-std=gnu++11") |
5315fcfd JL |
136 | #:phases |
137 | (modify-phases %standard-phases | |
138 | (add-after 'unpack 'enter-source | |
11cb109b | 139 | (lambda _ (chdir "base") #t))))) |
5315fcfd JL |
140 | (inputs `(("liblog" ,liblog))) |
141 | (home-page "https://developer.android.com/") | |
142 | (synopsis "Android platform base library") | |
143 | (description "@code{libbase} is a library in common use by the | |
144 | various Android core host applications.") | |
145 | (license license:asl2.0))) | |
146 | ||
147 | (define libcutils | |
148 | (package | |
149 | (name "libcutils") | |
150 | (version (android-platform-version)) | |
151 | (source (android-platform-system-core version)) | |
152 | (build-system gnu-build-system) | |
153 | (arguments | |
154 | `(#:tests? #f ; TODO. | |
155 | #:phases | |
156 | (modify-phases %standard-phases | |
157 | (add-after 'unpack 'enter-source | |
158 | (lambda _ (chdir "libcutils") #t)) | |
159 | (add-after 'enter-source 'create-Makefile | |
160 | (lambda _ | |
161 | ;; No useful makefile is shipped, so we create one. | |
162 | (with-output-to-file "Makefile" | |
163 | (lambda _ | |
164 | (display | |
165 | (string-append | |
166 | "NAME = libcutils\n" | |
167 | "SOURCES = load_file.o socket_local_client_unix.o" | |
168 | " socket_loopback_client_unix.o socket_network_client_unix.o" | |
169 | " socket_loopback_server_unix.o socket_local_server_unix.o" | |
170 | " sockets_unix.o socket_inaddr_any_server_unix.o" | |
171 | " sockets.o\n" | |
172 | "CC = gcc\n" | |
173 | ||
174 | "CFLAGS += -fPIC\n" | |
175 | "CXXFLAGS += -std=gnu++11 -fPIC\n" | |
176 | "CPPFLAGS += -Iinclude -I../include\n" | |
177 | "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n" | |
178 | ||
179 | "build: $(SOURCES)\n" | |
180 | " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)" | |
181 | " $(LDFLAGS)\n")) | |
182 | #t)))) | |
183 | (delete 'configure) | |
184 | (replace 'install | |
185 | (lambda* (#:key outputs #:allow-other-keys) | |
186 | (let* ((out (assoc-ref outputs "out")) | |
187 | (lib (string-append out "/lib"))) | |
188 | (install-file "libcutils.so.0" lib) | |
189 | (with-directory-excursion lib | |
190 | (symlink "libcutils.so.0" "libcutils.so")) | |
191 | #t)))))) | |
192 | (home-page "https://developer.android.com/") | |
193 | (synopsis "Android platform c utils library") | |
194 | (description "@code{libcutils} is a library in common use by the | |
195 | various Android core host applications.") | |
196 | (license license:asl2.0))) | |
197 | ||
092f88a6 DM |
198 | (define-public android-libsparse |
199 | (package | |
200 | (name "android-libsparse") | |
201 | (version (android-platform-version)) | |
202 | (source (android-platform-system-core version)) | |
203 | (build-system android-ndk-build-system) | |
204 | (arguments | |
205 | `(#:tests? #f ; TODO. | |
206 | #:make-flags '("CFLAGS=-Wno-error" | |
207 | "CXXFLAGS=-fpermissive -Wno-error") | |
208 | #:phases | |
209 | (modify-phases %standard-phases | |
210 | (add-after 'unpack 'enter-source | |
211 | (lambda _ (chdir "libsparse") #t))))) | |
212 | (inputs | |
213 | `(("zlib" ,zlib))) | |
214 | (home-page "https://developer.android.com/") | |
215 | (synopsis "Android platform sparse library") | |
216 | (description "@code{android-libsparse} is a library in common use by the | |
217 | various Android core host applications.") | |
218 | (license license:asl2.0))) | |
219 | ||
16c2be0b DM |
220 | (define-public android-libziparchive |
221 | (package | |
222 | (name "android-libziparchive") | |
223 | (version (android-platform-version)) | |
224 | (source (android-platform-system-core version)) | |
225 | (build-system android-ndk-build-system) | |
226 | (arguments | |
227 | `(#:tests? #f ; TODO. | |
228 | #:make-flags '("CFLAGS=-Wno-error" | |
229 | "CXXFLAGS=-fpermissive -Wno-error -std=gnu++11") | |
230 | #:phases | |
231 | (modify-phases %standard-phases | |
232 | (add-after 'unpack 'enter-source | |
233 | (lambda _ (chdir "libziparchive") #t)) | |
234 | (add-after 'install 'install-headers | |
235 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
236 | (let ((out (assoc-ref outputs "out"))) | |
237 | (copy-recursively "../include/ziparchive" | |
238 | (string-append out "/include/ziparchive")) | |
239 | #t)))))) | |
240 | (inputs | |
241 | `(("zlib" ,zlib))) | |
242 | (home-page "https://developer.android.com/") | |
243 | (synopsis "Android platform ZIP library") | |
244 | (description "@code{android-libziparchive} is a library in common use by the | |
245 | various Android core host applications.") | |
246 | (license license:asl2.0))) | |
247 | ||
5315fcfd JL |
248 | (define-public adb |
249 | (package | |
250 | (name "adb") | |
251 | (version (android-platform-version)) | |
b98d4478 | 252 | (source (android-platform-system-core version)) |
f6e75b0d | 253 | (build-system android-ndk-build-system) |
5315fcfd | 254 | (arguments |
f6e75b0d DM |
255 | `(#:tests? #f ; TODO. |
256 | #:make-flags | |
257 | (list "CFLAGS=-Wno-error" | |
258 | "CXXFLAGS=-fpermissive -Wno-error -std=gnu++14 -D_Nonnull= -D_Nullable= -I ." | |
259 | (string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out") "/lib " | |
260 | "-Wl,-rpath=" (assoc-ref %build-inputs "openssl") "/lib -L .")) | |
261 | #:phases | |
5315fcfd JL |
262 | (modify-phases %standard-phases |
263 | (add-after 'unpack 'enter-source | |
264 | (lambda _ (chdir "adb") #t)) | |
f6e75b0d DM |
265 | (add-after 'enter-source 'make-libs-available |
266 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
267 | (substitute* "Android.mk" | |
268 | (("libcrypto_static") "libcrypto")) | |
5315fcfd | 269 | #t)) |
f6e75b0d DM |
270 | (add-after 'install 'install-headers |
271 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
272 | (install-file "diagnose_usb.h" (string-append (assoc-ref outputs "out") "/include")) | |
273 | #t))))) | |
5315fcfd JL |
274 | (inputs |
275 | `(("libbase" ,libbase) | |
276 | ("libcutils" ,libcutils) | |
f6e75b0d | 277 | ("liblog" ,liblog) |
5315fcfd JL |
278 | ("openssl" ,openssl))) |
279 | (home-page "https://developer.android.com/studio/command-line/adb.html") | |
280 | (synopsis "Android Debug Bridge") | |
281 | (description | |
282 | "@command{adb} is a versatile command line tool that lets you communicate | |
283 | with an emulator instance or connected Android device. It facilitates a variety | |
284 | of device actions, such as installing and debugging apps, and it provides access | |
285 | to a Unix shell that can run commands on the connected device or emulator.") | |
286 | (license license:asl2.0))) | |
c1151ecf | 287 | |
7175abaa DM |
288 | (define-public mkbootimg |
289 | (package | |
290 | (name "mkbootimg") | |
291 | (version (android-platform-version)) | |
292 | (source (origin | |
293 | (inherit (android-platform-system-core version)))) | |
294 | (build-system python-build-system) | |
295 | (arguments | |
296 | `(#:tests? #f | |
297 | #:phases | |
298 | (modify-phases %standard-phases | |
299 | (add-after 'unpack 'enter-source | |
300 | (lambda _ (chdir "mkbootimg") #t)) | |
301 | (delete 'configure) | |
302 | (delete 'build) | |
303 | (replace 'install | |
304 | (lambda* (#:key outputs #:allow-other-keys) | |
305 | (let* ((out (assoc-ref outputs "out")) | |
3724d375 DM |
306 | (bin (string-append out "/bin")) |
307 | (include (string-append out "/include"))) | |
7175abaa | 308 | (install-file "mkbootimg" bin) |
3724d375 | 309 | (install-file "bootimg.h" include) |
7175abaa DM |
310 | #t)))))) |
311 | (home-page "https://developer.android.com/studio/command-line/adb.html") | |
312 | (synopsis "Tool to create Android boot images") | |
313 | (description "This package provides a tool to create Android Boot | |
314 | Images.") | |
315 | (license license:asl2.0))) | |
316 | ||
0ad03eae MC |
317 | (define-public android-udev-rules |
318 | (package | |
319 | (name "android-udev-rules") | |
b45bfc9c | 320 | (version "20180112") |
0ad03eae MC |
321 | (source |
322 | (origin | |
323 | (method git-fetch) | |
324 | (uri (git-reference | |
325 | (url "https://github.com/M0Rf30/android-udev-rules") | |
326 | (commit version))) | |
327 | (file-name (string-append name "-" version "-checkout")) | |
328 | (sha256 | |
b45bfc9c | 329 | (base32 "13gj79nnd04szqlrrzzkdr6wi1fky08pi7x8xfbg0jj3d3v0giah")))) |
0ad03eae MC |
330 | (build-system trivial-build-system) |
331 | (native-inputs `(("source" ,source))) | |
332 | (arguments | |
333 | '(#:modules ((guix build utils)) | |
334 | #:builder | |
335 | (begin | |
336 | (use-modules (guix build utils)) | |
337 | (let ((source (assoc-ref %build-inputs "source"))) | |
338 | (install-file (string-append source "/51-android.rules") | |
339 | (string-append %output "/lib/udev/rules.d")))))) | |
340 | (home-page "https://github.com/M0Rf30/android-udev-rules") | |
341 | (synopsis "udev rules for Android devices") | |
342 | (description "Provides a set of udev rules to allow using Android devices | |
343 | with tools such as @command{adb} and @command{fastboot} without root | |
344 | privileges. This package is intended to be added as a rule to the | |
345 | @code{udev-service-type} in your @code{operating-system} configuration. | |
346 | Additionally, an @code{adbusers} group must be defined and your user added to | |
347 | it. | |
348 | ||
349 | @emph{Simply installing this package will not have any effect.} It is meant | |
350 | to be passed to the @code{udev} service.") | |
351 | (license license:gpl3+))) | |
352 | ||
c1151ecf HG |
353 | (define-public git-repo |
354 | (package | |
355 | (name "git-repo") | |
356 | (version "1.12.37") | |
357 | (source | |
358 | (origin | |
359 | (method git-fetch) | |
360 | (uri (git-reference | |
361 | (url "https://gerrit.googlesource.com/git-repo") | |
362 | (commit (string-append "v" version)))) | |
363 | (file-name (string-append "git-repo-" version "-checkout")) | |
364 | (sha256 | |
365 | (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd")))) | |
366 | (build-system python-build-system) | |
367 | (arguments | |
368 | `(#:python ,python-2 ; code says: "Python 3 support is … experimental." | |
369 | #:phases | |
370 | (modify-phases %standard-phases | |
371 | (add-before 'build 'set-executable-paths | |
372 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
373 | (let* ((out (assoc-ref outputs "out")) | |
374 | (git (assoc-ref inputs "git")) | |
375 | (gpg (assoc-ref inputs "gnupg")) | |
376 | (ssh (assoc-ref inputs "ssh"))) | |
377 | (substitute* '("repo" "git_command.py") | |
378 | (("^GIT = 'git' ") | |
379 | (string-append "GIT = '" git "/bin/git' "))) | |
380 | (substitute* "repo" | |
381 | ((" cmd = \\['gpg',") | |
382 | (string-append " cmd = ['" gpg "/bin/gpg',"))) | |
383 | (substitute* "git_config.py" | |
384 | ((" command_base = \\['ssh',") | |
385 | (string-append " command_base = ['" ssh "/bin/ssh',"))) | |
386 | #t))) | |
387 | (add-before 'build 'do-not-clone-this-source | |
388 | (lambda* (#:key outputs #:allow-other-keys) | |
389 | (let* ((out (assoc-ref outputs "out")) | |
390 | (repo-dir (string-append out "/share/" ,name))) | |
391 | (substitute* "repo" | |
392 | (("^def _FindRepo\\(\\):.*") | |
393 | (format #f " | |
394 | def _FindRepo(): | |
395 | '''Look for a repo installation, starting at the current directory.''' | |
396 | # Use the installed version of git-repo. | |
397 | repo_main = '~a/main.py' | |
398 | curdir = os.getcwd() | |
399 | olddir = None | |
400 | while curdir != '/' and curdir != olddir: | |
401 | dot_repo = os.path.join(curdir, repodir) | |
402 | if os.path.isdir(dot_repo): | |
403 | return (repo_main, dot_repo) | |
404 | else: | |
405 | olddir = curdir | |
406 | curdir = os.path.dirname(curdir) | |
407 | return None, '' | |
408 | ||
409 | # The remaining of this function is dead code. It was used to | |
410 | # find a git-checked-out version in the local project.\n" repo-dir)) | |
411 | ;; Neither clone, check out, nor verify the git repository | |
412 | (("(^\\s+)_Clone\\(.*\\)") "") | |
413 | (("(^\\s+)_Checkout\\(.*\\)") "") | |
414 | ((" rev = _Verify\\(.*\\)") " rev = None")) | |
415 | #t))) | |
416 | (delete 'build) ; nothing to build | |
417 | (replace 'check | |
418 | (lambda _ | |
419 | (zero? (system* "python" "-m" "nose")))) | |
420 | (replace 'install | |
421 | (lambda* (#:key outputs #:allow-other-keys) | |
422 | (let* ((out (assoc-ref outputs "out")) | |
423 | (bin-dir (string-append out "/bin")) | |
424 | (repo-dir (string-append out "/share/" ,name))) | |
425 | (mkdir-p bin-dir) | |
426 | (mkdir-p repo-dir) | |
427 | (copy-recursively "." repo-dir) | |
428 | (delete-file-recursively (string-append repo-dir "/tests")) | |
429 | (symlink (string-append repo-dir "/repo") | |
430 | (string-append bin-dir "/repo")) | |
431 | #t)))))) | |
432 | (inputs | |
433 | ;; TODO: Add git-remote-persistent-https once it is available in guix | |
434 | `(("git" ,git) | |
435 | ("gnupg" ,gnupg) | |
c695fb76 | 436 | ("ssh" ,openssh))) |
c1151ecf HG |
437 | (native-inputs |
438 | `(("nose" ,python2-nose))) | |
439 | (home-page "https://code.google.com/p/git-repo/") | |
440 | (synopsis "Helps to manage many Git repositories.") | |
441 | (description "Repo is a tool built on top of Git. Repo helps manage many | |
442 | Git repositories, does the uploads to revision control systems, and automates | |
443 | parts of the development workflow. Repo is not meant to replace Git, only to | |
444 | make it easier to work with Git. The repo command is an executable Python | |
445 | script that you can put anywhere in your path.") | |
446 | (license license:asl2.0))) | |
6ef5162d DM |
447 | |
448 | (define-public abootimg | |
449 | (package | |
450 | (name "abootimg") | |
451 | (version "0.6") | |
452 | (source | |
453 | (origin | |
454 | (method url-fetch) | |
455 | (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/" | |
456 | "abootimg_" version ".orig.tar.gz")) | |
457 | (sha256 | |
458 | (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba")))) | |
459 | (build-system gnu-build-system) | |
460 | (arguments | |
461 | `(#:tests? #f | |
462 | #:phases | |
463 | (modify-phases %standard-phases | |
464 | (replace 'configure | |
465 | (lambda _ | |
466 | (setenv "CC" "gcc") | |
467 | #t)) | |
468 | (replace 'install | |
469 | (lambda* (#:key outputs #:allow-other-keys) | |
470 | (let* ((out (assoc-ref outputs "out")) | |
471 | (bin (string-append out "/bin"))) | |
472 | (install-file "abootimg" bin) | |
473 | #t)))))) | |
474 | (inputs | |
475 | `(("libblkid" ,util-linux))) | |
476 | (home-page "https://ac100.grandou.net/abootimg") | |
477 | (synopsis "Tool for manipulating Android Boot Images") | |
478 | (description "This package provides a tool for manipulating old Android | |
479 | Boot Images. @code{abootimg} can work directly on block devices, or, the | |
480 | safest way, on a file image.") | |
481 | (license license:gpl2+))) |