termux-packages/packages/android-tools/fix-ndk.patch

428 lines
14 KiB
Diff
Raw Normal View History

2021-04-07 18:51:30 +02:00
diff --git a/vendor/CMakeLists.adb.txt b/vendor/CMakeLists.adb.txt
index 5206a80..3fe9b70 100644
--- a/vendor/CMakeLists.adb.txt
+++ b/vendor/CMakeLists.adb.txt
@@ -192,7 +192,6 @@ target_link_libraries(adb
brotlidec
brotlienc
lz4
- pthread
usb-1.0
z
zstd)
diff --git a/vendor/CMakeLists.fastboot.txt b/vendor/CMakeLists.fastboot.txt
index 66cbd61..34d5e7f 100644
--- a/vendor/CMakeLists.fastboot.txt
+++ b/vendor/CMakeLists.fastboot.txt
@@ -133,4 +133,4 @@ target_compile_definitions(fastboot PRIVATE
target_link_libraries(fastboot
libsparse libzip libcutils liblog libfsmgr libutil
libbase libext4 libselinux libsepol libdiagnoseusb crypto
- z pcre2-8 pthread dl)
+ z pcre2-8 dl)
diff --git a/vendor/CMakeLists.mke2fs.txt b/vendor/CMakeLists.mke2fs.txt
index a8f89fd..d1cae40 100644
--- a/vendor/CMakeLists.mke2fs.txt
+++ b/vendor/CMakeLists.mke2fs.txt
@@ -112,6 +112,6 @@ add_executable("${ANDROID_MKE2FS_NAME}"
e2fsprogs/misc/util.c)
target_link_libraries("${ANDROID_MKE2FS_NAME}"
- libext2fs libsparse libbase libzip liblog libutil pthread z)
+ libext2fs libsparse libbase libzip liblog libutil z)
target_include_directories("${ANDROID_MKE2FS_NAME}" PRIVATE
e2fsprogs/lib)
diff --git a/vendor/base/libs/androidfw/ResourceTypes.cpp b/vendor/base/libs/androidfw/ResourceTypes.cpp
index dfb4009..e2a3862 100644
--- a/vendor/base/libs/androidfw/ResourceTypes.cpp
+++ b/vendor/base/libs/androidfw/ResourceTypes.cpp
@@ -41,7 +41,7 @@
#include <utils/String16.h>
#include <utils/String8.h>
-#ifdef __ANDROID__
+#if 0
#include <binder/TextOutput.h>
#endif
diff --git a/vendor/boringssl/crypto/CMakeLists.txt b/vendor/boringssl/crypto/CMakeLists.txt
index c6073d2..3552f42 100644
--- a/vendor/boringssl/crypto/CMakeLists.txt
+++ b/vendor/boringssl/crypto/CMakeLists.txt
@@ -161,7 +161,7 @@ perlasm(test/trampoline-x86_64.${ASM_EXT} test/asm/trampoline-x86_64.pl)
add_custom_command(
OUTPUT err_data.c
- COMMAND ${GO_EXECUTABLE} run err_data_generate.go > ${CMAKE_CURRENT_BINARY_DIR}/err_data.c
+ COMMAND GOOS=linux GOARCH=amd64 ${GO_EXECUTABLE} run err_data_generate.go > ${CMAKE_CURRENT_BINARY_DIR}/err_data.c
DEPENDS
err/err_data_generate.go
err/asn1.errordata
diff --git a/vendor/core/adb/pairing_auth/include/adb/pairing/pairing_auth.h b/vendor/core/adb/pairing_auth/include/adb/pairing/pairing_auth.h
index f6b7b2a..68116c0 100644
--- a/vendor/core/adb/pairing_auth/include/adb/pairing/pairing_auth.h
+++ b/vendor/core/adb/pairing_auth/include/adb/pairing/pairing_auth.h
@@ -26,7 +26,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
+#if 1
/**
* PairingAuthCtx is a wrapper around the SPAKE2 protocol + cipher initialization
diff --git a/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_connection.h b/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_connection.h
index ad34dc4..01dad0f 100644
--- a/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_connection.h
+++ b/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_connection.h
@@ -37,7 +37,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
+#if 1
const uint32_t kMaxPeerInfoSize = 8192;
struct PeerInfo {
diff --git a/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_server.h b/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_server.h
index 0a8d676..454a214 100644
--- a/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_server.h
+++ b/vendor/core/adb/pairing_connection/include/adb/pairing/pairing_server.h
@@ -33,7 +33,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
+#if 1
// PairingServerCtx is a wrapper around the #PairingConnectionCtx APIs,
// which handles multiple client connections.
diff --git a/vendor/core/adb/sysdeps.h b/vendor/core/adb/sysdeps.h
index 298c06a..7d822f4 100644
--- a/vendor/core/adb/sysdeps.h
+++ b/vendor/core/adb/sysdeps.h
@@ -482,7 +482,11 @@ static inline int adb_gethostname(char* name, size_t len) {
}
static inline int adb_getlogin_r(char* buf, size_t bufsize) {
- return getlogin_r(buf, bufsize);
+ char* logname = getlogin();
+ if (!logname) return ENXIO;
+ if (strlen(logname) >= bufsize) return ERANGE;
+ strcpy(buf, logname);
+ return 0;
}
static inline int adb_read(borrowed_fd fd, void* buf, size_t len) {
diff --git a/vendor/core/fs_mgr/liblp/utility.cpp b/vendor/core/fs_mgr/liblp/utility.cpp
index d8e171b..31b34a5 100644
--- a/vendor/core/fs_mgr/liblp/utility.cpp
+++ b/vendor/core/fs_mgr/liblp/utility.cpp
@@ -34,7 +34,7 @@
#include <ext4_utils/ext4_utils.h>
#include <openssl/sha.h>
-#ifdef __ANDROID__
+#if 0
#include <cutils/android_get_control_file.h>
#endif
@@ -208,7 +208,7 @@ bool SetBlockReadonly(int fd, bool readonly) {
}
base::unique_fd GetControlFileOrOpen(std::string_view path, int flags) {
-#if defined(__ANDROID__)
+#if 0
int fd = android_get_control_file(path.data());
if (fd >= 0) {
int newfd = TEMP_FAILURE_RETRY(dup(fd));
diff --git a/vendor/core/init/reboot.cpp b/vendor/core/init/reboot.cpp
index 1a7275f..85e0859 100644
--- a/vendor/core/init/reboot.cpp
+++ b/vendor/core/init/reboot.cpp
@@ -247,7 +247,7 @@ static bool FindPartitionsToUmount(std::vector<MountEntry>* block_dev_partitions
if (dump) {
LOG(INFO) << "mount entry " << mentry->mnt_fsname << ":" << mentry->mnt_dir << " opts "
<< mentry->mnt_opts << " type " << mentry->mnt_type;
- } else if (MountEntry::IsBlockDevice(*mentry) && hasmntopt(mentry, "rw")) {
+ } else if (MountEntry::IsBlockDevice(*mentry) && 0) {
std::string mount_dir(mentry->mnt_dir);
// These are R/O partitions changed to R/W after adb remount.
// Do not umount them as shutdown critical services may rely on them.
diff --git a/vendor/core/libcutils/properties.cpp b/vendor/core/libcutils/properties.cpp
index 03f0496..11c4786 100644
--- a/vendor/core/libcutils/properties.cpp
+++ b/vendor/core/libcutils/properties.cpp
@@ -91,7 +91,7 @@ int property_get(const char* key, char* value, const char* default_value) {
return len;
}
-#if __has_include(<sys/system_properties.h>)
+#if 0
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
diff --git a/vendor/core/libcutils/threads.cpp b/vendor/core/libcutils/threads.cpp
index d3c9af4..da28145 100644
--- a/vendor/core/libcutils/threads.cpp
+++ b/vendor/core/libcutils/threads.cpp
@@ -24,15 +24,13 @@
#include <sys/syscall.h>
#include <sys/time.h>
#include <unistd.h>
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__)
#include <syscall.h>
#include <unistd.h>
#elif defined(_WIN32)
#include <windows.h>
#endif
-// No definition needed for Android because we'll just pick up bionic's copy.
-#if !defined(__ANDROID__) || !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 30)
pid_t gettid() {
#if defined(__APPLE__)
uint64_t tid;
@@ -44,7 +42,6 @@ pid_t gettid() {
return GetCurrentThreadId();
#endif
}
-#endif // __ANDROID__
#if !defined(_WIN32)
diff --git a/vendor/core/liblog/include/android/log.h b/vendor/core/liblog/include/android/log.h
index e80432e..b52be34 100644
--- a/vendor/core/liblog/include/android/log.h
+++ b/vendor/core/liblog/include/android/log.h
@@ -216,7 +216,7 @@ typedef void (*__android_logger_function)(const struct __android_log_message* lo
*/
typedef void (*__android_aborter_function)(const char* abort_message);
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
+#if 1
/**
* Writes the log message specified by log_message. log_message includes additional file name and
* line number information that a logger may use. log_message is versioned for backwards
diff --git a/vendor/core/liblog/logger_write.cpp b/vendor/core/liblog/logger_write.cpp
index 09802ff..93e1b91 100644
--- a/vendor/core/liblog/logger_write.cpp
+++ b/vendor/core/liblog/logger_write.cpp
@@ -39,6 +39,8 @@
#include "logger.h"
#include "uio.h"
+#undef __ANDROID__
+
#ifdef __ANDROID__
#include "logd_writer.h"
#include "pmsg_writer.h"
@@ -108,31 +110,6 @@ void __android_log_close() {
#endif
}
-#if defined(__linux__) || defined(_WIN32)
-static const char* getprogname() {
-#if defined(__linux__)
- return program_invocation_short_name;
-#elif defined(_WIN32)
- static bool first = true;
- static char progname[MAX_PATH] = {};
-
- if (first) {
- char path[PATH_MAX + 1];
- DWORD result = GetModuleFileName(nullptr, path, sizeof(path) - 1);
- if (result == 0 || result == sizeof(path) - 1) return "";
- path[PATH_MAX - 1] = 0;
-
- char* path_basename = basename(path);
-
- snprintf(progname, sizeof(progname), "%s", path_basename);
- first = false;
- }
-
- return progname;
-#endif
-}
-#endif
-
// It's possible for logging to happen during static initialization before our globals are
// initialized, so we place this std::string in a function such that it is initialized on the first
// call.
diff --git a/vendor/e2fsprogs/lib/ext2fs/ismounted.c b/vendor/e2fsprogs/lib/ext2fs/ismounted.c
index 6cd497d..dcdd4fd 100644
--- a/vendor/e2fsprogs/lib/ext2fs/ismounted.c
+++ b/vendor/e2fsprogs/lib/ext2fs/ismounted.c
@@ -196,7 +196,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
#endif /* __GNU__ */
*mount_flags = EXT2_MF_MOUNTED;
-#ifdef MNTOPT_RO
+#if 0
/* Check to see if the ro option is set */
if (hasmntopt(mnt, MNTOPT_RO))
*mount_flags |= EXT2_MF_READONLY;
diff --git a/vendor/f2fs-tools/lib/libf2fs.c b/vendor/f2fs-tools/lib/libf2fs.c
index 55fa391..cf2716c 100644
--- a/vendor/f2fs-tools/lib/libf2fs.c
+++ b/vendor/f2fs-tools/lib/libf2fs.c
@@ -714,7 +714,7 @@ static int is_mounted(const char *mpt, const char *device)
while ((mnt = getmntent(file)) != NULL) {
if (!strcmp(device, mnt->mnt_fsname)) {
-#ifdef MNTOPT_RO
+#if 0
if (hasmntopt(mnt, MNTOPT_RO))
c.ro = 1;
#endif
diff --git a/vendor/libbase/include/android-base/unique_fd.h b/vendor/libbase/include/android-base/unique_fd.h
index 9ceb5db..bf6f5cc 100644
--- a/vendor/libbase/include/android-base/unique_fd.h
+++ b/vendor/libbase/include/android-base/unique_fd.h
@@ -46,7 +46,7 @@
// unique_fd is also known as ScopedFd/ScopedFD/scoped_fd; mentioned here to help
// you find this class if you're searching for one of those names.
-#if defined(__BIONIC__)
+#if 0
#include <android/fdsan.h>
#endif
@@ -54,7 +54,7 @@ namespace android {
namespace base {
struct DefaultCloser {
-#if defined(__BIONIC__)
+#if 0
static void Tag(int fd, void* old_addr, void* new_addr) {
if (android_fdsan_exchange_owner_tag) {
uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
diff --git a/vendor/libbase/liblog_symbols.cpp b/vendor/libbase/liblog_symbols.cpp
index 1f4b69b..0a1c1de 100644
--- a/vendor/libbase/liblog_symbols.cpp
+++ b/vendor/libbase/liblog_symbols.cpp
@@ -16,9 +16,7 @@
#include "liblog_symbols.h"
-#if defined(__ANDROID_SDK_VERSION__) && (__ANDROID_SDK_VERSION__ <= 29)
#define USE_DLSYM
-#endif
#ifdef USE_DLSYM
#include <dlfcn.h>
diff --git a/vendor/libbase/logging.cpp b/vendor/libbase/logging.cpp
index 88c05b5..5f993e2 100644
--- a/vendor/libbase/logging.cpp
+++ b/vendor/libbase/logging.cpp
@@ -66,11 +66,17 @@
namespace android {
namespace base {
+#if defined(__linux__)
+extern "C" {
+extern char* __progname;
+}
+#endif
+
// BSD-based systems like Android/macOS have getprogname(). Others need us to provide one.
#if defined(__linux__) || defined(_WIN32)
static const char* getprogname() {
#if defined(__linux__)
- return program_invocation_short_name;
+ return __progname;
#elif defined(_WIN32)
static bool first = true;
static char progname[MAX_PATH] = {};
diff --git a/vendor/libbase/properties.cpp b/vendor/libbase/properties.cpp
index 8190987..a61ac05 100644
--- a/vendor/libbase/properties.cpp
+++ b/vendor/libbase/properties.cpp
@@ -16,7 +16,7 @@
#include "android-base/properties.h"
-#if defined(__BIONIC__)
+#if 0
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/system_properties.h>
#include <sys/_system_properties.h>
@@ -32,8 +32,6 @@
#include <android-base/parseint.h>
#include <android-base/strings.h>
-#if !defined(__BIONIC__)
-
#define PROP_VALUE_MAX 92
static std::map<std::string, std::string>& g_properties = *new std::map<std::string, std::string>;
@@ -63,8 +61,6 @@ int __system_property_get(const char* key, char* value) {
return strlen(value);
}
-#endif
-
namespace android {
namespace base {
@@ -108,7 +104,7 @@ template uint64_t GetUintProperty(const std::string&, uint64_t, uint64_t);
std::string GetProperty(const std::string& key, const std::string& default_value) {
std::string property_value;
-#if defined(__BIONIC__)
+#if 0
const prop_info* pi = __system_property_find(key.c_str());
if (pi == nullptr) return default_value;
@@ -134,7 +130,7 @@ bool SetProperty(const std::string& key, const std::string& value) {
return (__system_property_set(key.c_str(), value.c_str()) == 0);
}
-#if defined(__BIONIC__)
+#if 0
struct WaitForPropertyData {
bool done;
diff --git a/vendor/libziparchive/zip_archive.cc b/vendor/libziparchive/zip_archive.cc
index 9e6091c..933c865 100644
--- a/vendor/libziparchive/zip_archive.cc
+++ b/vendor/libziparchive/zip_archive.cc
@@ -39,7 +39,9 @@
#define lseek64 lseek
#endif
-#if defined(__BIONIC__)
+#undef __ANDROID__
+
+#if 0
#include <android/fdsan.h>
#endif
@@ -88,7 +90,7 @@ static constexpr uint64_t kMaxFileLength = 256 * static_cast<uint64_t>(1u << 30u
* of the string length into the hash table entry.
*/
-#if defined(__BIONIC__)
+#if 0
uint64_t GetOwnerTag(const ZipArchive* archive) {
return android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_ZIPARCHIVE,
reinterpret_cast<uint64_t>(archive));
@@ -102,7 +104,7 @@ ZipArchive::ZipArchive(MappedZipFile&& map, bool assume_ownership)
central_directory(),
directory_map(),
num_entries(0) {
-#if defined(__BIONIC__)
+#if 0
if (assume_ownership) {
CHECK(mapped_zip.HasFd());
android_fdsan_exchange_owner_tag(mapped_zip.GetFileDescriptor(), 0, GetOwnerTag(this));
@@ -120,7 +122,7 @@ ZipArchive::ZipArchive(const void* address, size_t length)
ZipArchive::~ZipArchive() {
if (close_file && mapped_zip.GetFileDescriptor() >= 0) {
-#if defined(__BIONIC__)
+#if 0
android_fdsan_close_with_tag(mapped_zip.GetFileDescriptor(), GetOwnerTag(this));
#else
close(mapped_zip.GetFileDescriptor());