Index: head/devel/android-tools-fastboot/Makefile =================================================================== --- head/devel/android-tools-fastboot/Makefile (revision 511878) +++ head/devel/android-tools-fastboot/Makefile (revision 511879) @@ -1,89 +1,65 @@ # $FreeBSD$ PORTNAME= android-tools-fastboot -DISTVERSIONPREFIX= android- -DISTVERSION?= 9.0.0_r3 -PORTREVISION?= 3 +DISTVERSIONPREFIX= platform-tools- +DISTVERSION?= 29.0.3 +PORTREVISION?= 0 CATEGORIES= devel sysutils MASTER_SITES= https://salsa.debian.org/android-tools-team/android-tools/raw/706e754/debian/:manpage DISTFILES= fastboot.1:manpage EXTRACT_ONLY= ${DISTFILES:N*\:manpage:C/:.*//} MAINTAINER= jbeich@FreeBSD.org COMMENT= Android Fastboot protocol CLI tool LICENSE= APACHE20 BSD2CLAUSE LICENSE_COMB= multi USE_GITHUB= yes -GH_ACCOUNT= aosp-mirror jbeich:extras -GH_PROJECT= platform_system_core platform_system_extras:extras +GH_ACCOUNT= aosp-mirror jbeich:extras,mkbootimg +GH_PROJECT= platform_system_core platform_system_extras:extras \ + platform_system_tools_mkbootimg:mkbootimg CONFLICTS_INSTALL?= ${PORTNAME}-devel-* -USES= compiler:c++11-lib pkgconfig uidfix +USES= compiler:c++17-lang pkgconfig ssl uidfix BUILD_WRKSRC= ${WRKSRC}/fastboot INSTALL_WRKSRC= ${BUILD_WRKSRC} -CPPFLAGS+= -D_GLIBCXX_USE_C99 # XXX ports/193528 MAKEFILE?= ${.CURDIR}/files/Makefile MAKE_ENV= BINDIR="${PREFIX}/bin" EXTRADIR="${FILESDIR}" \ FILESDIR="${DOCSDIR}" \ - VERSION="${SDK_REVISION}-0 ${GH_REVISION}-android" \ + VERSION="${DISTVERSION}${DISTVERSIONSUFFIX}" \ MANDIR="${PREFIX}/man/man" PLIST_FILES= bin/fastboot \ man/man1/fastboot.1.gz PORTDOCS= * SUB_FILES= pkg-message -# Generated by "make update-revision" for "fastboot --version" -SDK_REVISION?= 28.0.0 -GH_REVISION= ${DISTVERSIONSUFFIX:U0fac9018f238:S/-g//} - 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} # Adjust paths relative to core @(cd ${WRKSRC_extras} && ${COPYTREE_SHARE} . ${WRKSRC}) + @(cd ${WRKSRC_mkbootimg} && ${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: - @${REINPLACE_CMD} -i '' -e "/^SDK_REVISION?=/s/=.*/= $$(\ - ${FETCH_CMD} -qo- \ - https://github.com/${GH_ACCOUNT}/platform_build/raw/${GH_TAGNAME}/core/version_defaults.mk | \ - ${SED} -n 's/^[[:space:]]*PLATFORM_SDK_VERSION := //p' \ - ).0.0/" \ - ${.CURDIR}/Makefile -# 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/:U[^}:]*/:U$$(\ - ${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; }' \ - )/" \ - ${.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 511878) +++ head/devel/android-tools-fastboot/distinfo (revision 511879) @@ -1,9 +1,11 @@ -TIMESTAMP = 1529542722 +TIMESTAMP = 1565662258 SHA256 (fastboot.1) = 2af01b064440952a82f1602691a0fecc030302722a71444946fb70d9c423d283 SIZE (fastboot.1) = 5906 -SHA256 (aosp-mirror-platform_system_core-android-9.0.0_r3_GH0.tar.gz) = b9de23465b304432aa2b585aa66c6bf4841b177f2139b75ca5adc5d917e0ecd6 -SIZE (aosp-mirror-platform_system_core-android-9.0.0_r3_GH0.tar.gz) = 27484684 -SHA256 (jbeich-platform_system_extras-android-9.0.0_r3_GH0.tar.gz) = d82c4576bed24bfe701bb8c781714fa70365c03aed93cf4777407215de4d672d -SIZE (jbeich-platform_system_extras-android-9.0.0_r3_GH0.tar.gz) = 211722695 +SHA256 (aosp-mirror-platform_system_core-platform-tools-29.0.3_GH0.tar.gz) = f2938ab5d206f5d4e075afba1a3e32fc26656bb439b6208200bef0ea5bae77eb +SIZE (aosp-mirror-platform_system_core-platform-tools-29.0.3_GH0.tar.gz) = 61252755 +SHA256 (jbeich-platform_system_extras-platform-tools-29.0.3_GH0.tar.gz) = 342433c834f260b5d55c5dc0b98ef27aea18feb50e1fff5e09fdb846c0f75a51 +SIZE (jbeich-platform_system_extras-platform-tools-29.0.3_GH0.tar.gz) = 210790583 +SHA256 (jbeich-platform_system_tools_mkbootimg-platform-tools-29.0.3_GH0.tar.gz) = 9c2f9ab0006969613a48b5a529674c0d79784b830479c28f802aa2a1916cdf53 +SIZE (jbeich-platform_system_tools_mkbootimg-platform-tools-29.0.3_GH0.tar.gz) = 6620 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/patch-libsparse_sparse__read.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-libsparse_sparse__read.cpp (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-libsparse_sparse__read.cpp (nonexistent) @@ -1,10 +0,0 @@ ---- libsparse/sparse_read.cpp.orig 2017-06-20 10:50:27 UTC -+++ libsparse/sparse_read.cpp -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include // memset - #include - - #include Property changes on: head/devel/android-tools-fastboot/files/patch-libsparse_sparse__read.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/files/patch-liblog_logger__write.c =================================================================== --- head/devel/android-tools-fastboot/files/patch-liblog_logger__write.c (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-liblog_logger__write.c (nonexistent) @@ -1,16 +0,0 @@ ---- liblog/logger_write.c.orig 2016-04-16 00:01:39 UTC -+++ liblog/logger_write.c -@@ -15,12 +15,12 @@ - */ - - #include --#include - #include - #include - #include - - #ifdef __BIONIC__ -+#include - #include - #endif - Property changes on: head/devel/android-tools-fastboot/files/patch-liblog_logger__write.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-fastboot/files/patch-adb_sysdeps.h =================================================================== --- head/devel/android-tools-fastboot/files/patch-adb_sysdeps.h (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-adb_sysdeps.h (nonexistent) @@ -1,43 +0,0 @@ ---- adb/sysdeps.h.orig 2015-09-05 00:01:27 UTC -+++ adb/sysdeps.h -@@ -61,11 +61,13 @@ - #endif - #endif - --#ifdef _WIN32 -- -+#if !defined(__clang__) || __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 7) - // Clang-only nullability specifiers - #define _Nonnull - #define _Nullable -+#endif -+ -+#ifdef _WIN32 - - #include - #include -@@ -401,6 +401,11 @@ typedef std::unique_ptr - -+#if defined(__Bitrig__) || defined(__DragonFly__) || \ -+ defined(__FreeBSD__) || defined(__OpenBSD__) -+#include -+#endif -+ - #define OS_PATH_SEPARATORS "/" - #define OS_PATH_SEPARATOR '/' - #define OS_PATH_SEPARATOR_STR "/" -@@ -627,6 +632,12 @@ static __inline__ bool adb_thread_create - static __inline__ int adb_thread_setname(const std::string& name) { - #ifdef __APPLE__ - return pthread_setname_np(name.c_str()); -+#elif defined(__Bitrig__) || defined(__DragonFly__) || \ -+ defined(__FreeBSD__) || defined(__OpenBSD__) -+ pthread_set_name_np(pthread_self(), name.c_str()); -+ return 0; -+#elif defined(__NetBSD__) -+ return pthread_setname_np(pthread_self(), "%s", (void*)name.c_str()); - #else - const char *s = name.c_str(); - Property changes on: head/devel/android-tools-fastboot/files/patch-adb_sysdeps.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-fastboot/files/patch-base_logging.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_logging.cpp (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-base_logging.cpp (nonexistent) @@ -1,54 +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,16 @@ - #include - #elif defined(_WIN32) - #include -+#elif defined(__DragonFly__) || defined(__FreeBSD__) -+#include -+#elif defined(__NetBSD__) -+#include -+#elif defined(__OpenBSD__) -+#include -+#elif defined(__sun) -+#include -+#else // fallback -+#include - #endif - - #if defined(_WIN32) -@@ -88,6 +97,16 @@ static thread_id GetThreadId() { - return syscall(__NR_gettid); - #elif defined(_WIN32) - return GetCurrentThreadId(); -+#elif defined(__DragonFly__) || defined(__FreeBSD__) -+ return pthread_getthreadid_np(); -+#elif defined(__NetBSD__) -+ return _lwp_self(); -+#elif defined(__OpenBSD__) -+ return getthrid(); -+#elif defined(__sun) -+ return thr_self(); -+#else // fallback -+ return (intptr_t) pthread_self(); - #endif - } - Property changes on: head/devel/android-tools-fastboot/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 Index: head/devel/android-tools-fastboot/files/patch-libziparchive_zip__archive.cc =================================================================== --- head/devel/android-tools-fastboot/files/patch-libziparchive_zip__archive.cc (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-libziparchive_zip__archive.cc (nonexistent) @@ -1,29 +0,0 @@ ---- libziparchive/zip_archive.cc.orig 2018-06-21 00:58:42 UTC -+++ libziparchive/zip_archive.cc -@@ -47,6 +47,17 @@ - #include "zip_archive_common.h" - #include "zip_archive_private.h" - -+#if !defined(_WIN32) -+#if __cplusplus >= 201703 || (defined(_LIBCPP_VERSION) && __has_include()) -+#include -+#elif __cplusplus >= 201402 -+#include -+namespace std { -+using std::experimental::string_view; -+} -+#endif // __cplusplus >= 201703 -+#endif // !defined(_WIN32) -+ - using android::base::get_unaligned; - - // Used to turn on crc checks - verify that the content CRC matches the values -@@ -100,7 +111,7 @@ static uint32_t RoundUpPower2(uint32_t val) { - } - - static uint32_t ComputeHash(const ZipString& name) { --#if !defined(_WIN32) -+#if __cplusplus >= 201402 && !defined(_WIN32) - return std::hash{}( - std::string_view(reinterpret_cast(name.name), name.name_length)); - #else Property changes on: head/devel/android-tools-fastboot/files/patch-libziparchive_zip__archive.cc ___________________________________________________________________ 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/files/patch-base_errors__unix.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_errors__unix.cpp (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-base_errors__unix.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- base/errors_unix.cpp.orig 2016-02-20 02:39:51 UTC -+++ base/errors_unix.cpp -@@ -16,7 +16,7 @@ - - #include "android-base/errors.h" - --#include -+#include - - namespace android { - namespace base { Property changes on: head/devel/android-tools-fastboot/files/patch-base_errors__unix.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/files/patch-base_parsenetaddress.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_parsenetaddress.cpp (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-base_parsenetaddress.cpp (nonexistent) @@ -1,10 +0,0 @@ ---- base/parsenetaddress.cpp.orig 2016-02-20 02:39:51 UTC -+++ base/parsenetaddress.cpp -@@ -16,6 +16,7 @@ - - #include "android-base/parsenetaddress.h" - -+#include // sscanf - #include - - #include "android-base/stringprintf.h" Property changes on: head/devel/android-tools-fastboot/files/patch-base_parsenetaddress.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/files/Makefile =================================================================== --- head/devel/android-tools-fastboot/files/Makefile (revision 511878) +++ head/devel/android-tools-fastboot/files/Makefile (revision 511879) @@ -1,110 +1,122 @@ # $FreeBSD$ PROG_CXX=fastboot BINDIR?=/usr/bin FILESDIR?=${DOCDIR}/${PROG} -VERSION?=0.0.0-0 FILES= README.md SRCS+= bootimg_utils.cpp -SRCS+= engine.cpp SRCS+= fastboot.cpp +SRCS+= fastboot_driver.cpp SRCS+= ../fastboot/fs.cpp -SRCS+= protocol.cpp +SRCS+= main.cpp SRCS+= socket.cpp SRCS+= tcp.cpp SRCS+= udp.cpp SRCS+= util.cpp .PATH: ${EXTRADIR} SRCS+= usb_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+= mapped_file.cpp SRCS+= parsenetaddress.cpp SRCS+= stringprintf.cpp SRCS+= strings.cpp +SRCS+= threads.cpp # required by fastboot +.PATH: ${.CURDIR}/../diagnose_usb +SRCS+= diagnose_usb.cpp + +# required by fs_mgr/liblp +.PATH: ${.CURDIR}/../ext4_utils +SRCS+= ext4_sb.cpp +SRCS+= ext4_utils.cpp + +# required by fastboot +.PATH: ${.CURDIR}/../fs_mgr/liblp +SRCS+= images.cpp +SRCS+= partition_opener.cpp +SRCS+= reader.cpp +SRCS+= utility.cpp +SRCS+= writer.cpp + +# required by fastboot .PATH: ${.CURDIR}/../libcutils SRCS+= android_get_control_file.cpp SRCS+= ../libcutils/sockets.cpp SRCS+= socket_inaddr_any_server_unix.cpp SRCS+= socket_network_client_unix.cpp SRCS+= sockets_unix.cpp # DragonFly, NetBSD, OpenBSD CPPFLAGS.sockets.cpp+= -o ${.TARGET} # 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 -SRCS+= logprint.c -SRCS+= stderr_write.c -SRCS+= test_utils.cpp +SRCS+= config_read.cpp +SRCS+= config_write.cpp +SRCS+= fake_log_device.cpp +SRCS+= fake_writer.cpp +SRCS+= logger_lock.cpp +SRCS+= logger_name.cpp +SRCS+= logger_write.cpp +SRCS+= logprint.cpp +SRCS+= stderr_write.cpp # required by fastboot .PATH: ${.CURDIR}/../libsparse -SRCS+= backed_block.c -SRCS+= output_file.c -SRCS+= sparse.c -SRCS+= sparse_crc32.c -SRCS+= sparse_err.c +SRCS+= backed_block.cpp +SRCS+= output_file.cpp +SRCS+= sparse.cpp +SRCS+= sparse_crc32.cpp +SRCS+= sparse_err.cpp SRCS+= sparse_read.cpp -# required by libziparchive -.PATH: ${.CURDIR}/../libutils -SRCS+= FileMap.cpp - # required by fastboot .PATH: ${.CURDIR}/../libziparchive SRCS+= zip_archive.cc -CPPFLAGS+= -DFASTBOOT_VERSION="\"${VERSION}\"" +CPPFLAGS+= -DPLATFORM_TOOLS_VERSION="\"${VERSION:U0.0.0}\"" 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/include/bootimg +CPPFLAGS+= -I${.CURDIR}/../include/bootimg CPPFLAGS+= -I${.CURDIR}/../base/include +CPPFLAGS+= -I${.CURDIR}/../diagnose_usb/include +CPPFLAGS+= -I${.CURDIR}/../ext4_utils/include +CPPFLAGS+= -I${.CURDIR}/../fs_mgr/liblp/include CPPFLAGS+= -I${.CURDIR}/../libsparse/include CPPFLAGS+= -I${.CURDIR}/../libziparchive/include CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}} +CPPFLAGS+= $$(${PKG_CONFIG} libcrypto --cflags 2>/dev/null) CPPFLAGS+= $$(${PKG_CONFIG} libusb-1.0 --cflags 2>/dev/null) CXXFLAGS+= -D__STDC_LIMIT_MACROS # DragonFly -CXXFLAGS+= -std=gnu++11 +CXXFLAGS+= -std=gnu++17 .ifndef COMPILE.c CFLAGS+= ${CPPFLAGS} CXXFLAGS+= ${CPPFLAGS} .endif +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+= ${LIBPTHREAD} ${LIBUSB} ${LIBZ} 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 (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-base_file.cpp (revision 511879) @@ -1,47 +1,44 @@ ---- base/file.cpp.orig 2017-06-20 10:50:27 UTC +--- base/file.cpp.orig 2019-07-17 19:54:09 UTC +++ base/file.cpp -@@ -19,6 +19,10 @@ - #include +@@ -20,6 +20,7 @@ #include + #include #include -+#include // PATH_MAX -+#include // BUFSIZ -+#include // realpath -+#include // strerror - #include - #include - #include -@@ -36,6 +39,9 @@ ++#include // PATH_MAX for GCC + #include + #include + #include +@@ -35,6 +36,9 @@ #if defined(__APPLE__) #include #endif +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) +#include +#endif #if defined(_WIN32) + #include #include - #define O_CLOEXEC O_NOINHERIT -@@ -251,6 +258,23 @@ std::string GetExecutablePath() { +@@ -421,6 +425,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 Index: head/devel/android-tools-fastboot/files/patch-base_include_android-base_logging.h =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_include_android-base_logging.h (revision 511878) +++ head/devel/android-tools-fastboot/files/patch-base_include_android-base_logging.h (revision 511879) @@ -1,11 +1,22 @@ ---- base/include/android-base/logging.h.orig 2015-09-29 18:07:07 UTC +--- base/include/android-base/logging.h.orig 2019-07-17 19:54:09 UTC +++ base/include/android-base/logging.h -@@ -25,6 +25,8 @@ - #endif - #endif - -+#include -+ - #include - #include - #include +@@ -350,7 +350,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; +@@ -486,8 +486,9 @@ namespace std { // NOLINT(cert-dcl58-cpp) + #pragma clang diagnostic ignored "-Wgcc-compat" + #define OSTREAM_STRING_POINTER_USAGE_WARNING \ + __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) ++OSTREAM_STRING_POINTER_USAGE_WARNING // GCC + inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) +- OSTREAM_STRING_POINTER_USAGE_WARNING { ++{ + return stream << static_cast(string_pointer); + } + #pragma clang diagnostic pop Index: head/devel/android-tools-fastboot/files/patch-base_threads.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-base_threads.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-base_threads.cpp (revision 511879) @@ -0,0 +1,36 @@ +--- base/threads.cpp.orig 2019-07-17 19:54:09 UTC ++++ base/threads.cpp +@@ -25,6 +25,16 @@ + #include + #elif defined(_WIN32) + #include ++#elif defined(__DragonFly__) || defined(__FreeBSD__) ++#include ++#elif defined(__NetBSD__) ++#include ++#elif defined(__OpenBSD__) ++#include ++#elif defined(__sun) ++#include ++#else // fallback ++#include + #endif + + namespace android { +@@ -41,6 +51,16 @@ uint64_t GetThreadId() { + return syscall(__NR_gettid); + #elif defined(_WIN32) + return GetCurrentThreadId(); ++#elif defined(__DragonFly__) || defined(__FreeBSD__) ++ return pthread_getthreadid_np(); ++#elif defined(__NetBSD__) ++ return _lwp_self(); ++#elif defined(__OpenBSD__) ++ return getthrid(); ++#elif defined(__sun) ++ return thr_self(); ++#else // fallback ++ return (intptr_t) pthread_self(); + #endif + } + Property changes on: head/devel/android-tools-fastboot/files/patch-base_threads.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-ext4__utils_ext4__utils.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-ext4__utils_ext4__utils.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-ext4__utils_ext4__utils.cpp (revision 511879) @@ -0,0 +1,47 @@ +--- ext4_utils/ext4_utils.cpp.orig 2019-08-13 02:10:50 UTC ++++ ext4_utils/ext4_utils.cpp +@@ -32,8 +32,16 @@ + + #if defined(__linux__) + #include +-#elif defined(__APPLE__) && defined(__MACH__) ++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ ++ || (defined(__APPLE__) && defined(__MACH__)) + #include ++#elif defined(__sun) ++#include ++#elif defined(__Bitrig__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#include ++#include ++#elif defined(__DragonFly__) ++#include + #endif + + int force = 0; +@@ -206,10 +214,24 @@ u64 get_block_device_size(int fd) + u64 size = 0; + int ret; + +-#if defined(__linux__) ++#if defined(BLKGETSIZE64) + ret = ioctl(fd, BLKGETSIZE64, &size); +-#elif defined(__APPLE__) && defined(__MACH__) ++#elif defined(DKIOCGETBLOCKCOUNT) + ret = ioctl(fd, DKIOCGETBLOCKCOUNT, &size); ++#elif defined(DIOCGMEDIASIZE) ++ ret = ioctl(fd, DIOCGMEDIASIZE, &size); ++#elif defined(DKIOCGMEDIAINFO) ++ struct dk_minfo minfo; ++ ret = ioctl(fd, DKIOCGMEDIAINFO, &minfo); ++ size = minfo.dki_lbsize * minfo.dki_capacity; ++#elif defined(DIOCGDINFO) ++ struct disklabel dl; ++ ret = ioctl(fd, DIOCGDINFO, &dl); ++ size = dl.d_secsize * dl.d_nsectors * dl.d_ntracks * dl.d_ncylinders; ++#elif defined(DIOCGPART) ++ struct partinfo pi; ++ ret = ioctl(fd, DIOCGPART, &pi); ++ size = pi.media_size; + #else + close(fd); + return 0; Property changes on: head/devel/android-tools-fastboot/files/patch-ext4__utils_ext4__utils.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-fastboot_fastboot.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-fastboot_fastboot.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-fastboot_fastboot.cpp (revision 511879) @@ -0,0 +1,24 @@ +--- fastboot/fastboot.cpp.orig 2019-08-13 02:10:58 UTC ++++ fastboot/fastboot.cpp +@@ -58,9 +58,20 @@ + #include + #include + #include ++#ifdef PLATFORM_TOOLS_VERSION ++#include ++namespace android { namespace build { ++std::string GetBuildNumber() { ++ struct utsname uts; ++ if (uname(&uts) == -1) ++ return "unknown"; ++ return uts.sysname; ++}}} ++#else + #include +-#include + #include ++#endif ++#include + #include + #include + Property changes on: head/devel/android-tools-fastboot/files/patch-fastboot_fastboot.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-liblog_fake__writer.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-liblog_fake__writer.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-liblog_fake__writer.cpp (revision 511879) @@ -0,0 +1,12 @@ +--- liblog/fake_writer.cpp.orig 2019-07-17 19:54:09 UTC ++++ liblog/fake_writer.cpp +@@ -33,8 +33,8 @@ static int logFds[(int)LOG_ID_MAX] = {-1, -1, -1, -1, + + struct android_log_transport_write fakeLoggerWrite = { + .node = {&fakeLoggerWrite.node, &fakeLoggerWrite.node}, +- .context.priv = &logFds, + .name = "fake", ++ .context = { .priv = &logFds }, // GCC + .available = NULL, + .open = fakeOpen, + .close = fakeClose, Property changes on: head/devel/android-tools-fastboot/files/patch-liblog_fake__writer.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-liblog_logger.h =================================================================== --- head/devel/android-tools-fastboot/files/patch-liblog_logger.h (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-liblog_logger.h (revision 511879) @@ -0,0 +1,16 @@ +--- liblog/logger.h.orig 2019-08-13 02:10:58 UTC ++++ liblog/logger.h +@@ -16,7 +16,13 @@ + + #pragma once + ++#ifdef __cplusplus ++#include ++using std::atomic_int; ++using std::atomic_uintptr_t; ++#else + #include ++#endif + + #include + #include Property changes on: head/devel/android-tools-fastboot/files/patch-liblog_logger.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-fastboot/files/patch-liblog_logger__write.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-liblog_logger__write.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-liblog_logger__write.cpp (revision 511879) @@ -0,0 +1,17 @@ +--- liblog/logger_write.cpp.orig 2019-07-17 19:54:09 UTC ++++ liblog/logger_write.cpp +@@ -15,12 +15,12 @@ + */ + + #include +-#include + #include + #include + #include + +-#ifdef __BIONIC__ ++#if defined(__ANDROID__) ++#include + #include + #endif + Property changes on: head/devel/android-tools-fastboot/files/patch-liblog_logger__write.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-liblog_stderr__write.cpp =================================================================== --- head/devel/android-tools-fastboot/files/patch-liblog_stderr__write.cpp (nonexistent) +++ head/devel/android-tools-fastboot/files/patch-liblog_stderr__write.cpp (revision 511879) @@ -0,0 +1,12 @@ +--- liblog/stderr_write.cpp.orig 2019-08-13 02:10:58 UTC ++++ liblog/stderr_write.cpp +@@ -55,8 +55,8 @@ struct stderrContext { + + struct android_log_transport_write stderrLoggerWrite = { + .node = {&stderrLoggerWrite.node, &stderrLoggerWrite.node}, +- .context.priv = NULL, + .name = "stderr", ++ .context = { .priv = NULL }, // GCC + .available = stderrAvailable, + .open = stderrOpen, + .close = stderrClose, Property changes on: head/devel/android-tools-fastboot/files/patch-liblog_stderr__write.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/usb_freebsd.cpp =================================================================== --- head/devel/android-tools-fastboot/files/usb_freebsd.cpp (revision 511878) +++ head/devel/android-tools-fastboot/files/usb_freebsd.cpp (revision 511879) @@ -1,208 +1,223 @@ /* * Copyright (C) 2011 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include "usb.h" struct usb_handle { libusb_device_handle *handle; libusb_device *dev; unsigned char ep_in; unsigned char ep_out; unsigned char iface; }; -class LibusbUsbTransport : public Transport { +class LibusbUsbTransport : public UsbTransport { public: - explicit LibusbUsbTransport(std::unique_ptr handle): - h(std::move(handle)) {} - ~LibusbUsbTransport() override = default; + explicit LibusbUsbTransport(std::unique_ptr handle, uint32_t ms_timeout): + h(std::move(handle)), ms_timeout_(ms_timeout) {} + ~LibusbUsbTransport() override; ssize_t Read(void *_data, size_t len) override; ssize_t Write(const void *_data, size_t len) override; int Close() override; + int Reset() override; private: std::unique_ptr h; + const uint32_t ms_timeout_; DISALLOW_COPY_AND_ASSIGN(LibusbUsbTransport); }; static int probe(std::unique_ptr &h, ifc_match_func callback) { usb_ifc_info info; libusb_device_descriptor ddesc; libusb_config_descriptor *pcfg; int i, j; if (libusb_open(h->dev, &h->handle) < 0) return (-1); if (libusb_get_device_descriptor(h->dev, &ddesc) < 0) { libusb_close(h->handle); return (-1); } memset(&info, 0, sizeof(info)); info.dev_vendor = ddesc.idVendor; info.dev_product = ddesc.idProduct; info.dev_class = ddesc.bDeviceClass; info.dev_subclass = ddesc.bDeviceSubClass; info.dev_protocol = ddesc.bDeviceProtocol; info.writable = 1; snprintf(info.device_path, sizeof(info.device_path), "usb:%d:%d", libusb_get_bus_number(h->dev), libusb_get_device_address(h->dev)); if (ddesc.iSerialNumber != 0) { libusb_get_string_descriptor_ascii(h->handle, ddesc.iSerialNumber, (unsigned char *)info.serial_number, sizeof(info.serial_number)); } if (libusb_get_active_config_descriptor(h->dev, &pcfg)) { libusb_close(h->handle); return (-1); } for (i = 0; i < pcfg->bNumInterfaces; i++) { h->ep_in = 0; h->ep_out = 0; h->iface = i; for (j = 0; j < pcfg->interface[i].altsetting[0].bNumEndpoints; j++) { unsigned char temp = pcfg->interface[i].altsetting[0]. endpoint[j].bEndpointAddress; unsigned char type = pcfg->interface[i].altsetting[0]. endpoint[j].bmAttributes & 0x03; /* check for BULK endpoint */ if ((type & 0x03) == 0x02) { /* check for IN endpoint */ if (temp & 0x80) h->ep_in = temp; else h->ep_out = temp; } } info.ifc_class = pcfg->interface[i].altsetting[0].bInterfaceClass; info.ifc_subclass = pcfg->interface[i].altsetting[0].bInterfaceSubClass; info.ifc_protocol = pcfg->interface[i].altsetting[0].bInterfaceProtocol; info.has_bulk_in = (h->ep_in != 0); info.has_bulk_out = (h->ep_out != 0); if (libusb_claim_interface(h->handle, h->iface) < 0) continue; if (callback(&info) == 0) { libusb_free_config_descriptor(pcfg); return (0); } libusb_release_interface(h->handle, h->iface); } libusb_free_config_descriptor(pcfg); libusb_close(h->handle); return (-1); } static std::unique_ptr enumerate(ifc_match_func callback) { static libusb_context *ctx = NULL; std::unique_ptr h; libusb_device **ppdev; ssize_t ndev; ssize_t x; if (ctx == NULL) libusb_init(&ctx); ndev = libusb_get_device_list(ctx, &ppdev); for (x = 0; x < ndev; x++) { h.reset(new usb_handle); h->dev = ppdev[x]; if (probe(h, callback) == 0) { libusb_ref_device(h->dev); libusb_free_device_list(ppdev, 1); return (h); } } h.reset(); libusb_free_device_list(ppdev, 1); return (nullptr); } ssize_t LibusbUsbTransport::Write(const void *_data, size_t len) { int actlen; if (libusb_bulk_transfer(h->handle, h->ep_out, - (unsigned char *)_data, len, &actlen, 0) < 0) + (unsigned char *)_data, len, &actlen, ms_timeout_) < 0) return (-1); return (actlen); } ssize_t LibusbUsbTransport::Read(void *_data, size_t len) { int actlen; if (libusb_bulk_transfer(h->handle, h->ep_in, - (unsigned char *)_data, len, &actlen, 0) < 0) + (unsigned char *)_data, len, &actlen, ms_timeout_) < 0) return (-1); return (actlen); } +LibusbUsbTransport::~LibusbUsbTransport() +{ + Close(); +} + int LibusbUsbTransport::Close() { libusb_close(h->handle); h->handle = NULL; libusb_unref_device(h->dev); h.reset(); return (0); } -Transport * -usb_open(ifc_match_func callback) +int +LibusbUsbTransport::Reset() { + if (libusb_reset_device(h->handle)) + return (-1); + return (0); +} + +UsbTransport * +usb_open(ifc_match_func callback, uint32_t timeout_ms) +{ std::unique_ptr h = enumerate(callback); - return (h ? new LibusbUsbTransport(std::move(h)) : nullptr); + return (h ? new LibusbUsbTransport(std::move(h), timeout_ms) : nullptr); }