adb package merged upstream.

Julien LepillerFri Apr 21 10:54:32+0200 2017

7a41c14

adb package merged upstream.

libbase-fix-includes.patch unknown status 2

1-
This patch fixes the build of adb on linux. It was taken from archlinux.
2-
3-
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
4-
index 75dcc86..867f3ec 100644
5-
--- a/adb/sysdeps.h
6-
+++ b/adb/sysdeps.h
7-
@@ -25,6 +25,7 @@
8-
 #endif
9-
 
10-
 #include <errno.h>
11-
+#include <sys/syscall.h>
12-
 
13-
 #include <string>
14-
 #include <vector>
15-
@@ -831,7 +832,16 @@ static __inline__ int adb_is_absolute_host_path(const char* path) {
16-
 
17-
 static __inline__ unsigned long adb_thread_id()
18-
 {
19-
-    return (unsigned long)gettid();
20-
+  // TODO: this function should be merged with GetThreadId
21-
+#if defined(__BIONIC__)
22-
+  return gettid();
23-
+#elif defined(__APPLE__)
24-
+  return syscall(SYS_thread_selfid);
25-
+#elif defined(__linux__)
26-
+  return syscall(__NR_gettid);
27-
+#elif defined(_WIN32)
28-
+  return GetCurrentThreadId();
29-
+#endif
30-
 }
31-
 
32-
 #endif /* !_WIN32 */
33-
diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp
34-
index 296995e..48269b6 100644
35-
--- a/base/errors_unix.cpp
36-
+++ b/base/errors_unix.cpp
37-
@@ -17,6 +17,7 @@
38-
 #include "android-base/errors.h"
39-
 
40-
 #include <errno.h>
41-
+#include <string.h>
42-
 
43-
 namespace android {
44-
 namespace base {
45-
diff --git a/base/file.cpp b/base/file.cpp
46-
index da1adba..91a3901 100644
47-
--- a/base/file.cpp
48-
+++ b/base/file.cpp
49-
@@ -20,6 +20,7 @@
50-
 #include <fcntl.h>
51-
 #include <sys/stat.h>
52-
 #include <sys/types.h>
53-
+#include <string.h>
54-
 
55-
 #include <string>
56-
 
57-
diff --git a/base/logging.cpp b/base/logging.cpp
58-
index 1741871..e97c7f1 100644
59-
--- a/base/logging.cpp
60-
+++ b/base/logging.cpp
61-
@@ -21,6 +21,7 @@
62-
 #include "android-base/logging.h"
63-
 
64-
 #include <libgen.h>
65-
+#include <string.h>
66-
 
67-
 // For getprogname(3) or program_invocation_short_name.
68-
 #if defined(__ANDROID__) || defined(__APPLE__)

libbase-use-own-logging.patch unknown status 2

1-
From e5dd71a290f664d3f3bf0dd8a4bad411dc7ad416 Mon Sep 17 00:00:00 2001
2-
From: Elliott Hughes <enh@google.com>
3-
Date: Thu, 28 Jul 2016 15:15:28 -0700
4-
Subject: [PATCH] libbase should use its own logging!
5-
6-
Not doing so led to us using a bogus log tag.
7-
8-
Bug: http://b/30281203
9-
Change-Id: I3ac91758a1a043146c65f2ae0f36fcfbe372c30f
10-
---
11-
 base/file.cpp    | 11 +++++------
12-
 base/logging.cpp |  3 +--
13-
 2 files changed, 6 insertions(+), 8 deletions(-)
14-
15-
diff --git a/base/file.cpp b/base/file.cpp
16-
index da1adba19..4e7ac82d1 100644
17-
--- a/base/file.cpp
18-
+++ b/base/file.cpp
19-
@@ -24,9 +24,8 @@
20-
 #include <string>
21-
 
22-
 #include "android-base/macros.h"  // For TEMP_FAILURE_RETRY on Darwin.
23-
+#include "android-base/logging.h"
24-
 #include "android-base/utf8.h"
25-
-#define LOG_TAG "base.file"
26-
-#include "cutils/log.h"
27-
 #include "utils/Compat.h"
28-
 
29-
 namespace android {
30-
@@ -86,22 +85,22 @@ bool WriteStringToFile(const std::string& content, const std::string& path,
31-
   int flags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
32-
   int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, mode));
33-
   if (fd == -1) {
34-
-    ALOGE("android::WriteStringToFile open failed: %s", strerror(errno));
35-
+    PLOG(ERROR) << "android::WriteStringToFile open failed";
36-
     return false;
37-
   }
38-
 
39-
   // We do an explicit fchmod here because we assume that the caller really
40-
   // meant what they said and doesn't want the umask-influenced mode.
41-
   if (fchmod(fd, mode) == -1) {
42-
-    ALOGE("android::WriteStringToFile fchmod failed: %s", strerror(errno));
43-
+    PLOG(ERROR) << "android::WriteStringToFile fchmod failed";
44-
     return CleanUpAfterFailedWrite(path);
45-
   }
46-
   if (fchown(fd, owner, group) == -1) {
47-
-    ALOGE("android::WriteStringToFile fchown failed: %s", strerror(errno));
48-
+    PLOG(ERROR) << "android::WriteStringToFile fchown failed";
49-
     return CleanUpAfterFailedWrite(path);
50-
   }
51-
   if (!WriteStringToFd(content, fd)) {
52-
-    ALOGE("android::WriteStringToFile write failed: %s", strerror(errno));
53-
+    PLOG(ERROR) << "android::WriteStringToFile write failed";
54-
     return CleanUpAfterFailedWrite(path);
55-
   }
56-
   close(fd);
57-
diff --git a/base/logging.cpp b/base/logging.cpp
58-
index 769c266c9..959bb8b05 100644
59-
--- a/base/logging.cpp
60-
+++ b/base/logging.cpp
61-
@@ -43,12 +43,11 @@
62-
 
63-
 #include "android-base/macros.h"
64-
 #include "android-base/strings.h"
65-
-#include "cutils/threads.h"
66-
 
67-
 // Headers for LogMessage::LogLine.
68-
 #ifdef __ANDROID__
69-
 #include <android/set_abort_message.h>
70-
-#include "cutils/log.h"
71-
+#include "log/log.h"
72-
 #else
73-
 #include <sys/types.h>
74-
 #include <unistd.h>
75-
-- 
76-
2.11.0
77-

more/packages/android.scm unknown status 2

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-
;;;
7-
;;; This file is part of GNU Guix.
8-
;;;
9-
;;; GNU Guix is free software; you can redistribute it and/or modify it
10-
;;; under the terms of the GNU General Public License as published by
11-
;;; the Free Software Foundation; either version 3 of the License, or (at
12-
;;; your option) any later version.
13-
;;;
14-
;;; GNU Guix is distributed in the hope that it will be useful, but
15-
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16-
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17-
;;; GNU General Public License for more details.
18-
;;;
19-
;;; You should have received a copy of the GNU General Public License
20-
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
21-
22-
(define-module (more packages android)
23-
  #:use-module (guix packages)
24-
  #:use-module (guix git-download)
25-
  #:use-module (guix build-system gnu)
26-
  #:use-module ((guix licenses) #:prefix license:)
27-
  #:use-module (gnu packages)
28-
  #:use-module (gnu packages tls))
29-
30-
;; The Makefiles that we add are largely based on the Debian
31-
;; packages.  They are licensed under GPL-2 and have copyright:
32-
;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
33-
;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
34-
;; Big thanks to them for laying the groundwork.
35-
36-
;; The version tag is consistent between all repositories.
37-
(define (android-platform-version) "7.1.2_r6")
38-
39-
(define (android-platform-system-core version)
40-
  (origin
41-
    (method git-fetch)
42-
    (uri (git-reference
43-
          (url "https://android.googlesource.com/platform/system/core")
44-
          (commit (string-append "android-" version))))
45-
    (file-name (string-append "android-platform-system-core-"
46-
                              version "-checkout"))
47-
    (sha256
48-
     (base32
49-
      "0xc2n7jxrf1iw9cc278pijdfjix2fkiig5ws27f6rwp40zg5mrgg"))))
50-
51-
(define liblog
52-
  (package
53-
    (name "liblog")
54-
    (version (android-platform-version))
55-
    (source (android-platform-system-core version))
56-
    (build-system gnu-build-system)
57-
    (arguments
58-
     `(#:tests? #f ; TODO.
59-
       #:make-flags '("CC=gcc")
60-
       #:phases
61-
       (modify-phases %standard-phases
62-
         (add-after 'unpack 'enter-source
63-
           (lambda _ (chdir "liblog") #t))
64-
         (add-after 'enter-source 'create-Makefile
65-
           (lambda _
66-
             ;; No useful makefile is shipped, so we create one.
67-
             (with-output-to-file "Makefile"
68-
               (lambda _
69-
                 (display
70-
                  (string-append
71-
                   "NAME = liblog\n"
72-
                   "SOURCES = log_event_list.c log_event_write.c"
73-
                   " logger_write.c config_write.c logger_name.c"
74-
                   " logger_lock.c fake_log_device.c fake_writer.c"
75-
                   " event_tag_map.c\n"
76-
77-
                   "CFLAGS += -fvisibility=hidden -fPIC\n"
78-
                   "CPPFLAGS += -I../include -DFAKE_LOG_DEVICE=1"
79-
                   ;; Keep these two in sync with "liblog/Android.bp".
80-
                   " -DLIBLOG_LOG_TAG=1005"
81-
                   " -DSNET_EVENT_LOG_TAG=1397638484\n"
82-
                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0 -lpthread\n"
83-
84-
                   "build: $(SOURCES)\n"
85-
                   "	$(CC) $^ -o $(NAME).so.0 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"))))))
86-
         (delete 'configure)
87-
         (replace 'install
88-
           (lambda* (#:key outputs #:allow-other-keys)
89-
             (let* ((out (assoc-ref outputs "out"))
90-
                    (lib (string-append out "/lib")))
91-
               (install-file "liblog.so.0" lib)
92-
               (with-directory-excursion lib
93-
                 (symlink "liblog.so.0" "liblog.so"))
94-
               #t))))))
95-
    (home-page "https://developer.android.com/")
96-
    (synopsis "Logging library from the Android platform.")
97-
    (description "@code{liblog} represents an interface to the volatile Android
98-
Logging system for NDK (Native) applications and libraries and contain
99-
interfaces for either writing or reading logs.  The log buffers are divided up
100-
in Main, System, Radio and Events sub-logs.")
101-
    (license license:asl2.0)))
102-
103-
(define libbase
104-
  (package
105-
    (name "libbase")
106-
    (version (android-platform-version))
107-
    (source (origin
108-
              (inherit (android-platform-system-core version))
109-
              (patches
110-
               (search-patches "libbase-use-own-logging.patch"
111-
                               "libbase-fix-includes.patch"))))
112-
    (build-system gnu-build-system)
113-
    (arguments
114-
     `(#:tests? #f ; TODO.
115-
       #:phases
116-
       (modify-phases %standard-phases
117-
         (add-after 'unpack 'enter-source
118-
           (lambda _ (chdir "base") #t))
119-
         (add-after 'enter-source 'create-Makefile
120-
           (lambda _
121-
             ;; No useful makefile is shipped, so we create one.
122-
             (with-output-to-file "Makefile"
123-
               (lambda _
124-
                 (display
125-
                  (string-append
126-
                   "NAME = libbase\n"
127-
                   "SOURCES = file.cpp logging.cpp parsenetaddress.cpp"
128-
                   " stringprintf.cpp strings.cpp errors_unix.cpp\n"
129-
130-
                   "CXXFLAGS += -std=gnu++11 -fPIC\n"
131-
                   "CPPFLAGS += -Iinclude -I../include\n"
132-
                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0"
133-
                   " -L.. -llog\n"
134-
135-
                   "build: $(SOURCES)\n"
136-
                   "	$(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"
137-
                   ))))))
138-
         (delete 'configure)
139-
         (replace 'install
140-
           (lambda* (#:key outputs #:allow-other-keys)
141-
             (let* ((out (assoc-ref outputs "out"))
142-
                    (lib (string-append out "/lib")))
143-
               (install-file "libbase.so.0" lib)
144-
               (with-directory-excursion lib
145-
                 (symlink "libbase.so.0" "libbase.so"))
146-
               (copy-recursively "include" out)
147-
               #t))))))
148-
    (inputs `(("liblog" ,liblog)))
149-
    (home-page "https://developer.android.com/")
150-
    (synopsis "Android platform base library")
151-
    (description "@code{libbase} is a library in common use by the
152-
various Android core host applications.")
153-
    (license license:asl2.0)))
154-
155-
(define libcutils
156-
  (package
157-
    (name "libcutils")
158-
    (version (android-platform-version))
159-
    (source (android-platform-system-core version))
160-
    (build-system gnu-build-system)
161-
    (arguments
162-
     `(#:tests? #f ; TODO.
163-
       #:phases
164-
       (modify-phases %standard-phases
165-
         (add-after 'unpack 'enter-source
166-
           (lambda _ (chdir "libcutils") #t))
167-
         (add-after 'enter-source 'create-Makefile
168-
           (lambda _
169-
             ;; No useful makefile is shipped, so we create one.
170-
             (with-output-to-file "Makefile"
171-
               (lambda _
172-
                 (display
173-
                  (string-append
174-
                   "NAME = libcutils\n"
175-
                   "SOURCES = load_file.o socket_local_client_unix.o"
176-
                   " socket_loopback_client_unix.o socket_network_client_unix.o"
177-
                   " socket_loopback_server_unix.o socket_local_server_unix.o"
178-
                   " sockets_unix.o socket_inaddr_any_server_unix.o"
179-
                   " sockets.o\n"
180-
                   "CC = gcc\n"
181-
182-
                   "CFLAGS += -fPIC\n"
183-
                   "CXXFLAGS += -std=gnu++11 -fPIC\n"
184-
                   "CPPFLAGS += -Iinclude -I../include\n"
185-
                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
186-
187-
                   "build: $(SOURCES)\n"
188-
                   "	$(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"
189-
                   ))))))
190-
         (delete 'configure)
191-
         (replace 'install
192-
           (lambda* (#:key outputs #:allow-other-keys)
193-
             (let* ((out (assoc-ref outputs "out"))
194-
                    (lib (string-append out "/lib")))
195-
               (install-file "libcutils.so.0" lib)
196-
               (with-directory-excursion lib
197-
                 (symlink "libcutils.so.0" "libcutils.so"))
198-
               #t))))))
199-
    (home-page "https://developer.android.com/")
200-
    (synopsis "Android platform c utils library")
201-
    (description "@code{libcutils} is a library in common use by the
202-
various Android core host applications.")
203-
    (license license:asl2.0)))
204-
205-
(define-public adb
206-
  (package
207-
    (name "adb")
208-
    (version (android-platform-version))
209-
    (source (origin
210-
              (inherit (android-platform-system-core version))
211-
              (patches
212-
               (search-patches "libbase-use-own-logging.patch"
213-
                               "libbase-fix-includes.patch"))))
214-
    (build-system gnu-build-system)
215-
    (arguments
216-
     `(#:phases
217-
       (modify-phases %standard-phases
218-
         (add-after 'unpack 'enter-source
219-
           (lambda _ (chdir "adb") #t))
220-
         (add-before 'build 'fix-clang
221-
           (lambda _
222-
             (substitute* "adb_client.h"
223-
                   (("_Nonnull") "")
224-
                   (("_Nullable") ""))))
225-
         (add-before 'build 'fix-main
226-
           (lambda _
227-
             (copy-file "client/main.cpp" "adb_main.cpp")))
228-
         (add-after 'enter-source 'create-Makefile
229-
           (lambda* (#:key outputs #:allow-other-keys)
230-
             ;; No useful makefile is shipped, so we create one.
231-
             (with-output-to-file "Makefile"
232-
               (lambda _
233-
                 (display
234-
                  (string-append
235-
                   ;; Common for all components.
236-
                   "CXXFLAGS += -std=gnu++14 -fpermissive\n"
237-
                   "CPPFLAGS += -I../include -I../base/include -I. -DADB_HOST=1 "
238-
                   "-DADB_REVISION='\"" ,version "\"' -fPIC\n"
239-
                   "LDFLAGS += -lcrypto -lpthread -lbase -lcutils -L. -ladb\n"
240-
241-
                   ;; Libadb specifics.
242-
                   "LIBADB_SOURCES = adb.cpp adb_auth.cpp adb_io.cpp "
243-
                   "adb_listeners.cpp adb_trace.cpp adb_utils.cpp fdevent.cpp "
244-
                   "sockets.cpp transport.cpp transport_local.cpp transport_usb.cpp "
245-
                   "get_my_path_linux.cpp sysdeps_unix.cpp usb_linux.cpp "
246-
                   "adb_auth_host.cpp diagnose_usb.cpp services.cpp "
247-
                   "shell_service_protocol.cpp bugreport.cpp line_printer.cpp\n"
248-
249-
                   "LIBADB_LDFLAGS += -shared -Wl,-soname,libadb.so.0 "
250-
                   "-lcrypto -lpthread -lbase\n"
251-
252-
                   ;; Adb specifics.
253-
                   "ADB_SOURCES = adb_main.cpp console.cpp commandline.cpp "
254-
                   "adb_client.cpp file_sync_client.cpp\n"
255-
                   "ADB_LDFLAGS += -Wl,-rpath=" (assoc-ref outputs "out") "/lib\n"
256-
257-
                   "build: libadb $(ADB_SOURCES)\n"
258-
                   "	$(CXX) $(ADB_SOURCES) -o adb $(CXXFLAGS) $(CPPFLAGS) "
259-
                   "$(ADB_LDFLAGS) $(LDFLAGS)\n"
260-
261-
                   "libadb: $(LIBADB_SOURCES)\n"
262-
                   "	$(CXX) $^ -o libadb.so.0 $(CXXFLAGS) $(CPPFLAGS) "
263-
                   "$(LIBADB_LDFLAGS)\n"
264-
                   "	ln -sv libadb.so.0 libadb.so\n"
265-
                   ))))))
266-
         (delete 'configure)
267-
         (replace 'install
268-
           (lambda* (#:key outputs #:allow-other-keys)
269-
             (let* ((out (assoc-ref outputs "out"))
270-
                    (lib (string-append out "/lib"))
271-
                    (bin (string-append out "/bin")))
272-
               (install-file "libadb.so.0" lib)
273-
               (install-file "adb" bin)
274-
               (with-directory-excursion lib
275-
                 (symlink "libadb.so.0" "libadb.so"))
276-
               #t))))
277-
       ;; Test suite must be run with attached devices
278-
       #:tests? #f))
279-
    (inputs
280-
     `(("libbase" ,libbase)
281-
       ("libcutils" ,libcutils)
282-
       ("openssl" ,openssl)))
283-
    (home-page "https://developer.android.com/studio/command-line/adb.html")
284-
    (synopsis "Android Debug Bridge")
285-
    (description
286-
     "@command{adb} is a versatile command line tool that lets you communicate
287-
with an emulator instance or connected Android device.  It facilitates a variety
288-
of device actions, such as installing and debugging apps, and it provides access
289-
to a Unix shell that can run commands on the connected device or emulator.")
290-
    (license license:asl2.0)))