Upgrade to much newer version with changed build system.

Now using https://github.com/nmeum/android-tools
This commit is contained in:
Kvuj 2021-03-14 02:04:15 +00:00 committed by Timothee Leclaire-Fournier
commit ad042eefb0
9 changed files with 27 additions and 9101 deletions

View file

@ -1,48 +0,0 @@
diff --git a/adb/sysdeps/posix/network.cpp b/adb/sysdeps/posix/network.cpp
index ecd1fd24e..07fd8c98e 100644
--- a/adb/sysdeps/posix/network.cpp
+++ b/adb/sysdeps/posix/network.cpp
@@ -19,6 +19,7 @@
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
+#include <string.h>
#include <string>
diff --git a/adb/types.h b/adb/types.h
index a3e5d4842..bac7181b4 100644
--- a/adb/types.h
+++ b/adb/types.h
@@ -22,6 +22,7 @@
#include <type_traits>
#include <utility>
#include <vector>
+#include <string.h>
#include <android-base/logging.h>
diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp
index 296995efe..48269b675 100644
--- a/base/errors_unix.cpp
+++ b/base/errors_unix.cpp
@@ -17,6 +17,7 @@
#include "android-base/errors.h"
#include <errno.h>
+#include <string.h>
namespace android {
namespace base {
diff --git a/base/file.cpp b/base/file.cpp
index d6fe753d1..3b10544dd 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <string.h>
#include <memory>
#include <mutex>

View file

@ -1,15 +0,0 @@
diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp
index 7adb262..b994c8c 100644
--- a/adb/client/usb_libusb.cpp
+++ b/adb/client/usb_libusb.cpp
@@ -27,8 +27,9 @@
#include <string>
#include <thread>
#include <unordered_map>
+#include <condition_variable>
-#include <libusb/libusb.h>
+#include <libusb-1.0/libusb.h>
#include <android-base/file.h>
#include <android-base/logging.h>

View file

@ -1,12 +0,0 @@
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 38c6f62c9..9df41a236 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -44,7 +44,6 @@
#include <android-base/parsenetaddress.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <build/version.h>
#include "adb_auth.h"
#include "adb_io.h"

View file

@ -1,51 +0,0 @@
diff --git a/libcrypto_utils/android_pubkey.c b/libcrypto_utils/android_pubkey.c
index 3052e52..7061db9 100644
--- a/libcrypto_utils/android_pubkey.c
+++ b/libcrypto_utils/android_pubkey.c
@@ -126,37 +126,41 @@ bool android_pubkey_encode(const RSA* key, uint8_t* key_buffer, size_t size) {
BIGNUM* r32 = BN_new();
BIGNUM* n0inv = BN_new();
BIGNUM* rr = BN_new();
+ const BIGNUM *n;
+ const BIGNUM *e;
if (sizeof(RSAPublicKey) > size ||
RSA_size(key) != ANDROID_PUBKEY_MODULUS_SIZE) {
goto cleanup;
}
+ RSA_get0_key(key, &n, &e, NULL);
+
// Store the modulus size.
key_struct->modulus_size_words = ANDROID_PUBKEY_MODULUS_SIZE_WORDS;
// Compute and store n0inv = -1 / N[0] mod 2^32.
- if (!ctx || !r32 || !n0inv || !BN_set_bit(r32, 32) ||
- !BN_mod(n0inv, key->n, r32, ctx) ||
+ if (!ctx || !r32 || !n0inv || !n || !e || !BN_set_bit(r32, 32) ||
+ !BN_mod(n0inv, n, r32, ctx) ||
!BN_mod_inverse(n0inv, n0inv, r32, ctx) || !BN_sub(n0inv, r32, n0inv)) {
goto cleanup;
}
key_struct->n0inv = (uint32_t)BN_get_word(n0inv);
// Store the modulus.
- if (!android_pubkey_encode_bignum(key->n, key_struct->modulus)) {
+ if (!android_pubkey_encode_bignum(n, key_struct->modulus)) {
goto cleanup;
}
// Compute and store rr = (2^(rsa_size)) ^ 2 mod N.
if (!ctx || !rr || !BN_set_bit(rr, ANDROID_PUBKEY_MODULUS_SIZE * 8) ||
- !BN_mod_sqr(rr, rr, key->n, ctx) ||
+ !BN_mod_sqr(rr, rr, n, ctx) ||
!android_pubkey_encode_bignum(rr, key_struct->rr)) {
goto cleanup;
}
// Store the exponent.
- key_struct->exponent = (uint32_t)BN_get_word(key->e);
+ key_struct->exponent = (uint32_t)BN_get_word(e);
ret = true;

View file

@ -1,12 +0,0 @@
diff --git a/adb/client/usb_linux.cpp b/adb/client/usb_linux.cpp
index 869e858d4..f1bf559a9 100644
--- a/adb/client/usb_linux.cpp
+++ b/adb/client/usb_linux.cpp
@@ -30,6 +30,7 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>

File diff suppressed because it is too large Load diff

View file

@ -1,57 +1,36 @@
%global date 20180828
%global git_commit c7815d675
%global packdname core-%{git_commit}
%global boring_git_commit fb44824b9
%global boring_packdname boringssl-%{boring_git_commit}
%global mdns_git_commit 33e620a7
%global mdns_packdname mdnsresponder-%{mdns_git_commit}
%global package_version 30.0.5p1
%global package_name android-tools
%global _hardened_build 1
Name: android-tools
Version: %{date}git%{git_commit}
Release: 11%{?dist}
Name: %{package_name}
Version: %{package_version}
Release: 1%{?dist}
Summary: Android platform tools(adb, fastboot)
# The entire source code is ASL 2.0 except boringssl which is BSD
License: ASL 2.0 and (ASL 2.0 and BSD)
URL: http://developer.android.com/guide/developing/tools/
# using git archive since upstream hasn't created tarballs.
# git archive --format=tar --prefix=core/ %%{git_commit} adb base diagnose_usb fastboot libcrypto_utils libcutils liblog libsparse libsystem libutils libziparchive mkbootimg include | xz > %%{packdname}.tar.xz
# https://android.googlesource.com/platform/system/core.git
# git archive --format=tar --prefix=boringssl/ %%{boring_git_commit} src/crypto include src/include | xz > %%{boring_packdname}.tar.xz
# https://android.googlesource.com/platform/external/boringssl
# git archive --format=tar --prefix=mdnsresponder/ %%{mdns_git_commit} mDNSShared | xz > %%{mdns_packdname}.tar.xz
# https://android.googlesource.com/platform/external/mdnsresponder
Source0: %{packdname}.tar.xz
Source2: generate_build.rb
Source3: %{boring_packdname}.tar.xz
Source4: %{mdns_packdname}.tar.xz
Source5: 51-android.rules
Source6: adb.service
Patch1: 0001-Add-string-h.patch
Patch2: 0002-libusb-modifications.patch
Patch3: 0003-buildlib-remove.patch
Patch4: 0004-bz1441234.patch
# https://android-review.googlesource.com/c/platform/system/core/+/740625
Patch5: 0005-Add-sysmacros-h.patch
Source0: %{package_name}-%{package_version}.tar.xz
Source1: adb.service
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
BuildRequires: clang
BuildRequires: cmake
BuildRequires: golang
BuildRequires: perl
BuildRequires: gtest-devel
BuildRequires: libselinux-devel
BuildRequires: libusbx-devel
BuildRequires: ninja-build
BuildRequires: openssl-devel
BuildRequires: ruby rubygems
BuildRequires: protobuf-devel
BuildRequires: brotli
BuildRequires: libzstd-devel
BuildRequires: lz4-devel
BuildRequires: systemd
BuildRequires: zlib-devel
Provides: adb
Provides: fastboot
@ -85,38 +64,15 @@ to read and write the flash partitions. It needs the same USB device
setup between the host and the target phone as adb.
%prep
%setup -q -b 3 -n boringssl
%setup -q -b 4 -n mdnsresponder
%setup -q -b 0 -n core
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
cp -p %{SOURCE5} 51-android.rules
export CC="clang"
export CXX="clang++"
sed -i 's/android::build::GetBuildNumber().c_str()/"%{git_commit}"/g' adb/adb.cpp
# This package appears to be failing because links to the LLVM plugins
# are not installed which results in the tools not being able to
# interpret the .o/.a files. Disable LTO for now
%define _lto_cflags %{nil}
%global optflags %(echo %{optflags} | sed -e 's/-mcet//g' -e 's/-fcf-protection//g' -e 's/-fstack-clash-protection//g')
%autosetup
%build
cd ..
PKGVER=%{git_commit} CXXFLAGS="%{optflags} -Qunused-arguments" CFLAGS="%{optflags} -Qunused-arguments" ruby %{SOURCE2} > build.ninja
%ninja_build
%cmake
%cmake_build
%install
cd ../
install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
install -d -m 0775 ${RPM_BUILD_ROOT}%{_sharedstatedir}/adb
install -m 0755 -t ${RPM_BUILD_ROOT}%{_bindir} adb fastboot simg2img img2simg
install -p -D -m 0644 %{SOURCE6} \
%cmake_install
install -p -D -m 0644 %{SOURCE1} \
%{buildroot}%{_unitdir}/adb.service
%post
@ -129,18 +85,21 @@ install -p -D -m 0644 %{SOURCE6} \
%systemd_postun_with_restart adb.service
%files
%doc adb/OVERVIEW.TXT adb/SERVICES.TXT adb/NOTICE adb/protocol.txt 51-android.rules
%{_unitdir}/adb.service
%attr(0755,root,root) %dir %{_sharedstatedir}/adb
#ASL2.0 and BSD
%{_bindir}/adb
#ASL2.0
%{_bindir}/simg2img
%{_bindir}/append2simg
%{_bindir}/img2simg
%{_bindir}/fastboot
%{_bindir}/mke2fs.android
%changelog
* Sat Mar 13 2021 Timothee Leclaire-Fournier <timotheel-f@protonmail.com> - 30.0.5p1-1
- Changed to use use much simpler cmake build system
- See https://github.com/nmeum/android-tools
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 20180828gitc7815d675-11
- Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.
@ -186,7 +145,7 @@ install -p -D -m 0644 %{SOURCE6} \
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 20170311gite7195be7725a-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Oct 26 2017 Vít Ondruch <vondruch@redhat.com> - 20170311gite7195be7725a-5
* Thu Oct 26 2017 dt Ondruch <vondruch@redhat.com> - 20170311gite7195be7725a-5
- Drop the explicit dependnecy on rubypick.
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 20170311gite7195be7725a-4

View file

@ -1,234 +0,0 @@
#!/usr/bin/ruby
# Android build system is complicated and does not allow to build
# separate parts easily.
# This script tries to mimic Android build rules.
def expand(dir, files)
files.map{|f| File.join(dir,f)}
end
# Compiles sources to *.o files.
# Returns array of output *.o filenames
def compile(sources, cflags)
outputs = []
for s in sources
ext = File.extname(s)
case ext
when '.c'
cc = 'cc'
lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS'
when '.cpp', '.cc'
cc = 'cxx'
lang_flags = '-std=gnu++17 $CXXFLAGS $CPPFLAGS'
else
raise "Unknown extension #{ext}"
end
output = s + '.o'
outputs << output
puts "build #{output}: #{cc} #{s}\n cflags = #{lang_flags} #{cflags}"
end
return outputs
end
# dir - directory where ninja file is located
# lib - static library path relative to dir
def subninja(dir, lib)
puts "subninja #{dir}build.ninja"
return lib.each{|l| dir + l}
end
# Links object files
def link(output, objects, ldflags)
puts "build #{output}: link #{objects.join(' ')}\n ldflags = #{ldflags} $LDFLAGS"
end
puts "# This set of commands generated by generate_build.rb script\n\n"
puts "CC = #{ENV['CC'] || 'clang'}"
puts "CXX = #{ENV['CXX'] || 'clang++'}\n\n"
puts "CFLAGS = #{ENV['CFLAGS']}"
puts "CXXFLAGS = #{ENV['CXXFLAGS']}"
puts "LDFLAGS = #{ENV['LDFLAGS']}"
puts "PKGVER = #{ENV['PKGVER']}\n\n"
puts """
rule cc
command = $CC $cflags -c $in -o $out
rule cxx
command = $CXX $cflags -c $in -o $out
rule link
command = $CXX $ldflags $LDFLAGS $in -o $out
"""
adbdfiles = %w(
adb.cpp
adb_io.cpp
adb_listeners.cpp
adb_trace.cpp
adb_utils.cpp
adb_unique_fd.cpp
sockets.cpp
transport.cpp
transport_local.cpp
transport_usb.cpp
fdevent.cpp
shell_service_protocol.cpp
)
libadbd = compile(expand('core/adb', adbdfiles), '-DADB_HOST=1 -Icore/diagnose_usb/include -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include')
adbfiles = %w(
client/auth.cpp
client/console.cpp
socket_spec.cpp
client/bugreport.cpp
client/line_printer.cpp
client/commandline.cpp
client/adb_client.cpp
services.cpp
client/file_sync_client.cpp
sysdeps_unix.cpp
sysdeps/errno.cpp
sysdeps/posix/network.cpp
client/main.cpp
client/usb_dispatch.cpp
client/usb_linux.cpp
client/usb_libusb.cpp
client/transport_mdns.cpp
)
libadb = compile(expand('core/adb', adbfiles), '-D_GNU_SOURCE -DADB_HOST=1 -Icore/libcrypto_utils/include -Iboringssl/src/include -Icore/include -Icore/base/include -Icore/adb -Imdnsresponder/mDNSShared')
basefiles = %w(
file.cpp
threads.cpp
logging.cpp
parsenetaddress.cpp
stringprintf.cpp
strings.cpp
errors_unix.cpp
test_utils.cpp
)
libbase = compile(expand('core/base', basefiles), '-DADB_HOST=1 -Icore/base/include -Icore/include')
logfiles = %w(
log_event_write.c
fake_log_device.c
log_event_list.c
logger_write.c
config_write.c
config_read.c
logger_lock.c
local_logger.c
fake_writer.c
logger_name.c
stderr_write.c
logprint.c
)
liblog = compile(expand('core/liblog', logfiles), '-DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1 -Icore/libsystem/include -Icore/liblog/include -Icore/include')
cutilsfiles = %w(
fs_config.cpp
canned_fs_config.cpp
android_get_control_file.cpp
socket_network_client_unix.cpp
socket_inaddr_any_server_unix.cpp
sockets.cpp
sockets_unix.cpp
socket_local_client_unix.cpp
socket_local_server_unix.cpp
)
libcutils = compile(expand('core/libcutils', cutilsfiles), '-D_GNU_SOURCE -Icore/libcutils/include -Icore/include -Icore/base/include')
diagnoseusbfiles = %w(
diagnose_usb.cpp
)
libdiagnoseusb = compile(expand('core/diagnose_usb', diagnoseusbfiles), '-Icore/diagnose_usb/include -Icore/include -Icore/base/include')
libcryptofiles = %w(
android_pubkey.c
)
libcrypto = compile(expand('core/libcrypto_utils', libcryptofiles), '-Icore/libcrypto_utils/include -Iboringssl/src/include')
utilfiles = %w(
FileMap.cpp
Unicode.cpp
SharedBuffer.cpp
String8.cpp
String16.cpp
)
libutil = compile(expand('core/libutils', utilfiles), '-Icore/include')
mdnsfiles = %w(
mDNSShared/dnssd_ipc.c
mDNSShared/dnssd_clientstub.c
)
mdns = compile(expand('mdnsresponder', mdnsfiles), '-D_GNU_SOURCE -DHAVE_IPV6 -DHAVE_LINUX -DNOT_HAVE_SA_LEN -DUSES_NETLINK -UMDNS_DEBUGMSGS -DMDNS_DEBUGMSGS=0 -Imdnsresponder/mDNSShared -Imdnsresponder/mDNSCore -Iinclude')
zipfiles = %w(
zip_archive_stream_entry.cc
zip_archive.cc
)
libzip = compile(expand('core/libziparchive', zipfiles), '-Icore/libziparchive/include -Icore/base/include -Icore/include')
boringcryptofiles = %w(
bn/cmp.c
bn/bn.c
bytestring/cbb.c
mem.c
buf/buf.c
bio/file.c
bn/convert.c
base64/base64.c
)
boringcrypto = compile(expand('boringssl/src/crypto', boringcryptofiles), '-Iboringssl/src/include -Iinclude')
link('adb', libbase + liblog + libcutils + libcrypto + libadbd + libadb + libdiagnoseusb + libutil + libzip + mdns + boringcrypto, '-lz -lcrypto -lpthread -lusb-1.0')
fastbootfiles = %w(
bootimg_utils.cpp
fs.cpp
socket.cpp
tcp.cpp
udp.cpp
usb_linux.cpp
util.cpp
main.cpp
engine.cpp
fastboot.cpp
fastboot_driver.cpp
)
libfastboot = compile(expand('core/fastboot', fastbootfiles), '-DFASTBOOT_VERSION="\"$PKGVER\"" -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -DUSE_F2FS -Icore/base/include -Icore/include -Icore/adb -Icore/libsparse/include -Icore/mkbootimg/include/bootimg -Icore/libziparchive/include -Icore/diagnose_usb/include')
sparsefiles = %w(
backed_block.cpp
output_file.cpp
sparse.cpp
sparse_crc32.cpp
sparse_err.cpp
sparse_read.cpp
)
libsparse = compile(expand('core/libsparse', sparsefiles), '-Icore/libsparse/include -Icore/base/include')
link('fastboot', libsparse + libzip + libcutils + liblog + libutil + libbase + libfastboot + libdiagnoseusb, '-lz -lpcre2-8 -lpthread -ldl')
simg2imgfiles = %w(
simg2img.cpp
)
libsimg2img = compile(expand('core/libsparse', simg2imgfiles), '-Iinclude -Icore/libsparse/include')
link('simg2img', libbase + libsparse + libsimg2img, '-lz')
img2simgfiles = %w(
img2simg.cpp
)
libimg2simg = compile(expand('core/libsparse', img2simgfiles), '-Iinclude -Icore/libsparse/include')
link('img2simg', libbase + libsparse + libimg2simg, '-lz')

View file

@ -1,3 +1 @@
SHA512 (core-c7815d675.tar.xz) = eb294bc0f70eb65527610c534140ddc9dd9b4555924ceda6867557dabfc183c3cafe58b8b7a9b60c0adf44fb459250d92df17441dd071367bce0365e6a739b45
SHA512 (mdnsresponder-33e620a7.tar.xz) = 9f8a3a05a0dc7440439b8ae8f0032bf8033587fd47bb2cbaad6243dbbf5bb42fa19f251714fc799247ce40fb968b2a51a257e5f9732b1ca9eb9fe3a9c84af904
SHA512 (boringssl-fb44824b9.tar.xz) = bf889a8b87cebdb8a70424c855d64fe4a7930fb1e5ace0659ce9486b47ddbb93e91f7f0db8106639969e422fc6be152f9b18f5aec37f05c5c1fb29811dd7179b
SHA512 (android-tools-30.0.5p1.tar.xz) = 8807d7e93ca04994c641278f6b260361f5c06186c9d9edacb0caa72484d5367c35f84c3fb3ad66bf969055e87af48c0b69241b70271e4f3891d1bb2e8336a7f6