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>
6 ;;; Copyright © 2017 Hartmut Goebel <h.goebel@crazy-compilers.com>
7 ;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
25 (define-module (gnu packages android)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system android-ndk)
31 #:use-module (guix build-system python)
32 #:use-module (guix build-system trivial)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages check)
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)
40 #:use-module (gnu packages tls)
41 #:use-module (gnu packages linux))
43 (define-public android-make-stub
47 (name "android-make-stub")
53 (url "https://github.com/daym/android-make-stub.git")
55 (file-name (string-append "android-make-stub-"
59 "1ni4szpcx2clf3lpzrybabwk7bgvsl6ynng7xxfc49y4jkdkk4sh"))))
60 (build-system gnu-build-system)
62 `(#:tests? #f ; None exist.
64 (modify-phases %standard-phases
68 (lambda* (#:key outputs #:allow-other-keys)
69 (let* ((out (assoc-ref outputs "out")))
70 (invoke "make" (string-append "prefix=" out) "install")
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))))
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.
85 ;; The version tag is consistent between all repositories.
86 (define (android-platform-version) "7.1.2_r6")
88 (define (android-platform-system-core version)
92 (url "https://android.googlesource.com/platform/system/core")
93 (commit (string-append "android-" version))))
94 (file-name (string-append "android-platform-system-core-"
98 "0xc2n7jxrf1iw9cc278pijdfjix2fkiig5ws27f6rwp40zg5mrgg"))))
103 (version (android-platform-version))
104 (source (android-platform-system-core version))
105 (build-system android-ndk-build-system)
107 `(#:tests? #f ; TODO.
108 #:make-flags '("CC=gcc")
110 (modify-phases %standard-phases
111 (add-after 'unpack 'enter-source
112 (lambda _ (chdir "liblog") #t)))))
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)))
124 (version (android-platform-version))
126 (inherit (android-platform-system-core version))
128 (search-patches "libbase-use-own-logging.patch"
129 "libbase-fix-includes.patch"))))
130 (build-system android-ndk-build-system)
132 `(#:tests? #f ; TODO.
133 #:make-flags '("CXXFLAGS=-std=gnu++11")
135 (modify-phases %standard-phases
136 (add-after 'unpack 'enter-source
137 (lambda _ (chdir "base") #t)))))
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)))
148 (version (android-platform-version))
149 (source (android-platform-system-core version))
150 (build-system gnu-build-system)
152 `(#:tests? #f ; TODO.
154 (modify-phases %standard-phases
155 (add-after 'unpack 'enter-source
156 (lambda _ (chdir "libcutils") #t))
157 (add-after 'enter-source 'create-Makefile
159 ;; No useful makefile is shipped, so we create one.
160 (with-output-to-file "Makefile"
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"
173 "CXXFLAGS += -std=gnu++11 -fPIC\n"
174 "CPPFLAGS += -Iinclude -I../include\n"
175 "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
177 "build: $(SOURCES)\n"
178 " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)"
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"))
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)))
199 (version (android-platform-version))
201 (inherit (android-platform-system-core version))
203 (search-patches "libbase-use-own-logging.patch"
204 "libbase-fix-includes.patch"
205 "adb-add-libraries.patch"))))
206 (build-system android-ndk-build-system)
208 `(#:tests? #f ; TODO.
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 ."))
215 (modify-phases %standard-phases
216 (add-after 'unpack 'enter-source
217 (lambda _ (chdir "adb") #t))
218 (add-after 'enter-source 'make-libs-available
219 (lambda* (#:key inputs outputs #:allow-other-keys)
220 (substitute* "Android.mk"
221 (("libcrypto_static") "libcrypto"))
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"))
228 `(("libbase" ,libbase)
229 ("libcutils" ,libcutils)
231 ("openssl" ,openssl)))
232 (home-page "https://developer.android.com/studio/command-line/adb.html")
233 (synopsis "Android Debug Bridge")
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)))
241 (define-public mkbootimg
244 (version (android-platform-version))
246 (inherit (android-platform-system-core version))))
247 (build-system python-build-system)
251 (modify-phases %standard-phases
252 (add-after 'unpack 'enter-source
253 (lambda _ (chdir "mkbootimg") #t))
257 (lambda* (#:key outputs #:allow-other-keys)
258 (let* ((out (assoc-ref outputs "out"))
259 (bin (string-append out "/bin"))
260 (include (string-append out "/include")))
261 (install-file "mkbootimg" bin)
262 (install-file "bootimg.h" include)
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
268 (license license:asl2.0)))
270 (define-public android-udev-rules
272 (name "android-udev-rules")
278 (url "https://github.com/M0Rf30/android-udev-rules")
280 (file-name (string-append name "-" version "-checkout"))
282 (base32 "13gj79nnd04szqlrrzzkdr6wi1fky08pi7x8xfbg0jj3d3v0giah"))))
283 (build-system trivial-build-system)
284 (native-inputs `(("source" ,source)))
286 '(#:modules ((guix build utils))
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
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+)))
306 (define-public git-repo
314 (url "https://gerrit.googlesource.com/git-repo")
315 (commit (string-append "v" version))))
316 (file-name (string-append "git-repo-" version "-checkout"))
318 (base32 "0qp7jqhblv7xblfgpcq4n18dyjdv8shz7r60c3vnjxx2fngkj2jd"))))
319 (build-system python-build-system)
321 `(#:python ,python-2 ; code says: "Python 3 support is … experimental."
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")
332 (string-append "GIT = '" git "/bin/git' ")))
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',")))
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)))
345 (("^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'
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)
359 curdir = os.path.dirname(curdir)
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"))
369 (delete 'build) ; nothing to build
372 (zero? (system* "python" "-m" "nose"))))
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)))
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"))
386 ;; TODO: Add git-remote-persistent-https once it is available in guix
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)))
401 (define-public abootimg
408 (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
409 "abootimg_" version ".orig.tar.gz"))
411 (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
412 (build-system gnu-build-system)
416 (modify-phases %standard-phases
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)
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+)))