From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Lepiller Subject: [PATCH] Add adb Date: Sun, 11 Dec 2016 17:26:43 +0100 Message-ID: <20161211172643.0da9750f@lepiller.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/_0s/LdQsAm84OnF9d_WSPO/" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cG6yJ-00044V-Iq for guix-devel@gnu.org; Sun, 11 Dec 2016 11:27:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cG6yF-0003kT-Hx for guix-devel@gnu.org; Sun, 11 Dec 2016 11:27:31 -0500 Received: from dau94-h03-89-91-205-84.dsl.sta.abo.bbox.fr ([89.91.205.84]:55231 helo=skaro.lepiller.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cG6yE-0003jo-VQ for guix-devel@gnu.org; Sun, 11 Dec 2016 11:27:27 -0500 Received: from localhost (localhost [127.0.0.1]) by skaro.lepiller.eu (Postfix) with ESMTP id 5BCCF7FCFC for ; Sun, 11 Dec 2016 17:27:23 +0100 (CET) Received: from skaro.lepiller.eu ([127.0.0.1]) by localhost (lepiller.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HJNwxo6b6z_3 for ; Sun, 11 Dec 2016 17:27:13 +0100 (CET) Received: from localhost (128-79-116-134.hfc.dyn.abo.bbox.fr [128.79.116.134]) by skaro.lepiller.eu (Postfix) with ESMTPSA id 4FED47F84F for ; Sun, 11 Dec 2016 17:27:13 +0100 (CET) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --MP_/_0s/LdQsAm84OnF9d_WSPO/ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I wanted to use adb, so here is a patch to have it in the distro. It works when ran as root, or if you add some udev rules to your os configuration. An issue I can see with this package is that it is only a part of the upstream repository, which in turn is only a part of a bigger build system. Normally, you would download multiple repos and build them all together to get an android image, and some android tools (including adb). I don't think we want to build a full android image, so I wrote a recipe for adb only. I took the recipe from archlinux, as well as the patch (android-tools package: https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/android-tools, see build.sh and fix-build.patch). They use clang, but our version isn't able to build c++ source files (it cannot find includes such as or ), so I fixed the source to remove clang dialect in adb/adb_client.h so we can build the files using gcc. Archlinux also builds fastboot and mkbootimg. Should I build them along with adb, or in a separate packages? --MP_/_0s/LdQsAm84OnF9d_WSPO/ Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-gnu-Add-adb.patch =46rom e1067facc404655c021011266c42d5e643a87abd Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sun, 11 Dec 2016 17:08:15 +0100 Subject: [PATCH] gnu: Add adb. * gnu/packages/android.scm: New file. * gnu/packages/patches/adb-fix-build.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add them --- gnu/local.mk | 2 + gnu/packages/android.scm | 132 +++++++++++++++++++++++++++= ++++ gnu/packages/patches/adb-fix-build.patch | 67 ++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 gnu/packages/android.scm create mode 100644 gnu/packages/patches/adb-fix-build.patch diff --git a/gnu/local.mk b/gnu/local.mk index 98a7f65ca..2dcf7547b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -40,6 +40,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/packages/adns.scm \ %D%/packages/algebra.scm \ %D%/packages/aidc.scm \ + %D%/packages/android.scm \ %D%/packages/animation.scm \ %D%/packages/anthy.scm \ %D%/packages/apl.scm \ @@ -463,6 +464,7 @@ dist_patch_DATA =3D \ %D%/packages/patches/abiword-explictly-cast-bools.patch \ %D%/packages/patches/abiword-wmf-version-lookup-fix.patch \ %D%/packages/patches/acl-hurd-path-max.patch \ + %D%/packages/patches/adb-fix-build.patch \ %D%/packages/patches/aegis-constness-error.patch \ %D%/packages/patches/aegis-perl-tempdir1.patch \ %D%/packages/patches/aegis-perl-tempdir2.patch \ diff --git a/gnu/packages/android.scm b/gnu/packages/android.scm new file mode 100644 index 000000000..f4aa02858 --- /dev/null +++ b/gnu/packages/android.scm @@ -0,0 +1,132 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2016 Julien Lepiller +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages android) + #:use-module ((srfi srfi-1) #:hide (zip)) + #:use-module (gnu packages) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix build-system gnu) + #:use-module (gnu packages tls) + #:use-module (gnu packages gcc) + #:use-module (gnu packages llvm)) + +(define-public adb + (package + (name "adb") + (version "7.0.0_r21") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://android.googlesource.com/platform/system/= core") + (commit (string-append "android-" version)))) + (sha256 + (base32 + "0570iyxkknhfl6q4jif8569f6zxiqpg7vrgprk5jz2jjvz4wkd2h")) + (patches (search-patches "adb-fix-build.patch")))) + (build-system gnu-build-system) + (propagated-inputs `(("openssl" ,openssl))) + (arguments + `(#:parallel-build? #f + #:tests? #f + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'fix-clang + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "adb/adb_client.h" + (("_Nonnull") "") + (("_Nullable") "")))) + (replace 'build + (lambda* (#:key inputs #:allow-other-keys) + (define (compile-c file) + (format #t "CC ~a\n" file) + (zero? (system* "gcc" "-o" (string-append file ".o") + "-std=3Dgnu11" "-DLIBLOG_LOG_TAG=3D1005" + "-DFAKE_LOG_DEVICE=3D1" "-D_GNU_SOURCE" + "-Ilog/include" "-Iinclude" "-c" + file))) + (define (compile-cpp file) + (format #t "CPP ~a\n" file) + (zero? (system* "g++" "-o" (string-append file ".o") + "-std=3Dgnu++14" + (string-append "-DADB_REVISION=3D" "\"" + ,version "\"") + (string-append "-I" (assoc-ref inputs "g= cc") + "/include/c++") + (string-append "-I" (assoc-ref inputs "g= cc") + "/include/c++/backward") + (string-append "-I" (assoc-ref inputs "g= cc") + "/include/c++/x86_64-unkn= own-linux-gnu") + "-DWORKAROUND_BUG6558362" "-D_GNU_SOURCE" + "-DADB_HOST=3D1" "-fpermissive" + "-Iinclude" "-Ibase/include" + "-Iadb" "-c" file))) + (define cpp-source + (list "adb/adb.cpp" "adb/adb_auth.cpp" + "adb/adb_io.cpp" "adb/adb_listeners.cpp" + "adb/adb_trace.cpp" "adb/adb_utils.cpp" + "adb/line_printer.cpp" "adb/sockets.cpp" + "adb/transport.cpp" "adb/transport_local.cpp" + "adb/transport_usb.cpp" "adb/sysdeps_unix.cpp" + "adb/fdevent.cpp" "adb/get_my_path_linux.cpp" + "adb/usb_linux.cpp" "adb/adb_auth_host.cpp" + "adb/shell_service_protocol.cpp" + "adb/console.cpp" "adb/commandline.cpp" + "adb/adb_client.cpp" "adb/services.cpp" + "adb/file_sync_client.cpp" "adb/client/main.cpp" + "base/file.cpp" "base/logging.cpp" + "base/parsenetaddress.cpp" "base/stringprintf.cpp" + "base/strings.cpp" "base/errors_unix.cpp" + "libcutils/sockets_unix.cpp" "libcutils/sockets.c= pp" + "adb/diagnose_usb.cpp")) + (define c-source + (list "liblog/log_event_write.c" "liblog/fake_log_devic= e.c" + "liblog/log_event_list.c" "liblog/logger_write.c" + "liblog/config_write.c" "liblog/logger_lock.c" + "liblog/fake_writer.c" "liblog/logger_name.c" + "libcutils/load_file.c" + "libcutils/socket_local_client_unix.c" + "libcutils/socket_loopback_client_unix.c" + "libcutils/socket_network_client_unix.c" + "libcutils/socket_loopback_server_unix.c" + "libcutils/socket_local_server_unix.c" + "libcutils/socket_inaddr_any_server_unix.c")) + (define (file-o list) + (string-join (map (lambda (str) (string-append str ".o")) + list))) + (map compile-c c-source) + (map compile-cpp cpp-source) + (zero? + (system + (string-append "g++ -o myadb -lrt -ldl -lpthread -lcry= pto " + (file-o c-source) " " (file-o cpp-sourc= e)))))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((bin (string-append (assoc-ref outputs "out") "/bin"= ))) + (mkdir-p bin) + (copy-file "myadb" (string-append bin "/adb")))))))) + (home-page + "https://android.googlesource.com/platform/system/core/") + (synopsis "Android Debug Bridge") + (description "Allows you to communicate with your android device throu= gh the +Android Debug Bridge.") + (license license:asl2.0))) ; and others for some files + diff --git a/gnu/packages/patches/adb-fix-build.patch b/gnu/packages/patche= s/adb-fix-build.patch new file mode 100644 index 000000000..fc81d6849 --- /dev/null +++ b/gnu/packages/patches/adb-fix-build.patch @@ -0,0 +1,67 @@ +This patch fixes the build of adb on linux. It was taken from archlinux. +diff --git a/adb/sysdeps.h b/adb/sysdeps.h +index 75dcc86..867f3ec 100644 +--- a/adb/sysdeps.h ++++ b/adb/sysdeps.h +@@ -25,6 +25,7 @@ + #endif +=20 + #include ++#include +=20 + #include + #include +@@ -831,7 +832,16 @@ static __inline__ int adb_is_absolute_host_path(const= char* path) { +=20 + static __inline__ unsigned long adb_thread_id() + { +- return (unsigned long)gettid(); ++ // TODO: this function should be merged with GetThreadId ++#if defined(__BIONIC__) ++ return gettid(); ++#elif defined(__APPLE__) ++ return syscall(SYS_thread_selfid); ++#elif defined(__linux__) ++ return syscall(__NR_gettid); ++#elif defined(_WIN32) ++ return GetCurrentThreadId(); ++#endif + } +=20 + #endif /* !_WIN32 */ +diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp +index 296995e..48269b6 100644 +--- a/base/errors_unix.cpp ++++ b/base/errors_unix.cpp +@@ -17,6 +17,7 @@ + #include "android-base/errors.h" +=20 + #include ++#include +=20 + namespace android { + namespace base { +diff --git a/base/file.cpp b/base/file.cpp +index da1adba..91a3901 100644 +--- a/base/file.cpp ++++ b/base/file.cpp +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include +=20 + #include +=20 +diff --git a/base/logging.cpp b/base/logging.cpp +index 1741871..e97c7f1 100644 +--- a/base/logging.cpp ++++ b/base/logging.cpp +@@ -21,6 +21,7 @@ + #include "android-base/logging.h" +=20 + #include ++#include +=20 + // For getprogname(3) or program_invocation_short_name. + #if defined(__ANDROID__) || defined(__APPLE__) --=20 2.11.0 --MP_/_0s/LdQsAm84OnF9d_WSPO/--