Index: head/devel/android-tools-adb/Makefile =================================================================== --- head/devel/android-tools-adb/Makefile (revision 448521) +++ head/devel/android-tools-adb/Makefile (revision 448522) @@ -1,98 +1,116 @@ # $FreeBSD$ PORTNAME= android-tools-adb DISTVERSIONPREFIX= android- -DISTVERSION?= 7.1.2_r17 +DISTVERSION?= 8.0.0_r4 PORTREVISION?= 0 CATEGORIES= devel comms + .ifndef EXTRA_PATCHES -PATCH_SITES= https://github.com/android/platform_system_core/commit/ -PATCHFILES= b4cff495a1f9.patch:-p1 +PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/ +PATCHFILES+= 46de1d7f03b7.patch:-p1 +PATCHFILES+= 5d002b8d6ae0.patch:-p1 .endif MAINTAINER= jbeich@FreeBSD.org COMMENT= Android debug bridge command line tool LICENSE= APACHE20 USE_GITHUB= yes GH_ACCOUNT= android GH_PROJECT= platform_system_core # Emulate GH_COMMIT without causing desync .ifdef DISTVERSIONSUFFIX GH_REVISION= ${DISTVERSIONSUFFIX:S/-g//} # snapshot .else -GH_REVISION= 1346a4012db4 # generated by: make update-revision +GH_REVISION= f6a78079a81a # generated by: make update-revision .endif CONFLICTS_INSTALL?= ${PORTNAME}-devel-* .ifndef EXTRA_PATCHES -EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-adb_sysdeps_mutex.h -EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_file.cpp +EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_include_android-base_logging.h .endif -USES+= compiler:c++11-lib pkgconfig ssl uidfix +USES+= compiler:c++14-lang pkgconfig ssl uidfix BUILD_WRKSRC= ${WRKSRC}/adb INSTALL_WRKSRC= ${BUILD_WRKSRC} TEST_WRKSRC= ${BUILD_WRKSRC} CPPFLAGS+= -D_GLIBCXX_USE_C99 # XXX ports/193528 MAKEFILE= ${FILESDIR}/Makefile MAKE_ENV= BINDIR="${PREFIX}/bin" EXTRADIR="${FILESDIR}" \ FILESDIR="${DOCSDIR}" REVISION="${GH_REVISION}" ALL_TARGET= all TEST_TARGET= test PLIST_FILES= bin/adb PORTDOCS= * -OPTIONS_DEFINE+=BASH DOCS TEST +OPTIONS_DEFINE+=MDNSRESPONDER BASH DOCS TEST TEST_PYTHON +OPTIONS_DEFAULT=MDNSRESPONDER OPTIONS_SUB= yes .if make(makesum) # for optional distfiles .MAKEFLAGS: WITH="${OPTIONS_DEFINE}" .endif BASH_GH_ACCOUNT= mbrubeck:bashcomp BASH_GH_PROJECT= android-completion:bashcomp BASH_GH_TAGNAME= c1b0656:bashcomp BASH_PLIST_FILES= etc/bash_completion.d/adb BASH_VARS= LICENSE+=MIT LICENSE_COMB=multi DOCS_MAKE_ARGS_OFF= FILES="" FILESDIR="" +MDNSRESPONDER_LIB_DEPENDS= libdns_sd.so:net/mDNSResponder +MDNSRESPONDER_USES= localbase:ldflags +MDNSRESPONDER_LDFLAGS= -ldns_sd +MDNSRESPONDER_MAKE_ENV_OFF= MDNSEXT=_unsupported + TEST_BUILD_DEPENDS+= googlemock>=1.6.0:devel/googlemock \ googletest>=1.6.0:devel/googletest TEST_ALL_TARGET= adb_test -pre-install-TEST-on: do-test +TEST_PYTHON_DESC= ${TEST_DESC:S/tests/python &/} +TEST_PYTHON_GH_PROJECT= platform_development:development +TEST_PYTHON_BUILD_DEPENDS=${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock +TEST_PYTHON_USES= python:2.7,build post-patch: # XXX Hidden by poudriere/tinderbox, see lindev(4) for FreeBSD < 11.0 @if [ ! -e /dev/full ]; then \ ${REINPLACE_CMD} -e '/TEST/s/[^ ]*ENOSPC/DISABLED_&/' \ ${WRKSRC}/adb/adb_io_test.cpp; \ fi + +pre-install-TEST-on: do-test + +pre-install-TEST_PYTHON-on: +# XXX python tests may leave behind running adb server + ${SETENV} PATH=${BUILD_WRKSRC}:${PATH} \ + PYTHONPATH=${WRKSRC_development}/python-packages \ + ${PYTHON_CMD} -m unittest discover -vs ${BUILD_WRKSRC} post-install-BASH-on: ${MKDIR} ${STAGEDIR}${PREFIX}/${BASH_PLIST_FILES:H} ${INSTALL_DATA} ${WRKSRC_bashcomp}/android \ ${STAGEDIR}${PREFIX}/${BASH_PLIST_FILES} update-revision: # https://developer.github.com/v3/repos/commits/#get-a-single-commit # Pretend to be curl(1) for pretty-printed JSON to help parse with sed(1) @${REINPLACE_CMD} -i '' -e "/^GH_REVISION.*$@/s/=.*/= $$(\ ${SETENV} HTTP_USER_AGENT=curl ${FETCH_CMD} -qo- \ https://api.github.com/repos/${GH_ACCOUNT}/${GH_PROJECT}/commits/${GH_TAGNAME} | \ ${SED} -n '/sha/ { s/.*\"\([0-9a-f]\{12\}\).*/\1/p; q; }' \ ) # generated by: make $@/" \ ${.CURDIR}/Makefile .include # XXX Work around !target(makesum) .ifndef DISTVERSIONSUFFIX makesum: update-revision .endif Index: head/devel/android-tools-adb/distinfo =================================================================== --- head/devel/android-tools-adb/distinfo (revision 448521) +++ head/devel/android-tools-adb/distinfo (revision 448522) @@ -1,7 +1,11 @@ -TIMESTAMP = 1495068953 -SHA256 (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = fb8d053d846f439951c651f205c9c914531d8dace86da60474f6675a92576449 -SIZE (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = 1596372 +TIMESTAMP = 1498603192 +SHA256 (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 3eb686edb1ccaa7312fb195b65c413823a6d60442d519c499c18b2d18c3094a9 +SIZE (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 5115403 SHA256 (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = ca3311ba47a5edd56c929ac9aae57c02c2c3f1636519c5f67abb00b6e3ecd75c SIZE (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = 5967 -SHA256 (b4cff495a1f9.patch) = cfb45f82866c7b46bdb9aa62aa0f856c243c13083f37e93b07c4491ad2b7db50 -SIZE (b4cff495a1f9.patch) = 2066 +SHA256 (android-platform_development-android-8.0.0_r4_GH0.tar.gz) = b6399cc349a332ef818f5041dd39742322bcf96d54663ec8a11e38cb5271096c +SIZE (android-platform_development-android-8.0.0_r4_GH0.tar.gz) = 93751770 +SHA256 (46de1d7f03b7.patch) = 93bf49a9a93f2b660f39041f8dbd179ea8f1170c1bebeee42f7df1dc1c393579 +SIZE (46de1d7f03b7.patch) = 12346 +SHA256 (5d002b8d6ae0.patch) = 0d105587abea3afbfd320a95be3f8532f213778a6f699150c4d4477334c9eef2 +SIZE (5d002b8d6ae0.patch) = 1385 Index: head/devel/android-tools-adb/files/get_my_path_freebsd.cpp =================================================================== --- head/devel/android-tools-adb/files/get_my_path_freebsd.cpp (revision 448521) +++ head/devel/android-tools-adb/files/get_my_path_freebsd.cpp (nonexistent) @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 bsdroid project - * Alexey Tarasov - * - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -void -get_my_path(char *exe, size_t maxLen) -{ - int mib[4] = { - CTL_KERN, - KERN_PROC, - KERN_PROC_PATHNAME, - getpid() - }; - - sysctl(mib, 4, exe, &maxLen, NULL, 0); -} Property changes on: head/devel/android-tools-adb/files/get_my_path_freebsd.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/usb_libusb.cpp =================================================================== --- head/devel/android-tools-adb/files/usb_libusb.cpp (revision 448521) +++ head/devel/android-tools-adb/files/usb_libusb.cpp (nonexistent) @@ -1,615 +0,0 @@ -/* - * Copyright (C) 2009 bsdroid project - * Alexey Tarasov - * - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define TRACE_TAG USB - -#include "sysdeps.h" - -#include -#include -#include -#include -#include -#include - -#include "adb.h" -#include "transport.h" - -ADB_MUTEX_DEFINE( usb_lock ); -static libusb_context *ctx = NULL; - -struct usb_handle -{ - usb_handle *prev; - usb_handle *next; - - libusb_device *dev; - libusb_device_handle *devh; - int interface; - uint8_t dev_bus; - uint8_t dev_addr; - - int zero_mask; - unsigned char end_point_address[2]; - char serial[128]; - - adb_cond_t notify; - adb_mutex_t lock; -}; - -static usb_handle handle_list = { - .prev = &handle_list, - .next = &handle_list, -}; - -static void -usb_cleanup() -{ - libusb_exit(ctx); -} - -static void -report_bulk_libusb_error(int r) -{ - switch (r) { - case LIBUSB_ERROR_TIMEOUT: - D("Transfer timeout"); - break; - - case LIBUSB_ERROR_PIPE: - D("Control request is not supported"); - break; - - case LIBUSB_ERROR_OVERFLOW: - D("Device offered more data"); - break; - - case LIBUSB_ERROR_NO_DEVICE : - D("Device was disconnected"); - break; - - default: - D("Error %d during transfer", r); - break; - }; -} - -static int -usb_bulk_write(usb_handle *uh, const void *data, int len) -{ - int r = 0; - int transferred = 0; - - r = libusb_bulk_transfer(uh->devh, uh->end_point_address[1], - (unsigned char *)data, len, &transferred, 0); - - if (r != 0) { - D("usb_bulk_write(): "); - report_bulk_libusb_error(r); - return r; - } - - return (transferred); -} - -static int -usb_bulk_read(usb_handle *uh, void *data, int len) -{ - int r = 0; - int transferred = 0; - - r = libusb_bulk_transfer(uh->devh, uh->end_point_address[0], - (unsigned char *)data, len, - &transferred, 0); - - if (r != 0) { - D("usb_bulk_read(): "); - report_bulk_libusb_error(r); - return r; - } - - return (transferred); -} - -int -usb_write(usb_handle *uh, const void *_data, int len) -{ - unsigned char *data = (unsigned char*) _data; - int n; - int need_zero = 0; - - if (uh->zero_mask == 1) { - if (!(len & uh->zero_mask)) { - need_zero = 1; - } - } - - D("usb_write(): %p:%d -> transport %p", _data, len, uh); - - while (len > 0) { - int xfer = (len > 4096) ? 4096 : len; - - n = usb_bulk_write(uh, data, xfer); - - if (n != xfer) { - D("usb_write(): failed for transport %p (%d bytes left)", uh, len); - return -1; - } - - len -= xfer; - data += xfer; - } - - if (need_zero){ - n = usb_bulk_write(uh, _data, 0); - - if (n < 0) { - D("usb_write(): failed to finish operation for transport %p", uh); - } - return n; - } - - return 0; -} - -int -usb_read(usb_handle *uh, void *_data, int len) -{ - unsigned char *data = (unsigned char*)_data; - int n; - - D("usb_read(): %p:%d <- transport %p", _data, len, uh); - - while (len > 0) { - int xfer = (len > 4096) ? 4096 : len; - - n = usb_bulk_read(uh, data, xfer); - - if (n != xfer) { - if (n > 0) { - data += n; - len -= n; - continue; - } - - D("usb_read(): failed for transport %p (%d bytes left)", uh, len); - return -1; - } - - len -= xfer; - data += xfer; - } - - return 0; -} - -int -usb_close(usb_handle *h) -{ - D("usb_close(): closing transport %p", h); - adb_mutex_lock(&usb_lock); - - h->next->prev = h->prev; - h->prev->next = h->next; - h->prev = NULL; - h->next = NULL; - - libusb_release_interface(h->devh, h->interface); - libusb_close(h->devh); - libusb_unref_device(h->dev); - - adb_mutex_unlock(&usb_lock); - - free(h); - - return (0); -} - -void -usb_kick(usb_handle *h) -{ - D("usb_kick(): kicking transport %p", h); - - adb_mutex_lock(&h->lock); - unregister_usb_transport(h); - adb_mutex_unlock(&h->lock); - - h->next->prev = h->prev; - h->prev->next = h->next; - h->prev = NULL; - h->next = NULL; - - libusb_release_interface(h->devh, h->interface); - libusb_close(h->devh); - libusb_unref_device(h->dev); - free(h); -} - -static int -check_usb_interface(libusb_interface const *interface, - libusb_device_descriptor const *desc, - usb_handle *uh) -{ - int e; - - if (interface->num_altsetting == 0) { - D("check_usb_interface(): No interface settings"); - return -1; - } - - libusb_interface_descriptor const *idesc = &interface->altsetting[0]; - - if (idesc->bNumEndpoints != 2) { - D("check_usb_interface(): Interface have not 2 endpoints, ignoring"); - return -1; - } - - for (e = 0; e < idesc->bNumEndpoints; e++) { - libusb_endpoint_descriptor const *edesc = &idesc->endpoint[e]; - - if (edesc->bmAttributes != LIBUSB_TRANSFER_TYPE_BULK) { - D("check_usb_interface(): Endpoint (%u) is not bulk (%u), ignoring", - edesc->bmAttributes, LIBUSB_TRANSFER_TYPE_BULK); - return -1; - } - - if (edesc->bEndpointAddress & LIBUSB_ENDPOINT_IN) - uh->end_point_address[0] = edesc->bEndpointAddress; - else - uh->end_point_address[1] = edesc->bEndpointAddress; - - /* aproto 01 needs 0 termination */ - if (idesc->bInterfaceProtocol == 0x01) { - uh->zero_mask = edesc->wMaxPacketSize - 1; - D("check_usb_interface(): Forced Android interface protocol v.1"); - } - } - - D("check_usb_interface(): Device: %04x:%04x " - "iclass: %x, isclass: %x, iproto: %x ep: %x/%x-> ", - desc->idVendor, desc->idProduct, idesc->bInterfaceClass, - idesc->bInterfaceSubClass, idesc->bInterfaceProtocol, - uh->end_point_address[0], uh->end_point_address[1]); - - if (!is_adb_interface(desc->idVendor, desc->idProduct, - idesc->bInterfaceClass, idesc->bInterfaceSubClass, - idesc->bInterfaceProtocol)) - { - D("not matches"); - return -1; - } - - D("matches"); - return 1; -} - -static int -check_usb_interfaces(libusb_config_descriptor *config, - libusb_device_descriptor *desc, - usb_handle *uh) -{ - int i; - - for (i = 0; i < config->bNumInterfaces; ++i) { - if (check_usb_interface(&config->interface[i], desc, uh) != -1) { - /* found some interface and saved information about it */ - D("check_usb_interfaces(): Interface %d of %04x:%04x " - "matches Android device", i, desc->idVendor, - desc->idProduct); - - return i; - } - } - - return -1; -} - -static int -register_device(usb_handle *uh, const char *serial) -{ - D("register_device(): Registering %p [%s] as USB transport", - uh, serial); - - usb_handle* usb = reinterpret_cast(calloc(1, sizeof(usb_handle))); - if (usb == nullptr) fatal("couldn't allocate usb_handle"); - memcpy(usb, uh, sizeof(usb_handle)); - strcpy(usb->serial, uh->serial); - - adb_cond_init(&usb->notify, 0); - adb_mutex_init(&usb->lock, 0); - - adb_mutex_lock(&usb_lock); - - usb->next = &handle_list; - usb->prev = handle_list.prev; - usb->prev->next = usb; - usb->next->prev = usb; - - adb_mutex_unlock(&usb_lock); - - char devpath[64]; - snprintf(devpath, sizeof(devpath), "ugen%d.%d", - uh->dev_bus, uh->dev_addr); - - register_usb_transport(usb, serial, devpath, 1); - - return (1); -} - -static int -already_registered(usb_handle *uh) -{ - usb_handle *usb = NULL; - int exists = 0; - - adb_mutex_lock(&usb_lock); - - for (usb = handle_list.next; usb != &handle_list; usb = usb->next) { - if ((usb->dev_bus == uh->dev_bus) && - (usb->dev_addr == uh->dev_addr)) - { - exists = 1; - break; - } - } - - adb_mutex_unlock(&usb_lock); - - return exists; -} - -static void -check_device(libusb_device *dev) -{ - usb_handle uh; - int i = 0; - int found = -1; - char serial[256] = {0}; - - libusb_device_descriptor desc; - libusb_config_descriptor *config = NULL; - - int r = libusb_get_device_descriptor(dev, &desc); - - if (r != LIBUSB_SUCCESS) { - D("check_device(): Failed to get device descriptor"); - return; - } - - if ((desc.idVendor == 0) && (desc.idProduct == 0)) - return; - - D("check_device(): Probing usb device %04x:%04x", - desc.idVendor, desc.idProduct); - - if (!is_adb_interface(desc.idVendor, desc.idProduct, - ADB_CLASS, ADB_SUBCLASS, ADB_PROTOCOL)) - { - D("check_device(): Ignored due unknown vendor id"); - return; - } - - uh.dev_bus = libusb_get_bus_number(dev); - uh.dev_addr = libusb_get_device_address(dev); - - if (already_registered(&uh)) { - D("check_device(): Device (bus: %d, address: %d) " - "is already registered", uh.dev_bus, uh.dev_addr); - return; - } - - D("check_device(): Device bus: %d, address: %d", - uh.dev_bus, uh.dev_addr); - - r = libusb_get_active_config_descriptor(dev, &config); - - if (r != 0) { - if (r == LIBUSB_ERROR_NOT_FOUND) { - D("check_device(): Device %4x:%4x is unconfigured", - desc.idVendor, desc.idProduct); - return; - } - - D("check_device(): Failed to get configuration for %4x:%4x", - desc.idVendor, desc.idProduct); - return; - } - - if (config == NULL) { - D("check_device(): Sanity check failed after " - "getting active config"); - return; - } - - if (config->interface != NULL) { - found = check_usb_interfaces(config, &desc, &uh); - } - - /* not needed anymore */ - libusb_free_config_descriptor(config); - - r = libusb_open(dev, &uh.devh); - uh.dev = dev; - - if (r != 0) { - switch (r) { - case LIBUSB_ERROR_NO_MEM: - D("check_device(): Memory allocation problem"); - break; - - case LIBUSB_ERROR_ACCESS: - D("check_device(): Permissions problem, " - "current user priveleges are messed up?"); - break; - - case LIBUSB_ERROR_NO_DEVICE: - D("check_device(): Device disconected, bad cable?"); - break; - - default: - D("check_device(): libusb triggered error %d", r); - } - // skip rest - found = -1; - } - - if (found >= 0) { - D("check_device(): Device matches Android interface"); - // read the device's serial number - memset(serial, 0, sizeof(serial)); - uh.interface = found; - - r = libusb_claim_interface(uh.devh, uh.interface); - - if (r < 0) { - D("check_device(): Failed to claim interface %d", - uh.interface); - - goto fail; - } - - if (desc.iSerialNumber != 0) { - libusb_get_string_descriptor_ascii(uh.devh, desc.iSerialNumber, - (unsigned char *)uh.serial, sizeof(uh.serial)); - } - if (register_device(&uh, uh.serial) == 0) { - D("check_device(): Failed to register device\n"); - goto fail_interface; - } - } - - return; - -fail_interface: - libusb_release_interface(uh.devh, uh.interface); - -fail: - libusb_close(uh.devh); - uh.devh = NULL; -} - -static int -check_device_connected(usb_handle *uh) -{ - int r = libusb_kernel_driver_active(uh->devh, uh->interface); - - if (r == LIBUSB_ERROR_NO_DEVICE) - return 0; - - if (r < 0) - return -1; - - return 1; -} - -static void -kick_disconnected() -{ - usb_handle *usb = NULL; - - adb_mutex_lock(&usb_lock); - - for (usb = handle_list.next; usb != &handle_list; usb = usb->next) { - if (check_device_connected(usb) == 0) { - D("kick_disconnected(): Transport %p is not online anymore", - usb); - - usb_kick(usb); - } - } - - adb_mutex_unlock(&usb_lock); -} - -static void -scan_usb_devices() -{ - D("scan_usb_devices(): started"); - - libusb_device **devs= NULL; - libusb_device *dev= NULL; - ssize_t cnt = libusb_get_device_list(ctx, &devs); - - if (cnt < 0) { - D("scan_usb_devices(): Failed to get device list (error: %zd)", - cnt); - - return; - } - - int i = 0; - - while ((dev = devs[i++]) != NULL) { - check_device(dev); - } - - libusb_free_device_list(devs, 1); -} - -static void -device_poll_thread(void*) -{ - adb_thread_setname("USB scan"); - D("device_poll_thread(): Created USB scan thread"); - - for (;;) { - sleep(5); - kick_disconnected(); - scan_usb_devices(); - } -} - -static void -sigalrm_handler(int signo) -{ - /* nothing */ -} - -void -usb_init() -{ - D("usb_init(): started"); - struct sigaction actions; - - atexit(usb_cleanup); - int r = libusb_init(&ctx); - - if (r != LIBUSB_SUCCESS) { - fatal_errno("Failed to init libusb"); - } - - memset(&actions, 0, sizeof(actions)); - - sigemptyset(&actions.sa_mask); - - actions.sa_flags = 0; - actions.sa_handler = sigalrm_handler; - - sigaction(SIGALRM, &actions, NULL); - - /* initial device scan */ - scan_usb_devices(); - - /* starting USB event polling thread */ - if (!adb_thread_create(device_poll_thread, nullptr)) { - fatal_errno("cannot create USB scan thread"); - } - - D("usb_init(): finished"); -} Property changes on: head/devel/android-tools-adb/files/usb_libusb.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h =================================================================== --- head/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h (revision 448521) +++ head/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h (nonexistent) @@ -1,9 +0,0 @@ ---- adb/sysdeps/mutex.h.orig 2016-06-23 07:04:56 UTC -+++ adb/sysdeps/mutex.h -@@ -104,4 +104,6 @@ - - } - -+#else -+#include - #endif Property changes on: head/devel/android-tools-adb/files/extra-patch-adb_sysdeps_mutex.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/extra-patch-base_file.cpp =================================================================== --- head/devel/android-tools-adb/files/extra-patch-base_file.cpp (revision 448521) +++ head/devel/android-tools-adb/files/extra-patch-base_file.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- base/file.cpp.orig 2016-08-08 21:10:17 UTC -+++ base/file.cpp -@@ -21,6 +21,8 @@ - #include - #include - -+#include // BUFSIZ -+#include // strerror - #include - - #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. Property changes on: head/devel/android-tools-adb/files/extra-patch-base_file.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/Makefile =================================================================== --- head/devel/android-tools-adb/files/Makefile (revision 448521) +++ head/devel/android-tools-adb/files/Makefile (revision 448522) @@ -1,141 +1,156 @@ # $FreeBSD$ PROG_CXX=adb NO_MAN= BINDIR?=/usr/bin FILESDIR?=${DOCDIR}/${PROG} FILES= *.[Tt][Xx][Tt] SRCS+= adb.cpp -SRCS+= adb_auth.cpp SRCS+= adb_auth_host.cpp SRCS+= adb_client.cpp SRCS+= adb_io.cpp SRCS+= adb_listeners.cpp SRCS+= adb_trace.cpp SRCS+= adb_utils.cpp SRCS+= bugreport.cpp SRCS+= commandline.cpp SRCS+= console.cpp SRCS+= diagnose_usb.cpp SRCS+= fdevent.cpp SRCS+= file_sync_client.cpp SRCS+= line_printer.cpp SRCS+= services.cpp SRCS+= shell_service_protocol.cpp +SRCS+= socket_spec.cpp SRCS+= ../adb/sockets.cpp SRCS+= sysdeps_unix.cpp SRCS+= transport.cpp SRCS+= transport_local.cpp +SRCS+= transport_mdns${MDNSEXT}.cpp SRCS+= transport_usb.cpp TEST_SRCS+= adb_io_test.cpp +TEST_SRCS+= adb_listeners_test.cpp TEST_SRCS+= adb_utils_test.cpp TEST_SRCS+= bugreport_test.cpp TEST_SRCS+= fdevent_test.cpp TEST_SRCS+= shell_service_protocol_test.cpp +TEST_SRCS+= socket_spec_test.cpp TEST_SRCS+= socket_test.cpp TEST_SRCS+= sysdeps_test.cpp TEST_SRCS+= transport_test.cpp .PATH: ${.CURDIR}/client SRCS+= main.cpp +SRCS+= usb_libusb.cpp .PATH: ${.CURDIR}/sysdeps +SRCS+= errno.cpp TEST_SRCS+= stat_test.cpp -.PATH: ${EXTRADIR} -SRCS+= get_my_path_freebsd.cpp -SRCS+= usb_libusb.cpp +.PATH: ${.CURDIR}/sysdeps/posix +SRCS+= network.cpp .PATH: ${.CURDIR}/../base SRCS+= file.cpp SRCS+= logging.cpp SRCS+= parsenetaddress.cpp +SRCS+= quick_exit.cpp SRCS+= stringprintf.cpp SRCS+= strings.cpp TEST_SRCS+= file_test.cpp TEST_SRCS+= logging_test.cpp TEST_SRCS+= parsenetaddress_test.cpp +TEST_SRCS+= quick_exit_test.cpp TEST_SRCS+= stringprintf_test.cpp TEST_SRCS+= strings_test.cpp TEST_SRCS+= test_main.cpp TEST_SRCS+= test_utils.cpp +.PATH: ${.CURDIR}/../libcrypto_utils +SRCS+= android_pubkey.c + +.PATH: ${.CURDIR}/../libcrypto_utils/tests +TEST_SRCS+= android_pubkey_test.cpp + .PATH: ${.CURDIR}/../libcutils SRCS+= socket_inaddr_any_server_unix.c SRCS+= socket_local_client_unix.c SRCS+= socket_local_server_unix.c -SRCS+= socket_loopback_client_unix.c -SRCS+= socket_loopback_server_unix.c SRCS+= socket_network_client_unix.c SRCS+= ../libcutils/sockets.cpp SRCS+= load_file.c SRCS+= threads.c # XXX Obsolete after 10.2 or r279980/r280329 CPPFLAGS.sockets.cpp+= -o ${.TARGET} # required by base/file.cpp .PATH: ${.CURDIR}/../liblog +SRCS+= config_read.c SRCS+= config_write.c SRCS+= fake_log_device.c SRCS+= fake_writer.c +SRCS+= local_logger.c SRCS+= logger_lock.c SRCS+= logger_name.c SRCS+= logger_write.c -CPPFLAGS.config_write.c+= -DFAKE_LOG_DEVICE=1 +SRCS+= logprint.c +SRCS+= stderr_write.c REVISION?= $$(${GIT} rev-parse --short=12 HEAD 2>/dev/null || echo unknown) CPPFLAGS+= -DADB_REVISION="\"${REVISION}-android\"" CPPFLAGS+= -DADB_HOST=1 CPPFLAGS+= -DHAVE_FORKEXEC=1 CPPFLAGS+= -DHAVE_SYMLINKS CPPFLAGS+= -DHAVE_TERMIO_H CPPFLAGS+= -DHAVE_SYS_SOCKET_H CPPFLAGS+= -D_FILE_OFFSET_BITS=64 +CPPFLAGS+= -DFAKE_LOG_DEVICE=1 CPPFLAGS+= -I${.CURDIR} CPPFLAGS+= -I${.CURDIR}/../include CPPFLAGS+= -I${.CURDIR}/../base/include +CPPFLAGS+= -I${.CURDIR}/../libcrypto_utils/include CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}} CPPFLAGS+= $$(${PKG_CONFIG} libcrypto --cflags 2>/dev/null) CPPFLAGS+= $$(${PKG_CONFIG} libusb-1.0 --cflags 2>/dev/null) -CXXFLAGS+= -std=gnu++11 +CXXFLAGS+= -std=gnu++14 .ifndef COMPILE.c CFLAGS+= ${CPPFLAGS} CXXFLAGS+= ${CPPFLAGS} .endif TEST_CPPFLAGS+= $$(${GTEST_CONFIG} --cppflags) TEST_CPPFLAGS+= $$(${GMOCK_CONFIG} --cppflags) .for f in ${TEST_SRCS} CPPFLAGS.${f}+= ${TEST_CPPFLAGS} .endfor LDADD+= $$(${PKG_CONFIG} libcrypto --libs 2>/dev/null || echo -lcrypto) LDADD+= $$(${PKG_CONFIG} libusb-1.0 --libs 2>/dev/null || echo -lusb) LDADD+= -lz \-lpthread DPADD+= ${LIBCRYPTO} ${LIBPTHREAD} ${LIBUSB} ${LIBZ} TEST_LDADD+= $$(${GTEST_CONFIG} --libs --ldflags) TEST_LDADD+= $$(${GMOCK_CONFIG} --libs --ldflags) TEST_OBJS+= ${TEST_SRCS:R:S/$/.o/} CLEANFILES+= ${PROG}_test ${TEST_OBJS} GIT?= git GTEST_CONFIG?= gtest-config GMOCK_CONFIG?= gmock-config PKG_CONFIG?= pkg-config beforeinstall: ${INSTALL} -d ${DESTDIR}${FILESDIR} .include test: ${PROG}_test @for f in ${.ALLSRC}; do ./$$f; done ${PROG}_test: ${OBJS:Nmain.o:Ncommandline.o} ${TEST_OBJS} ${CXX} ${CPPFLAGS} ${CXXFLAGS} ${LDFLAGS} -o $@ $> ${LDADD} ${TEST_LDADD} Index: head/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h =================================================================== --- head/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h (nonexistent) +++ head/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h (revision 448522) @@ -0,0 +1,11 @@ +--- base/include/android-base/logging.h.orig 2015-09-29 18:07:07 UTC ++++ base/include/android-base/logging.h +@@ -321,7 +321,7 @@ struct LogAbortAfterFullExpr { + // DCHECKs are debug variants of CHECKs only enabled in debug builds. Generally + // CHECK should be used unless profiling identifies a CHECK as being in + // performance critical code. +-#if defined(NDEBUG) ++#if defined(NDEBUG) || !defined(__ANDROID__) + static constexpr bool kEnableDChecks = false; + #else + static constexpr bool kEnableDChecks = true; Property changes on: head/devel/android-tools-adb/files/extra-patch-base_include_android-base_logging.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp (revision 448522) @@ -0,0 +1,43 @@ +--- adb/adb_auth_host.cpp.orig 2016-06-29 23:43:15 UTC ++++ adb/adb_auth_host.cpp +@@ -34,7 +34,9 @@ + #include + #include + #include ++#if defined(OPENSSL_IS_BORINGSSL) + #include ++#endif + #include + #include + #include +@@ -70,6 +72,30 @@ static std::string get_user_info() { + return " " + username + "@" + hostname; + } + ++#if !defined(OPENSSL_IS_BORINGSSL) ++// https://boringssl.googlesource.com/boringssl/+/6601402%5E!/ ++static int EVP_EncodedLength(size_t *out_len, size_t len) { ++ if (len + 2 < len) { ++ return 0; ++ } ++ len += 2; ++ len /= 3; ++ ++ if (((len << 2) >> 2) != len) { ++ return 0; ++ } ++ len <<= 2; ++ ++ if (len + 1 < len) { ++ return 0; ++ } ++ len++; ++ ++ *out_len = len; ++ return 1; ++} ++#endif ++ + static bool write_public_keyfile(RSA* private_key, const std::string& private_key_path) { + uint8_t binary_key_data[ANDROID_PUBKEY_ENCODED_SIZE]; + if (!android_pubkey_encode(private_key, binary_key_data, sizeof(binary_key_data))) { Property changes on: head/devel/android-tools-adb/files/patch-adb_adb__auth__host.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp (revision 448522) @@ -0,0 +1,30 @@ +--- adb/client/usb_libusb.cpp.orig 2017-06-20 10:50:27 UTC ++++ adb/client/usb_libusb.cpp +@@ -22,13 +22,14 @@ + + #include + #include ++#include + #include + #include + #include + #include + #include + +-#include ++#include + + #include + #include +@@ -89,7 +89,11 @@ struct transfer_info { + }; + + namespace libusb { ++#if defined(__linux__) || defined(__APPLE__) + struct usb_handle : public ::usb_handle { ++#else ++struct usb_handle { ++#endif + usb_handle(const std::string& device_address, const std::string& serial, + unique_device_handle&& device_handle, uint8_t interface, uint8_t bulk_in, + uint8_t bulk_out, size_t zero_mask, size_t max_packet_size) Property changes on: head/devel/android-tools-adb/files/patch-adb_client_usb__libusb.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_commandline.h =================================================================== --- head/devel/android-tools-adb/files/patch-adb_commandline.h (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_commandline.h (revision 448522) @@ -0,0 +1,11 @@ +--- adb/commandline.h.orig 2016-09-28 18:07:09 UTC ++++ adb/commandline.h +@@ -17,6 +17,8 @@ + #ifndef COMMANDLINE_H + #define COMMANDLINE_H + ++#include // fwrite ++ + #include "adb.h" + + // Callback used to handle the standard streams (stdout and stderr) sent by the Property changes on: head/devel/android-tools-adb/files/patch-adb_commandline.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp (revision 448522) @@ -0,0 +1,10 @@ +--- adb/sysdeps_test.cpp.orig 2017-06-27 22:39:52 UTC ++++ adb/sysdeps_test.cpp +@@ -19,6 +19,7 @@ + + #include + #include ++#include + #include + + #include "adb_io.h" Property changes on: head/devel/android-tools-adb/files/patch-adb_sysdeps__test.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp (revision 448522) @@ -0,0 +1,10 @@ +--- adb/sysdeps/posix/network.cpp.orig 2017-06-20 10:50:27 UTC ++++ adb/sysdeps/posix/network.cpp +@@ -17,6 +17,7 @@ + #include "sysdeps/network.h" + + #include ++#include // strerror + #include + #include + Property changes on: head/devel/android-tools-adb/files/patch-adb_sysdeps_posix_network.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_transport__usb.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-adb_transport__usb.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_transport__usb.cpp (revision 448522) @@ -0,0 +1,11 @@ +--- adb/transport_usb.cpp.orig 2017-06-20 10:50:27 UTC ++++ adb/transport_usb.cpp +@@ -191,6 +191,8 @@ int is_adb_interface(int usb_class, int usb_subclass, + bool should_use_libusb() { + #if defined(_WIN32) || !ADB_HOST + return false; ++#elif !defined(__linux__) && !defined(__APPLE__) ++ return true; + #else + static bool disable = getenv("ADB_LIBUSB") && strcmp(getenv("ADB_LIBUSB"), "0") == 0; + return !disable; Property changes on: head/devel/android-tools-adb/files/patch-adb_transport__usb.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-adb_usb.h =================================================================== --- head/devel/android-tools-adb/files/patch-adb_usb.h (nonexistent) +++ head/devel/android-tools-adb/files/patch-adb_usb.h (revision 448522) @@ -0,0 +1,20 @@ +--- adb/usb.h.orig 2017-06-20 10:50:27 UTC ++++ adb/usb.h +@@ -43,6 +43,7 @@ namespace libusb { + ADB_USB_INTERFACE(libusb::usb_handle*); + } + ++#if defined(__linux__) || defined(__APPLE__) + namespace native { + struct usb_handle; + ADB_USB_INTERFACE(native::usb_handle*); +@@ -53,6 +54,9 @@ struct usb_handle { + }; + + ADB_USB_INTERFACE(::usb_handle*); ++#else ++using namespace libusb; ++#endif + + #endif // linux host || darwin + Property changes on: head/devel/android-tools-adb/files/patch-adb_usb.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-base_file.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-base_file.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-base_file.cpp (revision 448522) @@ -0,0 +1,47 @@ +--- base/file.cpp.orig 2017-06-20 10:50:27 UTC ++++ base/file.cpp +@@ -19,6 +19,10 @@ + #include + #include + #include ++#include // PATH_MAX ++#include // BUFSIZ ++#include // realpath ++#include // strerror + #include + #include + #include +@@ -36,6 +39,9 @@ + #if defined(__APPLE__) + #include + #endif ++#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) ++#include ++#endif + #if defined(_WIN32) + #include + #define O_CLOEXEC O_NOINHERIT +@@ -251,6 +258,23 @@ std::string GetExecutablePath() { + if (result == 0 || result == sizeof(path) - 1) return ""; + path[PATH_MAX - 1] = 0; + return path; ++#elif defined(KERN_PROC_PATHNAME) ++ char path[PATH_MAX + 1]; ++ size_t path_len = sizeof(path); ++ int mib[] = { ++ CTL_KERN, ++#if defined(__NetBSD__) ++ KERN_PROC_ARGS, ++ -1, ++ KERN_PROC_PATHNAME, ++#else ++ KERN_PROC, ++ KERN_PROC_PATHNAME, ++ -1, ++#endif ++ }; ++ int rc = sysctl(mib, arraysize(mib), path, &path_len, NULL, 0); ++ return rc ? "" : path; + #else + #error unknown OS + #endif Property changes on: head/devel/android-tools-adb/files/patch-base_file.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-base_file__test.cpp =================================================================== --- head/devel/android-tools-adb/files/patch-base_file__test.cpp (nonexistent) +++ head/devel/android-tools-adb/files/patch-base_file__test.cpp (revision 448522) @@ -0,0 +1,42 @@ +--- base/file_test.cpp.orig 2017-06-20 10:50:27 UTC ++++ base/file_test.cpp +@@ -52,12 +52,20 @@ TEST(file, ReadFileToString_WriteStringToFile_symlink) + ASSERT_EQ(0, unlink(link.path)); + ASSERT_EQ(0, symlink(target.path, link.path)); + ASSERT_FALSE(android::base::WriteStringToFile("foo", link.path, false)); ++#ifdef __linux__ + ASSERT_EQ(ELOOP, errno); ++#else ++ ASSERT_EQ(EMLINK, errno); ++#endif + ASSERT_TRUE(android::base::WriteStringToFile("foo", link.path, true)); + + std::string s; + ASSERT_FALSE(android::base::ReadFileToString(link.path, &s)); ++#ifdef __linux__ + ASSERT_EQ(ELOOP, errno); ++#else ++ ASSERT_EQ(EMLINK, errno); ++#endif + ASSERT_TRUE(android::base::ReadFileToString(link.path, &s, true)); + ASSERT_EQ("foo", s); + } +@@ -131,6 +139,7 @@ TEST(file, RemoveFileIfExist) { + + TEST(file, Readlink) { + #if !defined(_WIN32) ++#ifdef __linux__ + // Linux doesn't allow empty symbolic links. + std::string min("x"); + // ext2 and ext4 both have PAGE_SIZE limits. +@@ -139,6 +148,10 @@ TEST(file, Readlink) { + // in current kernels (and marlin/sailfish where we're seeing this + // failure are still on 3.18, far from current). http://b/33306057. + std::string max(static_cast(4096 - 2 - 1 - 1), 'x'); ++#else ++ std::string min(""); ++ std::string max(static_cast(1024 - 1), 'x'); ++#endif + + TemporaryDir td; + std::string min_path{std::string(td.path) + "/" + "min"}; Property changes on: head/devel/android-tools-adb/files/patch-base_file__test.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-include_cutils_trace.h =================================================================== --- head/devel/android-tools-adb/files/patch-include_cutils_trace.h (nonexistent) +++ head/devel/android-tools-adb/files/patch-include_cutils_trace.h (revision 448522) @@ -0,0 +1,17 @@ +--- include/cutils/trace.h.orig 2017-06-20 10:50:27 UTC ++++ include/cutils/trace.h +@@ -18,8 +18,14 @@ + #define _LIBS_CUTILS_TRACE_H + + #include ++#ifdef __cplusplus ++#include ++using std::atomic_bool; ++using std::memory_order_acquire; ++#else + #include + #include ++#endif + #include + #include + #include Property changes on: head/devel/android-tools-adb/files/patch-include_cutils_trace.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c =================================================================== --- head/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c (nonexistent) +++ head/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c (revision 448522) @@ -0,0 +1,79 @@ +--- libcrypto_utils/android_pubkey.c.orig 2016-04-16 00:01:39 UTC ++++ libcrypto_utils/android_pubkey.c +@@ -110,6 +110,76 @@ cleanup: + return ret; + } + ++#if !defined(OPENSSL_IS_BORINGSSL) ++// https://android.googlesource.com/platform/external/chromium_org/third_party/boringssl/src/+/6887edb%5E!/ ++ ++/* constant_time_select_ulong returns |x| if |v| is 1 and |y| if |v| is 0. Its ++ * behavior is undefined if |v| takes any other value. */ ++static BN_ULONG constant_time_select_ulong(int v, BN_ULONG x, BN_ULONG y) { ++ BN_ULONG mask = v; ++ mask--; ++ ++ return (~mask & x) | (mask & y); ++} ++ ++/* constant_time_le_size_t returns 1 if |x| <= |y| and 0 otherwise. |x| and |y| ++ * must not have their MSBs set. */ ++static int constant_time_le_size_t(size_t x, size_t y) { ++ return ((x - y - 1) >> (sizeof(size_t) * 8 - 1)) & 1; ++} ++ ++/* read_word_padded returns the |i|'th word of |in|, if it is not out of ++ * bounds. Otherwise, it returns 0. It does so without branches on the size of ++ * |in|, however it necessarily does not have the same memory access pattern. If ++ * the access would be out of bounds, it reads the last word of |in|. |in| must ++ * not be zero. */ ++static BN_ULONG read_word_padded(const BIGNUM *in, size_t i) { ++ /* Read |in->d[i]| if valid. Otherwise, read the last word. */ ++ BN_ULONG l = in->d[constant_time_select_ulong( ++ constant_time_le_size_t(in->dmax, i), in->dmax - 1, i)]; ++ ++ /* Clamp to zero if above |d->top|. */ ++ return constant_time_select_ulong(constant_time_le_size_t(in->top, i), 0, l); ++} ++ ++static int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in) { ++ size_t i; ++ BN_ULONG l; ++ ++ /* Special case for |in| = 0. Just branch as the probability is negligible. */ ++ if (BN_is_zero(in)) { ++ memset(out, 0, len); ++ return 1; ++ } ++ ++ /* Check if the integer is too big. This case can exit early in non-constant ++ * time. */ ++ if ((size_t)in->top > (len + (BN_BYTES - 1)) / BN_BYTES) { ++ return 0; ++ } ++ if ((len % BN_BYTES) != 0) { ++ l = read_word_padded(in, len / BN_BYTES); ++ if (l >> (8 * (len % BN_BYTES)) != 0) { ++ return 0; ++ } ++ } ++ ++ /* Write the bytes out one by one. Serialization is done without branching on ++ * the bits of |in| or on |in->top|, but if the routine would otherwise read ++ * out of bounds, the memory access pattern can't be fixed. However, for an ++ * RSA key of size a multiple of the word size, the probability of BN_BYTES ++ * leading zero octets is low. ++ * ++ * See Falko Stenzke, "Manger's Attack revisited", ICICS 2010. */ ++ i = len; ++ while (i--) { ++ l = read_word_padded(in, i / BN_BYTES); ++ *(out++) = (uint8_t)(l >> (8 * (i % BN_BYTES))) & 0xff; ++ } ++ return 1; ++} ++#endif ++ + static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) { + if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) { + return false; Property changes on: head/devel/android-tools-adb/files/patch-libcrypto__utils_android__pubkey.c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/Makefile =================================================================== --- head/devel/android-tools-adb-devel/Makefile (revision 448521) +++ head/devel/android-tools-adb-devel/Makefile (revision 448522) @@ -1,40 +1,20 @@ # $FreeBSD$ # Hint: git describe --abbrev=12 --match android-o-preview-2 DISTVERSION= o-preview-2-332 DISTVERSIONSUFFIX= -gd1e9e7bc06f0 PORTREVISION= 1 PKGNAMESUFFIX= -devel CONFLICTS_INSTALL= ${PORTNAME}-[0-9]* MASTERDIR= ${.CURDIR}/../android-tools-adb DISTINFO_FILE= ${.CURDIR}/distinfo FILESDIR= ${.CURDIR}/files EXTRA_PATCHES= ${.CURDIR}/files/patch-* GH_MYTAG= ${DISTVERSIONPREFIX}${DISTVERSION:C/-[0-9]*$//} -USES= compiler:c++14-lang - -OPTIONS_DEFINE= MDNSRESPONDER TEST_PYTHON -OPTIONS_DEFAULT=MDNSRESPONDER - -MDNSRESPONDER_LIB_DEPENDS= libdns_sd.so:net/mDNSResponder -MDNSRESPONDER_USES= localbase:ldflags -MDNSRESPONDER_LDFLAGS= -ldns_sd -MDNSRESPONDER_MAKE_ENV_OFF= MDNSEXT=_unsupported - -TEST_PYTHON_DESC= ${TEST_DESC:S/tests/python &/} -TEST_PYTHON_GH_PROJECT= platform_development:development TEST_PYTHON_GH_TAGNAME= ${GH_MYTAG}-83-gc5efdcc74:development -TEST_PYTHON_BUILD_DEPENDS=${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock -TEST_PYTHON_USES= python:2.7,build - -pre-install-TEST_PYTHON-on: -# XXX python tests may leave behind running adb server - ${SETENV} PATH=${BUILD_WRKSRC}:${PATH} \ - PYTHONPATH=${WRKSRC_development}/python-packages \ - ${PYTHON_CMD} -m unittest discover -vs ${BUILD_WRKSRC} .include "${MASTERDIR}/Makefile" Index: head/devel/android-tools-adb-devel/files/patch-base_file.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-base_file.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-base_file.cpp (nonexistent) @@ -1,47 +0,0 @@ ---- base/file.cpp.orig 2017-06-20 10:50:27 UTC -+++ base/file.cpp -@@ -19,6 +19,10 @@ - #include - #include - #include -+#include // PATH_MAX -+#include // BUFSIZ -+#include // realpath -+#include // strerror - #include - #include - #include -@@ -36,6 +39,9 @@ - #if defined(__APPLE__) - #include - #endif -+#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) -+#include -+#endif - #if defined(_WIN32) - #include - #define O_CLOEXEC O_NOINHERIT -@@ -251,6 +258,23 @@ std::string GetExecutablePath() { - if (result == 0 || result == sizeof(path) - 1) return ""; - path[PATH_MAX - 1] = 0; - return path; -+#elif defined(KERN_PROC_PATHNAME) -+ char path[PATH_MAX + 1]; -+ size_t path_len = sizeof(path); -+ int mib[] = { -+ CTL_KERN, -+#if defined(__NetBSD__) -+ KERN_PROC_ARGS, -+ -1, -+ KERN_PROC_PATHNAME, -+#else -+ KERN_PROC, -+ KERN_PROC_PATHNAME, -+ -1, -+#endif -+ }; -+ int rc = sysctl(mib, arraysize(mib), path, &path_len, NULL, 0); -+ return rc ? "" : path; - #else - #error unknown OS - #endif Property changes on: head/devel/android-tools-adb-devel/files/patch-base_file.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_commandline.h =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_commandline.h (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_commandline.h (nonexistent) @@ -1,11 +0,0 @@ ---- adb/commandline.h.orig 2016-09-28 18:07:09 UTC -+++ adb/commandline.h -@@ -17,6 +17,8 @@ - #ifndef COMMANDLINE_H - #define COMMANDLINE_H - -+#include // fwrite -+ - #include "adb.h" - - // Callback used to handle the standard streams (stdout and stderr) sent by the Property changes on: head/devel/android-tools-adb-devel/files/patch-adb_commandline.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-include_cutils_trace.h =================================================================== --- head/devel/android-tools-adb-devel/files/patch-include_cutils_trace.h (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-include_cutils_trace.h (nonexistent) @@ -1,17 +0,0 @@ ---- include/cutils/trace.h.orig 2017-06-20 10:50:27 UTC -+++ include/cutils/trace.h -@@ -18,8 +18,14 @@ - #define _LIBS_CUTILS_TRACE_H - - #include -+#ifdef __cplusplus -+#include -+using std::atomic_bool; -+using std::memory_order_acquire; -+#else - #include - #include -+#endif - #include - #include - #include Property changes on: head/devel/android-tools-adb-devel/files/patch-include_cutils_trace.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_usb.h =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_usb.h (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_usb.h (nonexistent) @@ -1,20 +0,0 @@ ---- adb/usb.h.orig 2017-06-20 10:50:27 UTC -+++ adb/usb.h -@@ -43,6 +43,7 @@ namespace libusb { - ADB_USB_INTERFACE(libusb::usb_handle*); - } - -+#if defined(__linux__) || defined(__APPLE__) - namespace native { - struct usb_handle; - ADB_USB_INTERFACE(native::usb_handle*); -@@ -53,6 +54,9 @@ struct usb_handle { - }; - - ADB_USB_INTERFACE(::usb_handle*); -+#else -+using namespace libusb; -+#endif - - #endif // linux host || darwin - Property changes on: head/devel/android-tools-adb-devel/files/patch-adb_usb.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-base_file__test.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-base_file__test.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-base_file__test.cpp (nonexistent) @@ -1,42 +0,0 @@ ---- base/file_test.cpp.orig 2017-06-20 10:50:27 UTC -+++ base/file_test.cpp -@@ -52,12 +52,20 @@ TEST(file, ReadFileToString_WriteStringToFile_symlink) - ASSERT_EQ(0, unlink(link.path)); - ASSERT_EQ(0, symlink(target.path, link.path)); - ASSERT_FALSE(android::base::WriteStringToFile("foo", link.path, false)); -+#ifdef __linux__ - ASSERT_EQ(ELOOP, errno); -+#else -+ ASSERT_EQ(EMLINK, errno); -+#endif - ASSERT_TRUE(android::base::WriteStringToFile("foo", link.path, true)); - - std::string s; - ASSERT_FALSE(android::base::ReadFileToString(link.path, &s)); -+#ifdef __linux__ - ASSERT_EQ(ELOOP, errno); -+#else -+ ASSERT_EQ(EMLINK, errno); -+#endif - ASSERT_TRUE(android::base::ReadFileToString(link.path, &s, true)); - ASSERT_EQ("foo", s); - } -@@ -131,6 +139,7 @@ TEST(file, RemoveFileIfExist) { - - TEST(file, Readlink) { - #if !defined(_WIN32) -+#ifdef __linux__ - // Linux doesn't allow empty symbolic links. - std::string min("x"); - // ext2 and ext4 both have PAGE_SIZE limits. -@@ -139,6 +148,10 @@ TEST(file, Readlink) { - // in current kernels (and marlin/sailfish where we're seeing this - // failure are still on 3.18, far from current). http://b/33306057. - std::string max(static_cast(4096 - 2 - 1 - 1), 'x'); -+#else -+ std::string min(""); -+ std::string max(static_cast(1024 - 1), 'x'); -+#endif - - TemporaryDir td; - std::string min_path{std::string(td.path) + "/" + "min"}; Property changes on: head/devel/android-tools-adb-devel/files/patch-base_file__test.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_adb__auth__host.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_adb__auth__host.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_adb__auth__host.cpp (nonexistent) @@ -1,43 +0,0 @@ ---- adb/adb_auth_host.cpp.orig 2016-06-29 23:43:15 UTC -+++ adb/adb_auth_host.cpp -@@ -34,7 +34,9 @@ - #include - #include - #include -+#if defined(OPENSSL_IS_BORINGSSL) - #include -+#endif - #include - #include - #include -@@ -70,6 +72,30 @@ static std::string get_user_info() { - return " " + username + "@" + hostname; - } - -+#if !defined(OPENSSL_IS_BORINGSSL) -+// https://boringssl.googlesource.com/boringssl/+/6601402%5E!/ -+static int EVP_EncodedLength(size_t *out_len, size_t len) { -+ if (len + 2 < len) { -+ return 0; -+ } -+ len += 2; -+ len /= 3; -+ -+ if (((len << 2) >> 2) != len) { -+ return 0; -+ } -+ len <<= 2; -+ -+ if (len + 1 < len) { -+ return 0; -+ } -+ len++; -+ -+ *out_len = len; -+ return 1; -+} -+#endif -+ - static bool write_public_keyfile(RSA* private_key, const std::string& private_key_path) { - uint8_t binary_key_data[ANDROID_PUBKEY_ENCODED_SIZE]; - if (!android_pubkey_encode(private_key, binary_key_data, sizeof(binary_key_data))) { Property changes on: head/devel/android-tools-adb-devel/files/patch-adb_adb__auth__host.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-libcrypto__utils_android__pubkey.c =================================================================== --- head/devel/android-tools-adb-devel/files/patch-libcrypto__utils_android__pubkey.c (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-libcrypto__utils_android__pubkey.c (nonexistent) @@ -1,79 +0,0 @@ ---- libcrypto_utils/android_pubkey.c.orig 2016-04-16 00:01:39 UTC -+++ libcrypto_utils/android_pubkey.c -@@ -110,6 +110,76 @@ cleanup: - return ret; - } - -+#if !defined(OPENSSL_IS_BORINGSSL) -+// https://android.googlesource.com/platform/external/chromium_org/third_party/boringssl/src/+/6887edb%5E!/ -+ -+/* constant_time_select_ulong returns |x| if |v| is 1 and |y| if |v| is 0. Its -+ * behavior is undefined if |v| takes any other value. */ -+static BN_ULONG constant_time_select_ulong(int v, BN_ULONG x, BN_ULONG y) { -+ BN_ULONG mask = v; -+ mask--; -+ -+ return (~mask & x) | (mask & y); -+} -+ -+/* constant_time_le_size_t returns 1 if |x| <= |y| and 0 otherwise. |x| and |y| -+ * must not have their MSBs set. */ -+static int constant_time_le_size_t(size_t x, size_t y) { -+ return ((x - y - 1) >> (sizeof(size_t) * 8 - 1)) & 1; -+} -+ -+/* read_word_padded returns the |i|'th word of |in|, if it is not out of -+ * bounds. Otherwise, it returns 0. It does so without branches on the size of -+ * |in|, however it necessarily does not have the same memory access pattern. If -+ * the access would be out of bounds, it reads the last word of |in|. |in| must -+ * not be zero. */ -+static BN_ULONG read_word_padded(const BIGNUM *in, size_t i) { -+ /* Read |in->d[i]| if valid. Otherwise, read the last word. */ -+ BN_ULONG l = in->d[constant_time_select_ulong( -+ constant_time_le_size_t(in->dmax, i), in->dmax - 1, i)]; -+ -+ /* Clamp to zero if above |d->top|. */ -+ return constant_time_select_ulong(constant_time_le_size_t(in->top, i), 0, l); -+} -+ -+static int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in) { -+ size_t i; -+ BN_ULONG l; -+ -+ /* Special case for |in| = 0. Just branch as the probability is negligible. */ -+ if (BN_is_zero(in)) { -+ memset(out, 0, len); -+ return 1; -+ } -+ -+ /* Check if the integer is too big. This case can exit early in non-constant -+ * time. */ -+ if ((size_t)in->top > (len + (BN_BYTES - 1)) / BN_BYTES) { -+ return 0; -+ } -+ if ((len % BN_BYTES) != 0) { -+ l = read_word_padded(in, len / BN_BYTES); -+ if (l >> (8 * (len % BN_BYTES)) != 0) { -+ return 0; -+ } -+ } -+ -+ /* Write the bytes out one by one. Serialization is done without branching on -+ * the bits of |in| or on |in->top|, but if the routine would otherwise read -+ * out of bounds, the memory access pattern can't be fixed. However, for an -+ * RSA key of size a multiple of the word size, the probability of BN_BYTES -+ * leading zero octets is low. -+ * -+ * See Falko Stenzke, "Manger's Attack revisited", ICICS 2010. */ -+ i = len; -+ while (i--) { -+ l = read_word_padded(in, i / BN_BYTES); -+ *(out++) = (uint8_t)(l >> (8 * (i % BN_BYTES))) & 0xff; -+ } -+ return 1; -+} -+#endif -+ - static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) { - if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) { - return false; Property changes on: head/devel/android-tools-adb-devel/files/patch-libcrypto__utils_android__pubkey.c ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_sysdeps_posix_network.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_sysdeps_posix_network.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_sysdeps_posix_network.cpp (nonexistent) @@ -1,10 +0,0 @@ ---- adb/sysdeps/posix/network.cpp.orig 2017-06-20 10:50:27 UTC -+++ adb/sysdeps/posix/network.cpp -@@ -17,6 +17,7 @@ - #include "sysdeps/network.h" - - #include -+#include // strerror - #include - #include - Property changes on: head/devel/android-tools-adb-devel/files/patch-adb_sysdeps_posix_network.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_transport__usb.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_transport__usb.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_transport__usb.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- adb/transport_usb.cpp.orig 2017-06-20 10:50:27 UTC -+++ adb/transport_usb.cpp -@@ -191,6 +191,8 @@ int is_adb_interface(int usb_class, int usb_subclass, - bool should_use_libusb() { - #if defined(_WIN32) || !ADB_HOST - return false; -+#elif !defined(__linux__) && !defined(__APPLE__) -+ return true; - #else - static bool disable = getenv("ADB_LIBUSB") && strcmp(getenv("ADB_LIBUSB"), "0") == 0; - return !disable; Property changes on: head/devel/android-tools-adb-devel/files/patch-adb_transport__usb.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-adb-devel/files/patch-adb_client_usb__libusb.cpp =================================================================== --- head/devel/android-tools-adb-devel/files/patch-adb_client_usb__libusb.cpp (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-adb_client_usb__libusb.cpp (revision 448522) @@ -1,123 +1,102 @@ --- adb/client/usb_libusb.cpp.orig 2017-06-20 10:50:27 UTC +++ adb/client/usb_libusb.cpp -@@ -28,7 +28,7 @@ - #include - #include - --#include -+#include - - #include - #include -@@ -89,7 +89,11 @@ struct transfer_info { - }; - - namespace libusb { -+#if defined(__linux__) || defined(__APPLE__) - struct usb_handle : public ::usb_handle { -+#else -+struct usb_handle { -+#endif - usb_handle(const std::string& device_address, const std::string& serial, - unique_device_handle&& device_handle, uint8_t interface, uint8_t bulk_in, - uint8_t bulk_out, size_t zero_mask, size_t max_packet_size) @@ -152,7 +156,14 @@ struct usb_handle : public ::usb_handle { static auto& usb_handles = *new std::unordered_map>(); static auto& usb_handles_mutex = *new std::mutex(); +#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102 static libusb_hotplug_callback_handle hotplug_handle; +#else +static std::thread* device_poll_thread = nullptr; +static bool terminate_device_poll_thread = false; +static auto& device_poll_mutex = *new std::mutex(); +static auto& device_poll_cv = *new std::condition_variable(); +#endif static std::string get_device_address(libusb_device* device) { return StringPrintf("usb:%d:%d", libusb_get_bus_number(device), @@ -380,6 +391,7 @@ static void process_device(libusb_device* device) { LOG(INFO) << "registered new usb device '" << device_serial << "'"; } +#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102 static std::atomic connecting_devices(0); static void device_connected(libusb_device* device) { @@ -449,7 +461,31 @@ static int hotplug_callback(libusb_context*, libusb_de hotplug_queue.Push({event, device}); return 0; } +#else +static void poll_for_devices() { + libusb_device** list; + adb_thread_setname("device poll"); + while (true) { + const ssize_t device_count = libusb_get_device_list(nullptr, &list); + LOG(VERBOSE) << "found " << device_count << " attached devices"; + + for (ssize_t i = 0; i < device_count; ++i) { + process_device(list[i]); + } + + libusb_free_device_list(list, 1); + + adb_notify_device_scan_complete(); + + std::unique_lock lock(device_poll_mutex); + if (device_poll_cv.wait_for(lock, 500ms, []() { return terminate_device_poll_thread; })) { + return; + } + } +} +#endif + void usb_init() { LOG(DEBUG) << "initializing libusb..."; int rc = libusb_init(nullptr); @@ -457,6 +493,7 @@ void usb_init() { LOG(FATAL) << "failed to initialize libusb: " << libusb_error_name(rc); } +#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102 // Register the hotplug callback. rc = libusb_hotplug_register_callback( nullptr, static_cast(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | @@ -467,6 +504,7 @@ void usb_init() { if (rc != LIBUSB_SUCCESS) { LOG(FATAL) << "failed to register libusb hotplug callback"; } +#endif // Spawn a thread for libusb_handle_events. std::thread([]() { @@ -475,10 +513,28 @@ void usb_init() { libusb_handle_events(nullptr); } }).detach(); + +#if !defined(LIBUSB_API_VERSION) || LIBUSB_API_VERSION < 0x01000102 + std::unique_lock lock(device_poll_mutex); + device_poll_thread = new std::thread(poll_for_devices); +#endif } void usb_cleanup() { +#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102 libusb_hotplug_deregister_callback(nullptr, hotplug_handle); +#else + { + std::unique_lock lock(device_poll_mutex); + terminate_device_poll_thread = true; + + if (!device_poll_thread) { + return; + } + } + device_poll_cv.notify_all(); + device_poll_thread->join(); +#endif } // Dispatch a libusb transfer, unlock |device_lock|, and then wait for the result. Index: head/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h =================================================================== --- head/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h (revision 448521) +++ head/devel/android-tools-adb-devel/files/patch-base_include_android-base_logging.h (revision 448522) @@ -1,11 +1,11 @@ ---- base/include/android-base/logging.h.orig 2017-07-02 22:55:50 UTC +--- base/include/android-base/logging.h.orig 2015-09-29 18:07:07 UTC +++ base/include/android-base/logging.h @@ -321,7 +321,7 @@ struct LogAbortAfterFullExpr { // DCHECKs are debug variants of CHECKs only enabled in debug builds. Generally // CHECK should be used unless profiling identifies a CHECK as being in // performance critical code. -#if defined(NDEBUG) && !defined(__clang_analyzer__) +#if defined(NDEBUG) && !defined(__clang_analyzer__) || !defined(__ANDROID__) static constexpr bool kEnableDChecks = false; #else static constexpr bool kEnableDChecks = true; Index: head/devel/android-tools-fastboot/Makefile =================================================================== --- head/devel/android-tools-fastboot/Makefile (revision 448521) +++ head/devel/android-tools-fastboot/Makefile (revision 448522) @@ -1,94 +1,91 @@ # $FreeBSD$ PORTNAME= android-tools-fastboot DISTVERSIONPREFIX= android- -DISTVERSION?= 7.1.2_r17 +DISTVERSION?= 8.0.0_r4 PORTREVISION?= 0 CATEGORIES= devel sysutils MASTER_SITES= https://anonscm.debian.org/cgit/android-tools/android-tools.git/plain/debian/:manpage DISTFILES= fastboot.1?id=706e754:manpage EXTRACT_ONLY= ${DISTFILES:N*\:manpage:C/:.*//} MAINTAINER= jbeich@FreeBSD.org COMMENT= Android Fastboot protocol CLI tool LICENSE= APACHE20 BSD2CLAUSE PD LICENSE_COMB= multi LICENSE_FILE_PD= ${WRKSRC}/libselinux/NOTICE LIB_DEPENDS= libpcre.so:devel/pcre USE_GITHUB= yes GH_ACCOUNT= android jbeich:extras,libselinux GH_PROJECT= platform_system_core platform_system_extras:extras \ platform_external_libselinux:libselinux +GH_TAGNAME?= android-7.1.2_r17:libselinux GH_SUBDIR= libselinux:libselinux # Emulate GH_COMMIT without causing desync .ifdef DISTVERSIONSUFFIX GH_REVISION= ${DISTVERSIONSUFFIX:S/-g//} # snapshot .else -GH_REVISION= 1346a4012db4 # generated by: make update-revision +GH_REVISION= f6a78079a81a # generated by: make update-revision .endif CONFLICTS_INSTALL?= ${PORTNAME}-devel-* - -.ifndef EXTRA_PATCHES -EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-base_file.cpp -.endif USES= compiler:c++11-lib pkgconfig uidfix BUILD_WRKSRC= ${WRKSRC}/fastboot INSTALL_WRKSRC= ${BUILD_WRKSRC} MAKEFILE= ${.CURDIR}/files/Makefile # XXX ?= when bmake-only MAKE_ENV= BINDIR="${PREFIX}/bin" EXTRADIR="${FILESDIR}" \ FILESDIR="${DOCSDIR}" REVISION="${GH_REVISION}" \ MANDIR="${PREFIX}/man/man" \ LIBPCRE="${LOCALBASE}/lib/libpcre.a" PLIST_FILES= bin/fastboot \ man/man1/fastboot.1.gz PORTDOCS= * SUB_FILES= pkg-message OPTIONS_DEFINE= BASH DOCS OPTIONS_SUB= yes .if make(makesum) # for optional distfiles .MAKEFLAGS: WITH="${OPTIONS_DEFINE}" .endif BASH_GH_ACCOUNT= mbrubeck:bashcomp BASH_GH_PROJECT= android-completion:bashcomp BASH_GH_TAGNAME= c1b0656:bashcomp BASH_PLIST_FILES= etc/bash_completion.d/fastboot BASH_VARS= LICENSE+=MIT DOCS_MAKE_ARGS_OFF= FILES="" FILESDIR="" post-extract: @${CP} ${_DISTDIR}/${DISTFILES:M*\:manpage:C/:.*//} \ ${BUILD_WRKSRC}/${DISTFILES:M*\:manpage:C/\?.*//} # Adjust paths relative to core @(cd ${WRKSRC_extras} && ${COPYTREE_SHARE} . ${WRKSRC}) post-install-BASH-on: ${MKDIR} ${STAGEDIR}${PREFIX}/${BASH_PLIST_FILES:H} ${INSTALL_DATA} ${WRKSRC_bashcomp}/android \ ${STAGEDIR}${PREFIX}/${BASH_PLIST_FILES} update-revision: # https://developer.github.com/v3/repos/commits/#get-a-single-commit # Pretend to be curl(1) for pretty-printed JSON to help parse with sed(1) @${REINPLACE_CMD} -i '' -e "/^GH_REVISION.*$@/s/=.*/= $$(\ ${SETENV} HTTP_USER_AGENT=curl ${FETCH_CMD} -qo- \ https://api.github.com/repos/${GH_ACCOUNT}/${GH_PROJECT}/commits/${GH_TAGNAME} | \ ${SED} -n '/sha/ { s/.*\"\([0-9a-f]\{12\}\).*/\1/p; q; }' \ ) # generated by: make $@/" \ ${.CURDIR}/Makefile .include # XXX Work around !target(makesum) .ifndef DISTVERSIONSUFFIX makesum: update-revision .endif Index: head/devel/android-tools-fastboot/distinfo =================================================================== --- head/devel/android-tools-fastboot/distinfo (revision 448521) +++ head/devel/android-tools-fastboot/distinfo (revision 448522) @@ -1,11 +1,11 @@ TIMESTAMP = 1495068953 SHA256 (fastboot.1?id=706e754) = 2af01b064440952a82f1602691a0fecc030302722a71444946fb70d9c423d283 SIZE (fastboot.1?id=706e754) = 5906 -SHA256 (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = fb8d053d846f439951c651f205c9c914531d8dace86da60474f6675a92576449 -SIZE (android-platform_system_core-android-7.1.2_r17_GH0.tar.gz) = 1596372 -SHA256 (jbeich-platform_system_extras-android-7.1.2_r17_GH0.tar.gz) = ee97ae3df4eecc0d7fc16d3cb6f016ae1b1f81d7e450e678473c9b4618676b42 -SIZE (jbeich-platform_system_extras-android-7.1.2_r17_GH0.tar.gz) = 79621709 +SHA256 (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 3eb686edb1ccaa7312fb195b65c413823a6d60442d519c499c18b2d18c3094a9 +SIZE (android-platform_system_core-android-8.0.0_r4_GH0.tar.gz) = 5115403 +SHA256 (jbeich-platform_system_extras-android-8.0.0_r4_GH0.tar.gz) = 83d4a27f5ffa434688b62d00fcc33edd352bdc523f8b7fcbc3e8d0c1453b1c41 +SIZE (jbeich-platform_system_extras-android-8.0.0_r4_GH0.tar.gz) = 192575526 SHA256 (jbeich-platform_external_libselinux-android-7.1.2_r17_GH0.tar.gz) = 659e43d3e14b4f4fe8955975ad268310bfad0529f408fb33342ed70ae0d456c7 SIZE (jbeich-platform_external_libselinux-android-7.1.2_r17_GH0.tar.gz) = 59763 SHA256 (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = ca3311ba47a5edd56c929ac9aae57c02c2c3f1636519c5f67abb00b6e3ecd75c SIZE (mbrubeck-android-completion-c1b0656_GH0.tar.gz) = 5967 Index: head/devel/android-tools-fastboot/files/Makefile =================================================================== --- head/devel/android-tools-fastboot/files/Makefile (revision 448521) +++ head/devel/android-tools-fastboot/files/Makefile (revision 448522) @@ -1,135 +1,141 @@ # $FreeBSD$ PROG_CXX=fastboot BINDIR?=/usr/bin FILESDIR?=${DOCDIR}/${PROG} -FILES= *.[Tt][Xx][Tt] +FILES= *.md SRCS+= bootimg_utils.cpp SRCS+= engine.cpp SRCS+= fastboot.cpp SRCS+= ../fastboot/fs.cpp SRCS+= protocol.cpp SRCS+= socket.cpp SRCS+= tcp.cpp SRCS+= udp.cpp SRCS+= util.cpp .PATH: ${EXTRADIR} SRCS+= usb_freebsd.cpp -SRCS+= util_freebsd.cpp # required by fastboot .PATH: ${.CURDIR}/../adb SRCS+= diagnose_usb.cpp # required by fastboot, diagnose_usb and libziparchive .PATH: ${.CURDIR}/../base SRCS+= errors_unix.cpp SRCS+= file.cpp +SRCS+= logging.cpp SRCS+= parsenetaddress.cpp SRCS+= stringprintf.cpp SRCS+= strings.cpp # required by fastboot .PATH: ${.CURDIR}/../ext4_utils SRCS+= allocate.c SRCS+= contents.c SRCS+= crc16.c SRCS+= ext4_sb.c SRCS+= ext4_utils.c SRCS+= ext4fixup.c SRCS+= extent.c SRCS+= indirect.c SRCS+= make_ext4fs.c SRCS+= sha1.c SRCS+= wipe.c # required by fastboot .PATH: ${.CURDIR}/../libcutils +SRCS+= android_get_control_file.cpp SRCS+= ../libcutils/sockets.cpp SRCS+= socket_inaddr_any_server_unix.c SRCS+= socket_network_client_unix.c SRCS+= sockets_unix.cpp CPPFLAGS.sockets.cpp+= -o ${.TARGET} # XXX pre-r279980 # required by base and libutils .PATH: ${.CURDIR}/../liblog +SRCS+= config_read.c SRCS+= config_write.c SRCS+= fake_log_device.c SRCS+= fake_writer.c +SRCS+= local_logger.c SRCS+= logger_lock.c SRCS+= logger_name.c SRCS+= logger_write.c -CPPFLAGS.config_write.c+= -DFAKE_LOG_DEVICE=1 +SRCS+= logprint.c +SRCS+= stderr_write.c +SRCS+= test_utils.cpp # required by ext4_utils .PATH: ${.CURDIR}/../libselinux/src SRCS+= callbacks.c SRCS+= check_context.c SRCS+= freecon.c SRCS+= init.c SRCS+= label.c SRCS+= label_android_property.c SRCS+= label_file.c SRCS+= label_support.c CPPFLAGS.label_file.c+= -D_WITH_GETLINE # required by fastboot and ext4_utils .PATH: ${.CURDIR}/../libsparse SRCS+= backed_block.c SRCS+= output_file.c SRCS+= sparse.c SRCS+= sparse_crc32.c SRCS+= sparse_err.c SRCS+= sparse_read.c # required by libziparchive .PATH: ${.CURDIR}/../libutils SRCS+= FileMap.cpp # required by fastboot .PATH: ${.CURDIR}/../libziparchive SRCS+= zip_archive.cc REVISION?= $$(${GIT} rev-parse --short=12 HEAD 2>/dev/null || echo unknown) CPPFLAGS+= -DFASTBOOT_REVISION="\"${REVISION}-android\"" CPPFLAGS+= -Doff64_t=off_t CPPFLAGS+= -Dftruncate64=ftruncate CPPFLAGS+= -Dlseek64=lseek CPPFLAGS+= -Dmmap64=mmap CPPFLAGS+= -Dpread64=pread +CPPFLAGS+= -DFAKE_LOG_DEVICE=1 CPPFLAGS+= -I${.CURDIR} CPPFLAGS+= -I${.CURDIR}/../include CPPFLAGS+= -I${.CURDIR}/../adb CPPFLAGS+= -I${.CURDIR}/../mkbootimg CPPFLAGS+= -I${.CURDIR}/../base/include -CPPFLAGS+= -I${.CURDIR}/../ext4_utils +CPPFLAGS+= -I${.CURDIR}/../ext4_utils/include CPPFLAGS+= -I${.CURDIR}/../f2fs_utils CPPFLAGS+= -I${.CURDIR}/../libselinux/include CPPFLAGS+= -I${.CURDIR}/../libsparse/include CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}} CPPFLAGS+= $$(${PKG_CONFIG} libpcre --cflags 2>/dev/null) CPPFLAGS+= $$(${PKG_CONFIG} libusb-1.0 --cflags 2>/dev/null) CXXFLAGS+= -D__STDC_LIMIT_MACROS # DragonFly CXXFLAGS+= -std=gnu++11 .ifndef COMPILE.c CFLAGS+= ${CPPFLAGS} CXXFLAGS+= ${CPPFLAGS} .endif LDADD+= $$(${PKG_CONFIG} libpcre --libs 2>/dev/null || echo -lpcre) LDADD+= $$(${PKG_CONFIG} libusb-1.0 --libs 2>/dev/null || echo -lusb) -LDADD+= -lz -DPADD+= ${LIBPCRE} ${LIBUSB} ${LIBZ} +LDADD+= -lz \-lpthread +DPADD+= ${LIBPCRE} ${LIBPTHREAD} ${LIBUSB} ${LIBZ} GIT?= git PKG_CONFIG?= pkg-config beforeinstall: ${INSTALL} -d ${DESTDIR}${FILESDIR} .include Index: head/devel/android-tools-fastboot/files/patch-base_file.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_file.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-base_file.cpp (revision 448522) @@ -0,0 +1,47 @@ +--- base/file.cpp.orig 2017-06-20 10:50:27 UTC ++++ base/file.cpp +@@ -19,6 +19,10 @@ + #include + #include + #include ++#include // PATH_MAX ++#include // BUFSIZ ++#include // realpath ++#include // strerror + #include + #include + #include +@@ -36,6 +39,9 @@ + #if defined(__APPLE__) + #include + #endif ++#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) ++#include ++#endif + #if defined(_WIN32) + #include + #define O_CLOEXEC O_NOINHERIT +@@ -251,6 +258,23 @@ std::string GetExecutablePath() { + if (result == 0 || result == sizeof(path) - 1) return ""; + path[PATH_MAX - 1] = 0; + return path; ++#elif defined(KERN_PROC_PATHNAME) ++ char path[PATH_MAX + 1]; ++ size_t path_len = sizeof(path); ++ int mib[] = { ++ CTL_KERN, ++#if defined(__NetBSD__) ++ KERN_PROC_ARGS, ++ -1, ++ KERN_PROC_PATHNAME, ++#else ++ KERN_PROC, ++ KERN_PROC_PATHNAME, ++ -1, ++#endif ++ }; ++ int rc = sysctl(mib, arraysize(mib), path, &path_len, NULL, 0); ++ return rc ? "" : path; + #else + #error unknown OS + #endif Property changes on: head/devel/android-tools-fastboot/files/patch-base_file.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-fastboot/files/patch-base_logging.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_logging.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-base_logging.cpp (revision 448522) @@ -0,0 +1,50 @@ +--- base/logging.cpp.orig 2016-08-08 21:10:17 UTC ++++ base/logging.cpp +@@ -25,7 +25,7 @@ + #include + + // For getprogname(3) or program_invocation_short_name. +-#if defined(__ANDROID__) || defined(__APPLE__) ++#if !defined(_WIN32) && !defined(__GLIBC__) + #include + #elif defined(__GLIBC__) + #include +@@ -35,6 +35,8 @@ + #include + #endif + ++#include // strrchr ++#include // fprintf + #include + #include + #include +@@ -71,6 +72,14 @@ + #include + #elif defined(_WIN32) + #include ++#elif defined(__DragonFly__) ++#include ++#elif defined(__FreeBSD__) ++#include ++#elif defined(__NetBSD__) ++#include ++#else ++#include + #endif + + #if defined(_WIN32) +@@ -88,6 +97,14 @@ static thread_id GetThreadId() { + return syscall(__NR_gettid); + #elif defined(_WIN32) + return GetCurrentThreadId(); ++#elif defined(__DragonFly__) ++ return lwp_gettid(); ++#elif defined(__NetBSD__) ++ return _lwp_self(); ++#elif defined(__FreeBSD__) ++ return pthread_getthreadid_np(); ++#else ++ return (intptr_t) pthread_self(); + #endif + } + Property changes on: head/devel/android-tools-fastboot/files/patch-base_logging.cpp ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/devel/android-tools-fastboot-devel/files/patch-base_file.cpp =================================================================== --- head/devel/android-tools-fastboot-devel/files/patch-base_file.cpp (revision 448521) +++ head/devel/android-tools-fastboot-devel/files/patch-base_file.cpp (nonexistent) @@ -1,47 +0,0 @@ ---- base/file.cpp.orig 2017-06-20 10:50:27 UTC -+++ base/file.cpp -@@ -19,6 +19,10 @@ - #include - #include - #include -+#include // PATH_MAX -+#include // BUFSIZ -+#include // realpath -+#include // strerror - #include - #include - #include -@@ -36,6 +39,9 @@ - #if defined(__APPLE__) - #include - #endif -+#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) -+#include -+#endif - #if defined(_WIN32) - #include - #define O_CLOEXEC O_NOINHERIT -@@ -251,6 +258,23 @@ std::string GetExecutablePath() { - if (result == 0 || result == sizeof(path) - 1) return ""; - path[PATH_MAX - 1] = 0; - return path; -+#elif defined(KERN_PROC_PATHNAME) -+ char path[PATH_MAX + 1]; -+ size_t path_len = sizeof(path); -+ int mib[] = { -+ CTL_KERN, -+#if defined(__NetBSD__) -+ KERN_PROC_ARGS, -+ -1, -+ KERN_PROC_PATHNAME, -+#else -+ KERN_PROC, -+ KERN_PROC_PATHNAME, -+ -1, -+#endif -+ }; -+ int rc = sysctl(mib, arraysize(mib), path, &path_len, NULL, 0); -+ return rc ? "" : path; - #else - #error unknown OS - #endif Property changes on: head/devel/android-tools-fastboot-devel/files/patch-base_file.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/devel/android-tools-fastboot-devel/files/patch-base_logging.cpp =================================================================== --- head/devel/android-tools-fastboot-devel/files/patch-base_logging.cpp (revision 448521) +++ head/devel/android-tools-fastboot-devel/files/patch-base_logging.cpp (nonexistent) @@ -1,50 +0,0 @@ ---- base/logging.cpp.orig 2016-08-08 21:10:17 UTC -+++ base/logging.cpp -@@ -25,7 +25,7 @@ - #include - - // For getprogname(3) or program_invocation_short_name. --#if defined(__ANDROID__) || defined(__APPLE__) -+#if !defined(_WIN32) && !defined(__GLIBC__) - #include - #elif defined(__GLIBC__) - #include -@@ -35,6 +35,8 @@ - #include - #endif - -+#include // strrchr -+#include // fprintf - #include - #include - #include -@@ -71,6 +72,14 @@ - #include - #elif defined(_WIN32) - #include -+#elif defined(__DragonFly__) -+#include -+#elif defined(__FreeBSD__) -+#include -+#elif defined(__NetBSD__) -+#include -+#else -+#include - #endif - - #if defined(_WIN32) -@@ -88,6 +97,14 @@ static thread_id GetThreadId() { - return syscall(__NR_gettid); - #elif defined(_WIN32) - return GetCurrentThreadId(); -+#elif defined(__DragonFly__) -+ return lwp_gettid(); -+#elif defined(__NetBSD__) -+ return _lwp_self(); -+#elif defined(__FreeBSD__) -+ return pthread_getthreadid_np(); -+#else -+ return (intptr_t) pthread_self(); - #endif - } - Property changes on: head/devel/android-tools-fastboot-devel/files/patch-base_logging.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property