gnu: w3m: Update to 0.5.3+git20180125 [fixes CVE-2018-{6196,6197,6198}].
[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)
c1151ecf 30 #:use-module (guix build-system python)
0ad03eae 31 #:use-module (guix build-system trivial)
5315fcfd
JL
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (gnu packages)
ac257f12 34 #:use-module (gnu packages check)
c1151ecf
HG
35 #:use-module (gnu packages gnupg)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages ssh)
38 #:use-module (gnu packages version-control)
6ef5162d
DM
39 #:use-module (gnu packages tls)
40 #:use-module (gnu packages linux))
5315fcfd
JL
41
42;; The Makefiles that we add are largely based on the Debian
43;; packages. They are licensed under GPL-2 and have copyright:
44;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
45;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
46;; Big thanks to them for laying the groundwork.
47
48;; The version tag is consistent between all repositories.
49(define (android-platform-version) "7.1.2_r6")
50
51(define (android-platform-system-core version)
52 (origin
53 (method git-fetch)
54 (uri (git-reference
55 (url "https://android.googlesource.com/platform/system/core")
56 (commit (string-append "android-" version))))
57 (file-name (string-append "android-platform-system-core-"
58 version "-checkout"))
59 (sha256
60 (base32
61 "0xc2n7jxrf1iw9cc278pijdfjix2fkiig5ws27f6rwp40zg5mrgg"))))
62
63(define liblog
64 (package
65 (name "liblog")
66 (version (android-platform-version))
67 (source (android-platform-system-core version))
68 (build-system gnu-build-system)
69 (arguments
70 `(#:tests? #f ; TODO.
71 #:make-flags '("CC=gcc")
72 #:phases
73 (modify-phases %standard-phases
74 (add-after 'unpack 'enter-source
75 (lambda _ (chdir "liblog") #t))
76 (add-after 'enter-source 'create-Makefile
77 (lambda _
78 ;; No useful makefile is shipped, so we create one.
79 (with-output-to-file "Makefile"
80 (lambda _
81 (display
82 (string-append
83 "NAME = liblog\n"
84 "SOURCES = log_event_list.c log_event_write.c"
85 " logger_write.c config_write.c logger_name.c"
86 " logger_lock.c fake_log_device.c fake_writer.c"
87 " event_tag_map.c\n"
88
89 "CFLAGS += -fvisibility=hidden -fPIC\n"
90 "CPPFLAGS += -I../include -DFAKE_LOG_DEVICE=1"
91 ;; Keep these two in sync with "liblog/Android.bp".
92 " -DLIBLOG_LOG_TAG=1005"
93 " -DSNET_EVENT_LOG_TAG=1397638484\n"
94 "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0 -lpthread\n"
95
96 "build: $(SOURCES)\n"
97 " $(CC) $^ -o $(NAME).so.0 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"))
98 #t))))
99 (delete 'configure)
100 (replace 'install
101 (lambda* (#:key outputs #:allow-other-keys)
102 (let* ((out (assoc-ref outputs "out"))
103 (lib (string-append out "/lib")))
104 (install-file "liblog.so.0" lib)
105 (with-directory-excursion lib
106 (symlink "liblog.so.0" "liblog.so"))
107 #t))))))
108 (home-page "https://developer.android.com/")
109 (synopsis "Logging library from the Android platform.")
110 (description "@code{liblog} represents an interface to the volatile Android
111Logging system for NDK (Native) applications and libraries and contain
112interfaces for either writing or reading logs. The log buffers are divided up
113in Main, System, Radio and Events sub-logs.")
114 (license license:asl2.0)))
115
116(define libbase
117 (package
118 (name "libbase")
119 (version (android-platform-version))
120 (source (origin
121 (inherit (android-platform-system-core version))
122 (patches
123 (search-patches "libbase-use-own-logging.patch"
124 "libbase-fix-includes.patch"))))
125 (build-system gnu-build-system)
126 (arguments
127 `(#:tests? #f ; TODO.
128 #:phases
129 (modify-phases %standard-phases
130 (add-after 'unpack 'enter-source
131 (lambda _ (chdir "base") #t))
132 (add-after 'enter-source 'create-Makefile
133 (lambda _
134 ;; No useful makefile is shipped, so we create one.
135 (with-output-to-file "Makefile"
136 (lambda _
137 (display
138 (string-append
139 "NAME = libbase\n"
140 "SOURCES = file.cpp logging.cpp parsenetaddress.cpp"
141 " stringprintf.cpp strings.cpp errors_unix.cpp\n"
142
143 "CXXFLAGS += -std=gnu++11 -fPIC\n"
144 "CPPFLAGS += -Iinclude -I../include\n"
145 "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0"
146 " -L.. -llog\n"
147
148 "build: $(SOURCES)\n"
149 " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)"
150 " $(LDFLAGS)\n"))
151 #t))))
152 (delete 'configure)
153 (replace 'install
154 (lambda* (#:key outputs #:allow-other-keys)
155 (let* ((out (assoc-ref outputs "out"))
156 (lib (string-append out "/lib")))
157 (install-file "libbase.so.0" lib)
158 (with-directory-excursion lib
159 (symlink "libbase.so.0" "libbase.so"))
160 (copy-recursively "include" out)
161 #t))))))
162 (inputs `(("liblog" ,liblog)))
163 (home-page "https://developer.android.com/")
164 (synopsis "Android platform base library")
165 (description "@code{libbase} is a library in common use by the
166various Android core host applications.")
167 (license license:asl2.0)))
168
169(define libcutils
170 (package
171 (name "libcutils")
172 (version (android-platform-version))
173 (source (android-platform-system-core version))
174 (build-system gnu-build-system)
175 (arguments
176 `(#:tests? #f ; TODO.
177 #:phases
178 (modify-phases %standard-phases
179 (add-after 'unpack 'enter-source
180 (lambda _ (chdir "libcutils") #t))
181 (add-after 'enter-source 'create-Makefile
182 (lambda _
183 ;; No useful makefile is shipped, so we create one.
184 (with-output-to-file "Makefile"
185 (lambda _
186 (display
187 (string-append
188 "NAME = libcutils\n"
189 "SOURCES = load_file.o socket_local_client_unix.o"
190 " socket_loopback_client_unix.o socket_network_client_unix.o"
191 " socket_loopback_server_unix.o socket_local_server_unix.o"
192 " sockets_unix.o socket_inaddr_any_server_unix.o"
193 " sockets.o\n"
194 "CC = gcc\n"
195
196 "CFLAGS += -fPIC\n"
197 "CXXFLAGS += -std=gnu++11 -fPIC\n"
198 "CPPFLAGS += -Iinclude -I../include\n"
199 "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
200
201 "build: $(SOURCES)\n"
202 " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)"
203 " $(LDFLAGS)\n"))
204 #t))))
205 (delete 'configure)
206 (replace 'install
207 (lambda* (#:key outputs #:allow-other-keys)
208 (let* ((out (assoc-ref outputs "out"))
209 (lib (string-append out "/lib")))
210 (install-file "libcutils.so.0" lib)
211 (with-directory-excursion lib
212 (symlink "libcutils.so.0" "libcutils.so"))
213 #t))))))
214 (home-page "https://developer.android.com/")
215 (synopsis "Android platform c utils library")
216 (description "@code{libcutils} is a library in common use by the
217various Android core host applications.")
218 (license license:asl2.0)))
219
220(define-public adb
221 (package
222 (name "adb")
223 (version (android-platform-version))
224 (source (origin
225 (inherit (android-platform-system-core version))
226 (patches
227 (search-patches "libbase-use-own-logging.patch"
228 "libbase-fix-includes.patch"))))
229 (build-system gnu-build-system)
230 (arguments
231 `(#:phases
232 (modify-phases %standard-phases
233 (add-after 'unpack 'enter-source
234 (lambda _ (chdir "adb") #t))
235 (add-before 'build 'fix-clang
236 (lambda _
237 ;; adb_client.h contains _Nonnull and _Nullable attributes, that
238 ;; are not understood by gcc.
239 (substitute* "adb_client.h"
240 (("_Nonnull") "")
241 (("_Nullable") ""))
242 #t))
243 (add-before 'build 'fix-main
244 (lambda _
245 ;; main.cpp used to be adb_main.cpp in the current directory
246 ;; rather than in its own subdirectory, but it was not fixed.
247 ;; This leads to some header files not being found anymore.
248 (copy-file "client/main.cpp" "adb_main.cpp")
249 #t))
250 (add-after 'enter-source 'create-Makefile
251 (lambda* (#:key outputs #:allow-other-keys)
252 ;; No useful makefile is shipped, so we create one.
253 (with-output-to-file "Makefile"
254 (lambda _
255 (display
256 (string-append
257 ;; Common for all components.
258 "CXXFLAGS += -std=gnu++14 -fpermissive\n"
259 "CPPFLAGS += -I../include -I../base/include -I. -DADB_HOST=1 "
260 "-DADB_REVISION='\"" ,version "\"' -fPIC\n"
261 "LDFLAGS += -lcrypto -lpthread -lbase -lcutils -L. -ladb\n"
262
263 ;; Libadb specifics.
264 "LIBADB_SOURCES = adb.cpp adb_auth.cpp adb_io.cpp "
265 "adb_listeners.cpp adb_trace.cpp adb_utils.cpp fdevent.cpp "
266 "sockets.cpp transport.cpp transport_local.cpp transport_usb.cpp "
267 "get_my_path_linux.cpp sysdeps_unix.cpp usb_linux.cpp "
268 "adb_auth_host.cpp diagnose_usb.cpp services.cpp "
269 "shell_service_protocol.cpp bugreport.cpp line_printer.cpp\n"
270
271 "LIBADB_LDFLAGS += -shared -Wl,-soname,libadb.so.0 "
272 "-lcrypto -lpthread -lbase\n"
273
274 ;; Adb specifics.
275 "ADB_SOURCES = adb_main.cpp console.cpp commandline.cpp "
276 "adb_client.cpp file_sync_client.cpp\n"
277 "ADB_LDFLAGS += -Wl,-rpath=" (assoc-ref outputs "out") "/lib\n"
278
279 "build: libadb $(ADB_SOURCES)\n"
280 " $(CXX) $(ADB_SOURCES) -o adb $(CXXFLAGS) $(CPPFLAGS) "
281 "$(ADB_LDFLAGS) $(LDFLAGS)\n"
282
283 "libadb: $(LIBADB_SOURCES)\n"
284 " $(CXX) $^ -o libadb.so.0 $(CXXFLAGS) $(CPPFLAGS) "
285 "$(LIBADB_LDFLAGS)\n"
286 " ln -sv libadb.so.0 libadb.so\n"))
287 #t))))
288 (delete 'configure)
289 (replace 'install
290 (lambda* (#:key outputs #:allow-other-keys)
291 (let* ((out (assoc-ref outputs "out"))
292 (lib (string-append out "/lib"))
293 (bin (string-append out "/bin")))
294 (install-file "libadb.so.0" lib)
295 (install-file "adb" bin)
296 (with-directory-excursion lib
297 (symlink "libadb.so.0" "libadb.so"))
298 #t))))
299 ;; Test suite must be run with attached devices
300 #:tests? #f))
301 (inputs
302 `(("libbase" ,libbase)
303 ("libcutils" ,libcutils)
304 ("openssl" ,openssl)))
305 (home-page "https://developer.android.com/studio/command-line/adb.html")
306 (synopsis "Android Debug Bridge")
307 (description
308 "@command{adb} is a versatile command line tool that lets you communicate
309with an emulator instance or connected Android device. It facilitates a variety
310of device actions, such as installing and debugging apps, and it provides access
311to a Unix shell that can run commands on the connected device or emulator.")
312 (license license:asl2.0)))
c1151ecf 313
7175abaa
DM
314(define-public mkbootimg
315 (package
316 (name "mkbootimg")
317 (version (android-platform-version))
318 (source (origin
319 (inherit (android-platform-system-core version))))
320 (build-system python-build-system)
321 (arguments
322 `(#:tests? #f
323 #:phases
324 (modify-phases %standard-phases
325 (add-after 'unpack 'enter-source
326 (lambda _ (chdir "mkbootimg") #t))
327 (delete 'configure)
328 (delete 'build)
329 (replace 'install
330 (lambda* (#:key outputs #:allow-other-keys)
331 (let* ((out (assoc-ref outputs "out"))
332 (bin (string-append out "/bin")))
333 (install-file "mkbootimg" bin)
334 #t))))))
335 (home-page "https://developer.android.com/studio/command-line/adb.html")
336 (synopsis "Tool to create Android boot images")
337 (description "This package provides a tool to create Android Boot
338Images.")
339 (license license:asl2.0)))
340
0ad03eae
MC
341(define-public android-udev-rules
342 (package
343 (name "android-udev-rules")
d36d4c55 344 (version "20171113")
0ad03eae
MC
345 (source
346 (origin
347 (method git-fetch)
348 (uri (git-reference
349 (url "https://github.com/M0Rf30/android-udev-rules")
350 (commit version)))
351 (file-name (string-append name "-" version "-checkout"))
352 (sha256
d36d4c55 353 (base32 "11gcnk6wjc2sw05hwi4xphvx9ksmkpvsdziaczymqxkaads3f1dy"))))
0ad03eae
MC
354 (build-system trivial-build-system)
355 (native-inputs `(("source" ,source)))
356 (arguments
357 '(#:modules ((guix build utils))
358 #:builder
359 (begin
360 (use-modules (guix build utils))
361 (let ((source (assoc-ref %build-inputs "source")))
362 (install-file (string-append source "/51-android.rules")
363 (string-append %output "/lib/udev/rules.d"))))))
364 (home-page "https://github.com/M0Rf30/android-udev-rules")
365 (synopsis "udev rules for Android devices")
366 (description "Provides a set of udev rules to allow using Android devices
367with tools such as @command{adb} and @command{fastboot} without root
368privileges. This package is intended to be added as a rule to the
369@code{udev-service-type} in your @code{operating-system} configuration.
370Additionally, an @code{adbusers} group must be defined and your user added to
371it.
372
373@emph{Simply installing this package will not have any effect.} It is meant
374to be passed to the @code{udev} service.")
375 (license license:gpl3+)))
376
c1151ecf
HG
377(define-public git-repo
378 (package
379 (name "git-repo")
380 (version "1.12.37")
381 (source
382 (origin
383 (method git-fetch)
384 (uri (git-reference
385 (url "https://gerrit.googlesource.com/git-repo")
386 (commit (string-append "v" version))))
387 (file-name (string-append "git-repo-" version "-checkout"))
388 (sha256
389 (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd"))))
390 (build-system python-build-system)
391 (arguments
392 `(#:python ,python-2 ; code says: "Python 3 support is … experimental."
393 #:phases
394 (modify-phases %standard-phases
395 (add-before 'build 'set-executable-paths
396 (lambda* (#:key inputs outputs #:allow-other-keys)
397 (let* ((out (assoc-ref outputs "out"))
398 (git (assoc-ref inputs "git"))
399 (gpg (assoc-ref inputs "gnupg"))
400 (ssh (assoc-ref inputs "ssh")))
401 (substitute* '("repo" "git_command.py")
402 (("^GIT = 'git' ")
403 (string-append "GIT = '" git "/bin/git' ")))
404 (substitute* "repo"
405 ((" cmd = \\['gpg',")
406 (string-append " cmd = ['" gpg "/bin/gpg',")))
407 (substitute* "git_config.py"
408 ((" command_base = \\['ssh',")
409 (string-append " command_base = ['" ssh "/bin/ssh',")))
410 #t)))
411 (add-before 'build 'do-not-clone-this-source
412 (lambda* (#:key outputs #:allow-other-keys)
413 (let* ((out (assoc-ref outputs "out"))
414 (repo-dir (string-append out "/share/" ,name)))
415 (substitute* "repo"
416 (("^def _FindRepo\\(\\):.*")
417 (format #f "
418def _FindRepo():
419 '''Look for a repo installation, starting at the current directory.'''
420 # Use the installed version of git-repo.
421 repo_main = '~a/main.py'
422 curdir = os.getcwd()
423 olddir = None
424 while curdir != '/' and curdir != olddir:
425 dot_repo = os.path.join(curdir, repodir)
426 if os.path.isdir(dot_repo):
427 return (repo_main, dot_repo)
428 else:
429 olddir = curdir
430 curdir = os.path.dirname(curdir)
431 return None, ''
432
433 # The remaining of this function is dead code. It was used to
434 # find a git-checked-out version in the local project.\n" repo-dir))
435 ;; Neither clone, check out, nor verify the git repository
436 (("(^\\s+)_Clone\\(.*\\)") "")
437 (("(^\\s+)_Checkout\\(.*\\)") "")
438 ((" rev = _Verify\\(.*\\)") " rev = None"))
439 #t)))
440 (delete 'build) ; nothing to build
441 (replace 'check
442 (lambda _
443 (zero? (system* "python" "-m" "nose"))))
444 (replace 'install
445 (lambda* (#:key outputs #:allow-other-keys)
446 (let* ((out (assoc-ref outputs "out"))
447 (bin-dir (string-append out "/bin"))
448 (repo-dir (string-append out "/share/" ,name)))
449 (mkdir-p bin-dir)
450 (mkdir-p repo-dir)
451 (copy-recursively "." repo-dir)
452 (delete-file-recursively (string-append repo-dir "/tests"))
453 (symlink (string-append repo-dir "/repo")
454 (string-append bin-dir "/repo"))
455 #t))))))
456 (inputs
457 ;; TODO: Add git-remote-persistent-https once it is available in guix
458 `(("git" ,git)
459 ("gnupg" ,gnupg)
460 ("ssh", openssh)))
461 (native-inputs
462 `(("nose" ,python2-nose)))
463 (home-page "https://code.google.com/p/git-repo/")
464 (synopsis "Helps to manage many Git repositories.")
465 (description "Repo is a tool built on top of Git. Repo helps manage many
466Git repositories, does the uploads to revision control systems, and automates
467parts of the development workflow. Repo is not meant to replace Git, only to
468make it easier to work with Git. The repo command is an executable Python
469script that you can put anywhere in your path.")
470 (license license:asl2.0)))
6ef5162d
DM
471
472(define-public abootimg
473 (package
474 (name "abootimg")
475 (version "0.6")
476 (source
477 (origin
478 (method url-fetch)
479 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
480 "abootimg_" version ".orig.tar.gz"))
481 (sha256
482 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
483 (build-system gnu-build-system)
484 (arguments
485 `(#:tests? #f
486 #:phases
487 (modify-phases %standard-phases
488 (replace 'configure
489 (lambda _
490 (setenv "CC" "gcc")
491 #t))
492 (replace 'install
493 (lambda* (#:key outputs #:allow-other-keys)
494 (let* ((out (assoc-ref outputs "out"))
495 (bin (string-append out "/bin")))
496 (install-file "abootimg" bin)
497 #t))))))
498 (inputs
499 `(("libblkid" ,util-linux)))
500 (home-page "https://ac100.grandou.net/abootimg")
501 (synopsis "Tool for manipulating Android Boot Images")
502 (description "This package provides a tool for manipulating old Android
503Boot Images. @code{abootimg} can work directly on block devices, or, the
504safest way, on a file image.")
505 (license license:gpl2+)))