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