diff options
Diffstat (limited to 'dev-util/android-tools/files')
6 files changed, 231 insertions, 158 deletions
diff --git a/dev-util/android-tools/files/android-tools-33.0.3-adb-0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch b/dev-util/android-tools/files/android-tools-33.0.3-adb-0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch new file mode 100644 index 000000000000..25572574d834 --- /dev/null +++ b/dev-util/android-tools/files/android-tools-33.0.3-adb-0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch @@ -0,0 +1,120 @@ +https://github.com/anatol/android-tools/blob/2f8405a47909861c9359fe4797e7b4a0fba4dc12/patches/adb/0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch +https://github.com/nmeum/android-tools/issues/74 +https://bugs.gentoo.org/876328 + +From c830c90995fc0877348e2ed9cdeccf9b739138d2 Mon Sep 17 00:00:00 2001 +From: Anatol Pomozov <anatol.pomozov@gmail.com> +Date: Mon, 10 Oct 2022 10:47:57 -0700 +Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") +where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member. + +Current USB API usage causes a compilation error at Linux 6.0: + +In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28: +/usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’ + 134 | struct usbdevfs_iso_packet_desc iso_frame_desc[]; + | ^~~~~~~~~~~~~~ +/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member ‘usbdevfs_urb usb_handle::urb_out’ declared here + 76 | usbdevfs_urb urb_out; + | ^~~~~~~ +/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of ‘struct usb_handle’ + 61 | struct usb_handle { + | ^~~~~~~~~~ + +Fix it by using pointers to a struct with flexible-array members. +Current fix works both with the old and the new API. + +See https://github.com/nmeum/android-tools/issues/74 for more context. + +Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB +cable +Acked-by: Gustavo A. R. Silva gustavoars@kernel.org +Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101 +Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> +--- a/client/usb_linux.cpp ++++ b/client/usb_linux.cpp +@@ -71,8 +71,8 @@ struct usb_handle { + unsigned zero_mask; + unsigned writeable = 1; + +- usbdevfs_urb urb_in; +- usbdevfs_urb urb_out; ++ usbdevfs_urb *urb_in; ++ usbdevfs_urb *urb_out; + + bool urb_in_busy = false; + bool urb_out_busy = false; +@@ -303,7 +303,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) { + std::unique_lock<std::mutex> lock(h->mutex); + D("++ usb_bulk_write ++"); + +- usbdevfs_urb* urb = &h->urb_out; ++ usbdevfs_urb* urb = h->urb_out; + memset(urb, 0, sizeof(*urb)); + urb->type = USBDEVFS_URB_TYPE_BULK; + urb->endpoint = h->ep_out; +@@ -342,7 +342,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + std::unique_lock<std::mutex> lock(h->mutex); + D("++ usb_bulk_read ++"); + +- usbdevfs_urb* urb = &h->urb_in; ++ usbdevfs_urb* urb = h->urb_in; + memset(urb, 0, sizeof(*urb)); + urb->type = USBDEVFS_URB_TYPE_BULK; + urb->endpoint = h->ep_in; +@@ -387,7 +387,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + } + D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length); + +- if (out == &h->urb_in) { ++ if (out == h->urb_in) { + D("[ reap urb - IN complete ]"); + h->urb_in_busy = false; + if (urb->status != 0) { +@@ -396,7 +396,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + } + return urb->actual_length; + } +- if (out == &h->urb_out) { ++ if (out == h->urb_out) { + D("[ reap urb - OUT compelete ]"); + h->urb_out_busy = false; + h->cv.notify_all(); +@@ -500,10 +500,10 @@ void usb_kick(usb_handle* h) { + ** but this ensures that a reader blocked on REAPURB + ** will get unblocked + */ +- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in); +- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out); +- h->urb_in.status = -ENODEV; +- h->urb_out.status = -ENODEV; ++ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in); ++ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out); ++ h->urb_in->status = -ENODEV; ++ h->urb_out->status = -ENODEV; + h->urb_in_busy = false; + h->urb_out_busy = false; + h->cv.notify_all(); +@@ -519,6 +519,8 @@ int usb_close(usb_handle* h) { + + D("-- usb close %p (fd = %d) --", h, h->fd); + ++ delete h->urb_in; ++ delete h->urb_out; + delete h; + + return 0; +@@ -572,6 +574,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned + usb->ep_out = ep_out; + usb->zero_mask = zero_mask; + usb->max_packet_size = max_packet_size; ++ usb->urb_in = new usbdevfs_urb; ++ usb->urb_out = new usbdevfs_urb; + + // Initialize mark so we don't get garbage collected after the device scan. + usb->mark = true; diff --git a/dev-util/android-tools/files/android-tools-33.0.3-adb-gcc-13.patch b/dev-util/android-tools/files/android-tools-33.0.3-adb-gcc-13.patch new file mode 100644 index 000000000000..4ba2c9a49c31 --- /dev/null +++ b/dev-util/android-tools/files/android-tools-33.0.3-adb-gcc-13.patch @@ -0,0 +1,25 @@ +https://bugs.gentoo.org/875575 +https://android-review.googlesource.com/c/platform/packages/modules/adb/+/2399311 + +From ddffab649b12dce1502d63711836b58d007f6a28 Mon Sep 17 00:00:00 2001 +From: Heiko Becker <heirecka@exherbo.org> +Date: Mon, 23 Jan 2023 23:09:52 +0100 +Subject: [PATCH] Fix build with gcc 13 by including <cstdint> + +Like other versions before, gcc 13 moved some includes around and as a +result <cstdint> is no longer transitively included. Explicitly include +it for uint{32,64}_t. + +Test: local build +Change-Id: I05a27726b05427c486fd01b013dba4d698abac97 +--- a/file_sync_protocol.h ++++ b/file_sync_protocol.h +@@ -16,6 +16,8 @@ + + #pragma once + ++#include <cstdint> ++ + #define MKID(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) + + #define ID_LSTAT_V1 MKID('S', 'T', 'A', 'T') diff --git a/dev-util/android-tools/files/android-tools-34.0.0-protobuf.patch b/dev-util/android-tools/files/android-tools-34.0.0-protobuf.patch new file mode 100644 index 000000000000..d7aa309410a4 --- /dev/null +++ b/dev-util/android-tools/files/android-tools-34.0.0-protobuf.patch @@ -0,0 +1,41 @@ +https://bugs.gentoo.org/912789 +https://github.com/nmeum/android-tools/commit/c5eae90a06072c6982e483f8154e490b47e620f7 +https://github.com/nmeum/android-tools/pull/120#issuecomment-1621066529 + +--- a/vendor/CMakeLists.txt ++++ b/vendor/CMakeLists.txt +@@ -73,6 +73,8 @@ + pkg_check_modules(libzstd REQUIRED IMPORTED_TARGET libzstd) + ++find_package(Protobuf CONFIG) + find_package(Protobuf REQUIRED) ++set(PROTOBUF_LIBRARIES protobuf::libprotobuf) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + +--- a/vendor/extras/libjsonpb/parse/jsonpb.cpp ++++ b/vendor/extras/libjsonpb/parse/jsonpb.cpp +@@ -50,8 +50,10 @@ + if (!status.ok()) { + #if GOOGLE_PROTOBUF_VERSION < 3016000 + return MakeError<std::string>(status.error_message().as_string()); +-#else ++#elif GOOGLE_PROTOBUF_VERSION < 4022000 + return MakeError<std::string>(status.message().as_string()); ++#else ++ return MakeError<std::string>(std::string(status.message())); + #endif + } + return ErrorOr<std::string>(std::move(json)); +@@ -67,8 +69,10 @@ + if (!status.ok()) { + #if GOOGLE_PROTOBUF_VERSION < 3016000 + return MakeError<std::monostate>(status.error_message().as_string()); +-#else ++#elif GOOGLE_PROTOBUF_VERSION < 4022000 + return MakeError<std::monostate>(status.message().as_string()); ++#else ++ return MakeError<std::monostate>(std::string(status.message())); + #endif + } + if (!message->ParseFromString(binary)) { diff --git a/dev-util/android-tools/files/android-tools-34.0.1-include-algorithm.patch b/dev-util/android-tools/files/android-tools-34.0.1-include-algorithm.patch new file mode 100644 index 000000000000..79bd52c4c634 --- /dev/null +++ b/dev-util/android-tools/files/android-tools-34.0.1-include-algorithm.patch @@ -0,0 +1,45 @@ +From 805c7e385123c6c142c8fec941406fea62af4459 Mon Sep 17 00:00:00 2001 +From: Christopher Fore <csfore@posteo.net> +Date: Sat, 9 Dec 2023 15:07:12 -0500 +Subject: [PATCH] dev-util/android-tools: Add patch to fix compilation on GCC 14 + +https://github.com/gentoo/gentoo/pull/34201 +--- + +diff --git a/vendor/adb/client/incremental_utils.cpp b/vendor/adb/client/incremental_utils.cpp +index 2f6958b..67f21a1 100644 +--- a/vendor/adb/client/incremental_utils.cpp ++++ b/vendor/adb/client/incremental_utils.cpp +@@ -24,6 +24,7 @@ + #include <ziparchive/zip_archive.h> + #include <ziparchive/zip_writer.h> + ++#include <algorithm> + #include <array> + #include <cinttypes> + #include <numeric> +diff --git a/vendor/core/fs_mgr/liblp/super_layout_builder.cpp b/vendor/core/fs_mgr/liblp/super_layout_builder.cpp +index 37f28e1..0db82e5 100644 +--- a/vendor/core/fs_mgr/liblp/super_layout_builder.cpp ++++ b/vendor/core/fs_mgr/liblp/super_layout_builder.cpp +@@ -17,6 +17,8 @@ + + #include <liblp/liblp.h> + ++#include <algorithm> ++ + #include "images.h" + #include "utility.h" + #include "writer.h" +diff --git a/vendor/core/fs_mgr/liblp/utility.cpp b/vendor/core/fs_mgr/liblp/utility.cpp +index d8e171b..70c7b79 100644 +--- a/vendor/core/fs_mgr/liblp/utility.cpp ++++ b/vendor/core/fs_mgr/liblp/utility.cpp +@@ -25,6 +25,7 @@ + #include <sys/ioctl.h> + #endif + ++#include <algorithm> + #include <map> + #include <string> + #include <vector> diff --git a/dev-util/android-tools/files/android-tools-8.1.0_p1-build.patch b/dev-util/android-tools/files/android-tools-8.1.0_p1-build.patch deleted file mode 100644 index f3d664ef70a3..000000000000 --- a/dev-util/android-tools/files/android-tools-8.1.0_p1-build.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/adb/sysdeps.h -+++ b/adb/sysdeps.h -@@ -66,6 +66,11 @@ - #endif - #endif - -+#ifndef __clang__ -+#define _Nonnull -+#define _Nullable -+#endif -+ - #ifdef _WIN32 - - // Clang-only nullability specifiers ---- a/libcutils/include/cutils/trace.h -+++ b/libcutils/include/cutils/trace.h -@@ -18,7 +18,13 @@ - #define _LIBS_CUTILS_TRACE_H - - #include <inttypes.h> -+// https://gcc.gnu.org/PR60932 -+#ifdef __cplusplus -+#include <atomic> -+using namespace std; -+#else - #include <stdatomic.h> -+#endif - #include <stdbool.h> - #include <stdint.h> - #include <stdio.h> diff --git a/dev-util/android-tools/files/make-tarballs.sh b/dev-util/android-tools/files/make-tarballs.sh deleted file mode 100755 index 5a0a775c1290..000000000000 --- a/dev-util/android-tools/files/make-tarballs.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -# Copyright 1999-2018 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -# Create the various tarballs we need. GoB does not provide stable archives (unlike github), -# and some repos are uselessly fat, so we have to create things by hand. Fun times. - -set -e - -die() { - echo "error: $*" >&2 - exit 1 -} - -fetch_boringssl() { - local ver=$1 tag=$2 - local content hash - - echo "checking boringssl in ${tag}" - content=$(wget -nv "https://android.googlesource.com/platform/external/boringssl/+/${tag}/BORINGSSL_REVISION?format=TEXT" -O -) - hash=$(echo "${content}" | base64 -d) - echo "using boringssl ${hash}" - - local tar="${DISTDIR}/boringssl-${hash}.tar.gz" - if [[ ! -e ${tar} ]] ; then - # We use github as it provides stable tarballs. GoB does not (includes timestamps). - # https://boringssl.googlesource.com/boringssl/+archive/${hash}.tar.gz - wget -c "https://github.com/google/boringssl/archive/${hash}.tar.gz" -O "${tar}" - fi - - du -h "${tar}" -} - -# The extras repo has ballooned to ~200MB, so we have to strip the large useless -# files and random binaries. -fetch_extras() { - local ver=$1 tag=$2 - local tar="${DISTDIR}/android-tools-${ver}-extras.tar.xz" - - if [[ ! -e ${tar} ]] ; then - local prune=( - ioshark - memory_replay - perfprofd - simpleperf - ) - local dir="${tag}-extras" - rm -rf "${dir}" - mkdir "${dir}" - cd "${dir}" - - wget "https://android.googlesource.com/platform/system/extras/+archive/${tag}.tar.gz" -O extras.tar.gz - tar xf extras.tar.gz - rm -rf "${prune[@]}" extras.tar.gz - - cd .. - tar cf - "${dir}" | xz -9 > "${dir}.tar.xz" - rm -rf "${dir}" - - mv "${dir}.tar.xz" "${tar}" - fi - - du -h "${tar}" -} - -# Since the GoB archive is unstable, we might as well rewrite it into xz to shrink. -fetch_selinux() { - local ver=$1 tag=$2 - local tar="${DISTDIR}/android-tools-${ver}-selinux.tar.xz" - - if [[ ! -e ${tar} ]] ; then - wget "https://android.googlesource.com/platform/external/selinux/+archive/${tag}.tar.gz" -O - | zcat | xz > "${tar}" - fi - - du -h "${tar}" -} - -# Since the GoB archive is unstable, we might as well rewrite it into xz to shrink. -fetch_f2fs() { - local ver=$1 tag=$2 - local tar="${DISTDIR}/android-tools-${ver}-f2fs-tools.tar.xz" - - if [[ ! -e ${tar} ]] ; then - wget "https://android.googlesource.com/platform/external/f2fs-tools/+archive/${tag}.tar.gz" -O - | zcat | xz > "${tar}" - fi - - du -h "${tar}" -} - -usage() { - local status=$1 - - [[ ${status} -eq 1 ]] && exec 1>&2 - - cat <<-EOF - Usage: $0 <android version> - - To find the next available version, consult: - https://git.archlinux.org/svntogit/community.git/log/trunk?h=packages/android-tools - - They have some helper scripts for building the files directly. - - Example: - $0 android-8.1.0_r1 - EOF - - exit ${status} -} - -main() { - [[ $# -ne 1 ]] && usage 1 - [[ $1 == "-h" || $1 == "--help" ]] && usage 0 - - if [[ -z ${DISTDIR} ]] ; then - eval $(portageq -v envvar DISTDIR) - fi - if [[ -z ${DISTDIR} ]] ; then - die "Please set \$DISTDIR first" - fi - - local ver="${1#android-}" - local tag="android-${ver}" - fetch_boringssl "${ver}" "${tag}" - fetch_extras "${ver}" "${tag}" - fetch_selinux "${ver}" "${tag}" - fetch_f2fs "${ver}" "${tag}" -} -main "$@" |