Subject: [alpine-aports] [PATCH] testing/android-tools: upgrade to 6.0.1_p46

From: Sören Tempel <[email-masked]>
Date: Sun, 10 Jul 2016 20:49:17 +0200

Use the ruby hack written by the arch linux folks to build the entire
thing.
---
 testing/android-tools/APKBUILD                 | 107 +++++++--------
 testing/android-tools/Makefile                 | 110 ----------------
 testing/android-tools/fix-build.patch          |  69 ++++++++++
 testing/android-tools/fix-getcwd.patch         |  36 ++++++
 testing/android-tools/generate-build.rb        | 172 +++++++++++++++++++++++++
 testing/android-tools/qemu-musl-native64.patch | 120 -----------------
 6 files changed, 321 insertions(+), 293 deletions(-)
 delete mode 100644 testing/android-tools/Makefile
 create mode 100644 testing/android-tools/fix-build.patch
 create mode 100644 testing/android-tools/fix-getcwd.patch
 create mode 100644 testing/android-tools/generate-build.rb
 delete mode 100644 testing/android-tools/qemu-musl-native64.patch

diff --git a/testing/android-tools/APKBUILD b/testing/android-tools/APKBUILD
index a351744..83deb0e 100644
--- a/testing/android-tools/APKBUILD
+++ b/testing/android-tools/APKBUILD
@@ -1,7 +1,7 @@
 # Contributor: Sören Tempel <[email-masked]>
 # Maintainer: Sören Tempel <[email-masked]>
 pkgname=android-tools
-pkgver=5.1.1_p13
+pkgver=6.0.1_p46
 _realver=${pkgver/_p/_r}
 pkgrel=1
 pkgdesc="Android platform tools"
@@ -9,30 +9,37 @@ url="http://tools.android.com/"
 arch="all"
 license="Apache BSD"
 depends=""
-depends_dev="openssl-dev pcre-dev"
-makedepends="$depends_dev linux-headers bsd-compat-headers"
+depends_dev=""
+makedepends="openssl-dev pcre-dev linux-headers bsd-compat-headers ruby"
 install=""
 subpackages=""
 source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-core-$_realver.tar.gz
 	http://dev.alpinelinux.org/archive/$pkgname/$pkgname-extras-$_realver.tar.gz
 	http://dev.alpinelinux.org/archive/$pkgname/$pkgname-libselinux-$_realver.tar.gz
 	http://dev.alpinelinux.org/archive/$pkgname/$pkgname-f2fs-tools-$_realver.tar.gz
-	http://dev.alpinelinux.org/archive/$pkgname/$pkgname-sdk-$_realver.tar.gz
-	http://dev.alpinelinux.org/archive/$pkgname/$pkgname-qemu-$_realver.tar.gz
 
-	Makefile
-
-	qemu-musl-native64.patch
+	fix-build.patch
+	fix-getcwd.patch
+	generate-build.rb
 	"
 
 _giturl="https://android.googlesource.com/platform"
 _gittag="android-$_realver"
 
+builddir="$srcdir"
+prepare() {
+	default_prepare || return 1
+
+	cd "$builddir"
+	echo "set -x -e" > build.sh
+	ruby generate-build.rb >> build.sh
+}
+
 snapshot() {
 	mkdir -p "$srcdir" && cd "$srcdir"
 
 	local r=
-	for r in system/core system/extras external/libselinux external/f2fs-tools sdk external/qemu; do
+	for r in system/core system/extras external/libselinux external/f2fs-tools; do
 		local n="${r##*/}.git"
 		local f=$pkgname-"${r##*/}"
 
@@ -47,63 +54,37 @@ snapshot() {
 	scp "$srcdir"/$pkgname-*-$_realver.tar.gz dev.alpinelinux.org:/archive/$pkgname/
 }
 
-prepare() {
-	cd "$srcdir"
-	sed -e 's/f2fs_sparse_file = NULL/f2fs_sparse_file = 0/g' \
-		-i extras/f2fs_utils/f2fs_utils.c || return 1
-
-	cd "$srcdir"/qemu
-	patch -p1 -i "$srcdir"/qemu-musl-native64.patch || return 1
-}
-
 build() {
-	make -C "$srcdir"
-
-	cd "$srcdir"/qemu
-	_bits=32
-	case "$CARCH" in
-	x86_64) _bits=64;;
-	esac
-	USE_CCACHE=0 \
-	./android-configure.sh --ignore-audio \
-		--gles-dir=../sdk/emulator/opengl \
-		--no-tests \
-		--no-strip \
-		|| return 1
-	make objs/emulator \
-		objs/emulator$_bits-x86 \
-		objs/emulator$_bits-arm \
-		|| return 1
-
+	cd "$builddir"
+	CFLAGS="$CFLAGS -DDEFFILEMODE=0666" \
+		PKGVER=$pkgver sh build.sh || return 1
 }
 
 package() {
-	make DESTDIR="$pkgdir" \
-		-C "$srcdir" install || return 1
-	install "$srcdir"/qemu/objs/emulator* "$pkgdir"/usr/bin/
+	cd "$builddir"
+	mkdir -p "$pkgdir"/usr/bin/
+	install -Dm755 mkbootimg fastboot adb \
+		"$pkgdir"/usr/bin/ || return 1
 }
 
-md5sums="872508bf26b5e3cb04aa73d4ba558d9d  android-tools-core-5.1.1_r13.tar.gz
-c1451c39af87f6e59330f222f69e143f  android-tools-extras-5.1.1_r13.tar.gz
-e6eb1bb16898e4ef2000f0dab4e921bd  android-tools-libselinux-5.1.1_r13.tar.gz
-9087604b3553d1e6f5070f72b9299ec5  android-tools-f2fs-tools-5.1.1_r13.tar.gz
-0c538db4ae36aa390ac79cab95b7f809  android-tools-sdk-5.1.1_r13.tar.gz
-70f246cfa59f0f23cc04cb9b5ae220d4  android-tools-qemu-5.1.1_r13.tar.gz
-19d59c9442ed7c1882dafa652f815e79  Makefile
-ff6851515388a1c35c563f530c0ddeb6  qemu-musl-native64.patch"
-sha256sums="d3ce45dafe5d5388ad6092186753c5482993a81995fb44ffb24bbe756f996c9e  android-tools-core-5.1.1_r13.tar.gz
-08487b9009067dba2ccd436330873350b9a556fe0a19bd191468e145f99fd14c  android-tools-extras-5.1.1_r13.tar.gz
-d010434fe8dffe7e7bd649c3b071fd21676b17b861457055637451d3fdb418bb  android-tools-libselinux-5.1.1_r13.tar.gz
-f9a4c9747bbebbdde5b712e9aac644d8af2b1c8ab2ef340c22824c3e64fa3f49  android-tools-f2fs-tools-5.1.1_r13.tar.gz
-839ad231559e09ce3e95472ab2fcb009f331d24a7c2ee5acbd54333085c49604  android-tools-sdk-5.1.1_r13.tar.gz
-858c2fb9b414025ba0eb2f7144273557df91303e6b7cc3a7a00ddbce0499cafb  android-tools-qemu-5.1.1_r13.tar.gz
-d8b2fca4acf93525ba70779651f8b5ceddf4955299c80c4842cfe05a7facc4d8  Makefile
-1d82e9784945f2efa12aa4b103968eb541388998ac1086aa10b9346cb964b8b3  qemu-musl-native64.patch"
-sha512sums="46081c68fb9907ac454ffbb6d9c783eec31a112b9a87d0fd77f6b5cba3b1b6ccc1f9c05b05699d0fe3f6fb82e71900ecf5b4813fdae393f02ff518c5a7500ad6  android-tools-core-5.1.1_r13.tar.gz
-318a8ea0dc9b956d329405eb807d61972579ea04ec1692ea0b1c7f273339a14353f52f15b4f5f5e61357fee1cf010ddee116ef8b6428a76de8c4adbba23900a1  android-tools-extras-5.1.1_r13.tar.gz
-2f301ebbe079eff510df3312b6d63bdd6e456c0e418f6a94a6718f5560f94c402851dcf5edfda71315570fd6a8fcd6306d8c640a74ee36efb39e73318e8d570f  android-tools-libselinux-5.1.1_r13.tar.gz
-9bc54d777f4ead1878e389932f1b60027b146a6a1afa78f187e20dd473826b8a02dbadaced87ef3f764941712f99c81e8113cc6e5cb1f0e7975c7af747d7c3aa  android-tools-f2fs-tools-5.1.1_r13.tar.gz
-5e9c0c2a5e6e5d0255813722a1d9db0eb9350a21942c03071cd925c193df9cae46bb9a657e4f6a29ebc86dacc1c5d10784bca1d1d842ebf3b3c8310d378c2ef2  android-tools-sdk-5.1.1_r13.tar.gz
-6c04937b67fa6ecd42f58c368364550d625900a7c052fb5b523099db29a793d08a25d82881b45a73a38326586226d7850ff6bf5d32d35cd56a1b6ad1f88fdefc  android-tools-qemu-5.1.1_r13.tar.gz
-0868206cbfb60b57a134354b541de93ec3bbef51d87e3b4bda7ecd01a6e94ef3f5bc323c49a6fb6eb2560beec8744c2cabd969ec968bc2b774a1b64f291f5d05  Makefile
-36cffb12dfb659ff78dc42b2affa3af866b1ce21d3449730463bf744df3129d412cfa548626f376b0c091a911317e88aa5bbe89732b28c03202854f98f1d1624  qemu-musl-native64.patch"
+md5sums="9a943c0659cf8a0aabc000ded6fb6f55  android-tools-core-6.0.1_r46.tar.gz
+1981e7c89b363a9f2448d2e57118160d  android-tools-extras-6.0.1_r46.tar.gz
+c56a60a2d68f7be18ff1e06b54c814a3  android-tools-libselinux-6.0.1_r46.tar.gz
+1944e42cd835d61b4f2e75abf3afdd6d  android-tools-f2fs-tools-6.0.1_r46.tar.gz
+7272c0aea987e1d4450ed316cb19937a  fix-build.patch
+b3d1da647a52bf0dd6ca562033648b41  fix-getcwd.patch
+3c77207b30748bcf2cbb6dab257bf6ff  generate-build.rb"
+sha256sums="0c26de29a84442a35856401275c8da3b2ab9e71c6f782636ca78f2cdcf197acb  android-tools-core-6.0.1_r46.tar.gz
+883f959dc93a739a8194adafea93fec3089a14773dcda48148ea353e4fb7288f  android-tools-extras-6.0.1_r46.tar.gz
+8db84813cc18144c6bb2fb80e519e8ee818256b5d11ac1d92aa748978c9bb81a  android-tools-libselinux-6.0.1_r46.tar.gz
+d236883bf2ff025ce4c091028489a3ace2318bbfd2e1dcdaa7d7c6acadb41fa7  android-tools-f2fs-tools-6.0.1_r46.tar.gz
+bb91e2a8855a5b47d64fbe2a13dcfb5c3bfca5b9e79e06a790cdabe48d55bc2c  fix-build.patch
+d9e2ba5337c2dbea2d9747c232f56953562494e44faeee88dd0abddb3c810796  fix-getcwd.patch
+802f565f7204b720ff86f6acb02aa1ba03b9438b84a38911ba76edeb0824dd3d  generate-build.rb"
+sha512sums="6dff9e1b8d2218ffc8c96bdf8d025be63f9443c0fb6376e0dc8213f8cfb7755a8d119a1a275ce23e614db6c07d0ee9048060266a36df91fa16127f2e07180257  android-tools-core-6.0.1_r46.tar.gz
+c7af5327f9dc88a9c3ccc4d789c211e56b19bb5c689b257bd2a528d418ebae2326e96f41d11c72bd0c34d6390c1f42c2b15e8ea8ab93b8056dcf2ec82ca0f26e  android-tools-extras-6.0.1_r46.tar.gz
+8e42bbd59095bdb85162190d44e81f8293f081fba31000f2c30a6d14ccca648cfe7eac5f05610370ac1ac13c3857899b4d333bf741bf1d14fd59e866e8ae743a  android-tools-libselinux-6.0.1_r46.tar.gz
+90b263f2fcaeaf5c94864eb2d7505e229b641c5e9c048084a12c040c0a2ba77fab6da5a3528182332f3bc591909dff13f918d79ef3d4275e74a9d2bf6622b524  android-tools-f2fs-tools-6.0.1_r46.tar.gz
+38e5ce4bfc0305585b1071b52c5d2e47927adc24318abdc466c9eed53ad6ed4fa83b6c1342db51d3a62b76996d2649632012d73c340eaf8b131ac6023248c59a  fix-build.patch
+d6ab3595d1f77f4baea03d828cc03291cb08e7787ebd653faac4776a2d27ff899f0746516f52c8b533dd104f9e9a1fcede59936de3146f7b8e8955101dacd889  fix-getcwd.patch
+421596678ab767d4bf59c54878e82a4faa0e3b5a070803ea37b5ee3c8cd41972d2d8ae46d081ee54a0d5b24874c893f32ad2aae7426090632f8c6099a241030b  generate-build.rb"
diff --git a/testing/android-tools/Makefile b/testing/android-tools/Makefile
deleted file mode 100644
index 679df34..0000000
--- a/testing/android-tools/Makefile
+++ /dev/null
@@ -1,110 +0,0 @@
-all: mkbootimg fastboot adb mksdcard
-
-install:
-	install -m755 -d $(DESTDIR)/usr/bin
-	install -m755 -t $(DESTDIR)/usr/bin mkbootimg fastboot adb mksdcard
-
-clean:
-	rm -f **/*.o
-
-.PHONY: clean
-
-
-
-
-MKBOOTIMG_SRCS += $(wildcard core/libmincrypt/*.c)
-MKBOOTIMG_SRCS += core/mkbootimg/mkbootimg.c
-
-MKBOOTIMG_CFLAGS += -Icore/include
-
-mkbootimg: $(MKBOOTIMG_SRCS)
-	$(CC) -o $@ $(CFLAGS) $(MKBOOTIMG_CFLAGS) $(LDFLAGS) $(MKBOOTIMG_LIBS) $(MKBOOTIMG_SRCS)
-
-
-
-
-ADB_SRCS += core/adb/adb.c
-ADB_SRCS += core/adb/adb_auth_host.c
-ADB_SRCS += core/adb/adb_client.c
-ADB_SRCS += core/adb/commandline.c
-ADB_SRCS += core/adb/console.c
-ADB_SRCS += core/adb/fdevent.c
-ADB_SRCS += core/adb/file_sync_client.c
-ADB_SRCS += core/adb/get_my_path_linux.c
-ADB_SRCS += core/adb/services.c
-ADB_SRCS += core/adb/sockets.c
-ADB_SRCS += core/adb/transport.c
-ADB_SRCS += core/adb/transport_local.c
-ADB_SRCS += core/adb/transport_usb.c
-ADB_SRCS += core/adb/usb_linux.c
-ADB_SRCS += core/adb/usb_vendors.c
-ADB_SRCS += core/libcutils/load_file.c
-ADB_SRCS += core/libcutils/socket_inaddr_any_server.c
-ADB_SRCS += core/libcutils/socket_local_client.c
-ADB_SRCS += core/libcutils/socket_local_server.c
-ADB_SRCS += core/libcutils/socket_loopback_client.c
-ADB_SRCS += core/libcutils/socket_loopback_server.c
-ADB_SRCS += core/libcutils/socket_network_client.c
-ADB_SRCS += core/libzipfile/centraldir.c
-ADB_SRCS += core/libzipfile/zipfile.c
-
-ADB_CFLAGS  += -DADB_HOST=1 -DHAVE_FORKEXEC=1 -DHAVE_OFF64_T=1 -DHAVE_TERMIO_H -I core/include -I core/adb
-ADB_LIBS += -lcrypto -lpthread -lz
-
-adb: $(ADB_SRCS)
-	$(CC) -o $@ $(CFLAGS) $(ADB_CFLAGS) $(LDFLAGS) $(ADB_SRCS) $(ADB_LIBS)
-
-
-
-FASTBOOT_SRCS += core/fastboot/bootimg.c
-FASTBOOT_SRCS += core/fastboot/engine.c
-FASTBOOT_SRCS += core/fastboot/fastboot.c
-FASTBOOT_SRCS += core/fastboot/protocol.c
-FASTBOOT_SRCS += core/fastboot/usb_linux.c
-FASTBOOT_SRCS += core/fastboot/util_linux.c
-FASTBOOT_SRCS += core/fastboot/util.c
-FASTBOOT_SRCS += core/fastboot/fs.c
-FASTBOOT_SRCS += core/libsparse/backed_block.c
-FASTBOOT_SRCS += core/libsparse/output_file.c
-FASTBOOT_SRCS += core/libsparse/sparse.c
-FASTBOOT_SRCS += core/libsparse/sparse_crc32.c
-FASTBOOT_SRCS += core/libsparse/sparse_err.c
-FASTBOOT_SRCS += core/libsparse/sparse_read.c
-FASTBOOT_SRCS += core/libzipfile/centraldir.c
-FASTBOOT_SRCS += core/libzipfile/zipfile.c
-FASTBOOT_SRCS += extras/ext4_utils/allocate.c
-FASTBOOT_SRCS += extras/ext4_utils/contents.c
-FASTBOOT_SRCS += extras/ext4_utils/crc16.c
-FASTBOOT_SRCS += extras/ext4_utils/ext4_utils.c
-FASTBOOT_SRCS += extras/ext4_utils/ext4_sb.c
-FASTBOOT_SRCS += extras/ext4_utils/extent.c
-FASTBOOT_SRCS += extras/ext4_utils/indirect.c
-FASTBOOT_SRCS += extras/ext4_utils/make_ext4fs.c
-FASTBOOT_SRCS += extras/ext4_utils/sha1.c
-FASTBOOT_SRCS += extras/ext4_utils/uuid.c
-FASTBOOT_SRCS += extras/ext4_utils/wipe.c
-FASTBOOT_SRCS += extras/f2fs_utils/f2fs_utils.c
-FASTBOOT_SRCS += extras/f2fs_utils/f2fs_dlutils.c
-FASTBOOT_SRCS += extras/f2fs_utils/f2fs_ioutils.c
-FASTBOOT_SRCS += libselinux/src/callbacks.c
-FASTBOOT_SRCS += libselinux/src/check_context.c
-FASTBOOT_SRCS += libselinux/src/freecon.c
-FASTBOOT_SRCS += libselinux/src/init.c
-FASTBOOT_SRCS += libselinux/src/label.c
-FASTBOOT_SRCS += libselinux/src/label_android_property.c
-FASTBOOT_SRCS += libselinux/src/label_file.c
-
-FASTBOOT_CFLAGS  += -DHAVE_OFF64_T=1 -std=gnu99 -I core/mkbootimg -I core/libsparse/include -I core/include -I extras/ext4_utils -I extras/f2fs_utils -I libselinux/include -I f2fs-tools/include -I f2fs-tools/mkfs
-FASTBOOT_LIBS += -lz -ldl -lpcre
-
-fastboot: $(FASTBOOT_SRCS)
-	$(CC) -o $@ $(CFLAGS) $(FASTBOOT_CFLAGS) $(LDFLAGS) $(FASTBOOT_SRCS) $(FASTBOOT_LIBS)
-
-
-MKSDCARD_SRCS += $(wildcard  sdk/emulator/mksdcard/src/source/*.c)
-
-mksdcard: $(MKSDCARD_SRCS)
-	$(CC) -o $@ $(CFLAGS) $(MKSDCARD_CFLAGS) $(LDFLAGS) $(MKSDCARD_SRCS) $(MKSDCARD_LIBS)
-
-
-
diff --git a/testing/android-tools/fix-build.patch b/testing/android-tools/fix-build.patch
new file mode 100644
index 0000000..d86ad54
--- /dev/null
+++ b/testing/android-tools/fix-build.patch
@@ -0,0 +1,69 @@
+--- a/core/base/file.cpp
++++ b/core/base/file.cpp
+@@ -20,6 +20,7 @@
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
++#include <string.h>
+ 
+ #include <string>
+ 
+--- a/core/liblog/log_read.c
++++ b/core/liblog/log_read.c
+@@ -26,6 +26,7 @@
+ #include <string.h>
+ #include <sys/cdefs.h>
+ #include <unistd.h>
++#include <sys/user.h>
+ 
+ #include <cutils/list.h>
+ #include <cutils/sockets.h>
+
+--- a/libselinux/src/label_internal.h
++++ b/libselinux/src/label_internal.h
+@@ -10,6 +10,7 @@
+ 
+ #include <stdlib.h>
+ #include <stdarg.h>
++#include <stdbool.h>
+ #include <selinux/selinux.h>
+ #include <selinux/label.h>
+ #include "dso.h"
+diff -upr core.orig/include/utils/Compat.h core/include/utils/Compat.h
+--- a/core/include/utils/Compat.h	2016-07-10 15:30:25.935363345 +0200
++++ b/core/include/utils/Compat.h	2016-07-10 15:31:01.785149166 +0200
+@@ -35,10 +35,11 @@ static inline ssize_t pread64(int fd, vo
+ 
+ #endif /* __APPLE__ */
+ 
++#define DEFFILEMODE 0666
++
+ #if defined(_WIN32)
+ #define O_CLOEXEC O_NOINHERIT
+ #define O_NOFOLLOW 0
+-#define DEFFILEMODE 0666
+ #endif /* _WIN32 */
+ 
+ #if defined(_WIN32)
+diff -upr core/adb/adb_auth_host.cpp core.orig/adb/adb_auth_host.cpp
+--- a/core/adb/adb_auth_host.cpp	2016-04-22 04:11:37.000000000 +0200
++++ b/core/adb/adb_auth_host.cpp	2016-07-10 20:28:54.553727489 +0200
+@@ -46,6 +46,7 @@
+ #include <base/strings.h>
+ #include <cutils/list.h>
+ 
++#include <openssl/bn.h>
+ #include <openssl/evp.h>
+ #include <openssl/objects.h>
+ #include <openssl/pem.h>
+diff -upr core.orig/include/ziparchive/zip_archive.h core/include/ziparchive/zip_archive.h
+--- a/core/include/ziparchive/zip_archive.h	2016-07-10 20:41:30.509065561 +0200
++++ b/core/include/ziparchive/zip_archive.h	2016-07-10 20:41:47.117424874 +0200
+@@ -23,6 +23,7 @@
+ #include <stdint.h>
+ #include <string.h>
+ #include <sys/types.h>
++#include <sys/cdefs.h>
+ #include <utils/Compat.h>
+ 
+ __BEGIN_DECLS
diff --git a/testing/android-tools/fix-getcwd.patch b/testing/android-tools/fix-getcwd.patch
new file mode 100644
index 0000000..d96ab42
--- /dev/null
+++ b/testing/android-tools/fix-getcwd.patch
@@ -0,0 +1,36 @@
+diff -upr core.orig/adb/adb_utils.cpp core/adb/adb_utils.cpp
+--- a/core.orig/adb/adb_utils.cpp	2016-07-10 15:17:54.889682995 +0200
++++ b/core/adb/adb_utils.cpp	2016-07-10 15:18:04.338747965 +0200
+@@ -30,7 +30,7 @@
+ #include "adb_trace.h"
+ #include "sysdeps.h"
+ 
+-bool getcwd(std::string* s) {
++bool agetcwd(std::string* s) {
+   char* cwd = getcwd(nullptr, 0);
+   if (cwd != nullptr) *s = cwd;
+   free(cwd);
+diff -upr core.orig/adb/commandline.cpp core/adb/commandline.cpp
+--- a/core.orig/adb/commandline.cpp	2016-07-10 15:17:54.889682995 +0200
++++ b/core/adb/commandline.cpp	2016-07-10 15:18:11.671355701 +0200
+@@ -863,7 +863,7 @@ static std::string find_product_out_path
+     // make it absolute.
+     if (adb_dirstart(hint) != nullptr) {
+         std::string cwd;
+-        if (!getcwd(&cwd)) {
++        if (!agetcwd(&cwd)) {
+             fprintf(stderr, "adb: getcwd failed: %s\n", strerror(errno));
+             return "";
+         }
+diff -upr core.orig/adb/adb_utils.h core/adb/adb_utils.h
+--- a/core.orig/adb/adb_utils.h	2016-07-10 15:21:09.327109127 +0200
++++ b/core/adb/adb_utils.h	2016-07-10 15:21:18.272890564 +0200
+@@ -19,7 +19,7 @@
+ 
+ #include <string>
+ 
+-bool getcwd(std::string* cwd);
++bool agetcwd(std::string* cwd);
+ bool directory_exists(const std::string& path);
+ 
+ std::string escape_arg(const std::string& s);
diff --git a/testing/android-tools/generate-build.rb b/testing/android-tools/generate-build.rb
new file mode 100644
index 0000000..448b23d
--- /dev/null
+++ b/testing/android-tools/generate-build.rb
@@ -0,0 +1,172 @@
+#!/usr/bin/ruby
+# Copied from the archlinux android-tools PKGBUILD.
+
+# 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 = 'gcc'
+        lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS'
+    when '.cpp', '.cc'
+        cc = 'g++'
+        lang_flags = '-std=gnu++11 $CXXFLAGS $CPPFLAGS'
+    else
+        raise "Unknown extension #{ext}"
+    end
+
+    output = s + '.o'
+    outputs << output
+    puts "#{cc} -o #{output} #{lang_flags} #{cflags} -c #{s}\n"
+  end
+
+  return outputs
+end
+
+# Links object files
+def link(output, objects, ldflags)
+  puts "g++ -o #{output} #{objects.join(' ')} #{ldflags} $LDFLAGS"
+end
+
+minicryptfiles = %w(
+  dsa_sig.c
+  p256_ec.c
+  rsa.c
+  sha.c
+  p256.c
+  p256_ecdsa.c
+  sha256.c
+)
+libminicrypt = compile(expand('core/libmincrypt', minicryptfiles), '-Icore/include')
+libmkbootimg = compile(['core/mkbootimg/mkbootimg.c'], '-Icore/include')
+link('mkbootimg', libminicrypt + libmkbootimg, nil)
+
+
+adbdfiles = %w(
+  adb.cpp
+  adb_auth.cpp
+  adb_io.cpp
+  adb_listeners.cpp
+  adb_utils.cpp
+  sockets.cpp
+  transport.cpp
+  transport_local.cpp
+  transport_usb.cpp
+
+  fdevent.cpp
+  get_my_path_linux.cpp
+  usb_linux.cpp
+
+  adb_auth_host.cpp
+)
+libadbd = compile(expand('core/adb', adbdfiles), '-DADB_HOST=1 -fpermissive -Icore/include -Icore/base/include')
+
+adbfiles = %w(
+  adb_main.cpp
+  console.cpp
+  commandline.cpp
+  adb_client.cpp
+  services.cpp
+  file_sync_client.cpp
+)
+libadb = compile(expand('core/adb', adbfiles), '-DADB_REVISION=\"$PKGVER\" -D_GNU_SOURCE -DADB_HOST=1 -DWORKAROUND_BUG6558362 -fpermissive -Icore/include -Icore/base/include')
+
+basefiles = %w(
+  file.cpp
+  stringprintf.cpp
+  strings.cpp
+)
+libbase = compile(expand('core/base', basefiles), '-DADB_HOST=1 -Icore/base/include -Icore/include')
+
+logfiles = %w(
+  logd_write.c
+  log_event_write.c
+  fake_log_device.c
+)
+liblog = compile(expand('core/liblog', logfiles), '-DLIBLOG_LOG_TAG=1005 -DFAKE_LOG_DEVICE=1 -D_GNU_SOURCE -Icore/log/include -Icore/include')
+
+cutilsfiles = %w(
+  load_file.c
+  socket_inaddr_any_server.c
+  socket_local_client.c
+  socket_local_server.c
+  socket_loopback_client.c
+  socket_loopback_server.c
+  socket_network_client.c
+)
+libcutils = compile(expand('core/libcutils', cutilsfiles), '-D_GNU_SOURCE -Icore/include')
+
+link('adb', libbase + liblog + libcutils + libadbd + libadb, '-lrt -ldl -lpthread -lssl -lcrypto')
+
+
+fastbootfiles = %w(
+  protocol.c
+  engine.c
+  bootimg_utils.cpp
+  fastboot.cpp
+  util.c
+  fs.c
+  usb_linux.c
+  util_linux.c
+)
+libfastboot = compile(expand('core/fastboot', fastbootfiles), '-DFASTBOOT_REVISION=\"$PKGVER\" -D_GNU_SOURCE -Icore/include -Icore/libsparse/include -Icore/mkbootimg -Iextras/ext4_utils -Iextras/f2fs_utils')
+
+sparsefiles = %w(
+  backed_block.c
+  output_file.c
+  sparse.c
+  sparse_crc32.c
+  sparse_err.c
+  sparse_read.c
+)
+libsparse = compile(expand('core/libsparse', sparsefiles), '-Icore/libsparse/include')
+
+zipfiles = %w(
+  zip_archive.cc
+)
+libzip = compile(expand('core/libziparchive', zipfiles), '-Icore/base/include -Icore/include')
+
+utilfiles = %w(
+  FileMap.cpp
+)
+libutil = compile(expand('core/libutils', utilfiles), '-Icore/include')
+
+ext4files = %w(
+  make_ext4fs.c
+  ext4fixup.c
+  ext4_utils.c
+  allocate.c
+  contents.c
+  extent.c
+  indirect.c
+  sha1.c
+  wipe.c
+  crc16.c
+  ext4_sb.c
+)
+libext4 = compile(expand('extras/ext4_utils', ext4files), '-Icore/libsparse/include -Icore/include -Ilibselinux/include')
+
+selinuxfiles = %w(
+  src/callbacks.c
+  src/check_context.c
+  src/freecon.c
+  src/init.c
+  src/label.c
+  src/label_file.c
+  src/label_android_property.c
+)
+libselinux = compile(expand('libselinux', selinuxfiles), '-DAUDITD_LOG_TAG=1003 -D_GNU_SOURCE -DHOST -Ilibselinux/include')
+
+link('fastboot', libsparse + libzip + liblog + libutil + libbase + libext4 + libselinux + libfastboot, '-lz -lpcre')
diff --git a/testing/android-tools/qemu-musl-native64.patch b/testing/android-tools/qemu-musl-native64.patch
deleted file mode 100644
index 1733281..0000000
--- a/testing/android-tools/qemu-musl-native64.patch
+++ /dev/null
@@ -1,120 +0,0 @@
-diff --git a/Makefile.android b/Makefile.android
-index 600be7c..4ca77b8 100644
---- a/Makefile.android
-+++ b/Makefile.android
-@@ -236,7 +236,7 @@ start-emulator-library = \
-     $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \
-     $(eval LOCAL_MODULE := $1) \
-     $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES) \
--    $(eval LOCAL_MODULE_BITS := 32)
-+    $(eval LOCAL_MODULE_BITS := 64)
- 
- start-emulator64-library = \
-     $(call start-emulator-library, $1) \
-@@ -286,11 +286,9 @@ LOCAL_LDLIBS := \
- 
- # Ensure only one of -m32 or -m64 is being used and place it first.
- LOCAL_CFLAGS := \
--    -m$$(LOCAL_MODULE_BITS) \
-     $$(filter-out -m32 -m64, $$(LOCAL_CFLAGS))
- 
- LOCAL_LDFLAGS := \
--    -m$$(LOCAL_MODULE_BITS) \
-     $$(filter-out -m32 -m64, $$(LOCAL_LDFLAGS))
- 
- endef
-@@ -399,7 +397,7 @@ endif
- 
- $(call end-emulator-program)
- 
--include $(LOCAL_PATH)/Makefile.tests
-+#include $(LOCAL_PATH)/Makefile.tests
- 
- ##############################################################################
- ##############################################################################
-diff --git a/Makefile.target b/Makefile.target
-index e68de28..cb14321 100644
---- a/Makefile.target
-+++ b/Makefile.target
-@@ -164,7 +164,8 @@ common_LOCAL_SRC_FILES += \
- ##############################################################################
- # CPU-specific emulation.
- #
--common_LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare
-+#common_LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare
-+common_LOCAL_CFLAGS += -fomit-frame-pointer -Wno-sign-compare
- 
- ifeq ($(HOST_ARCH),ppc)
-     common_LOCAL_CFLAGS += -D__powerpc__
-diff --git a/android-configure.sh b/android-configure.sh
-index 42fe51d..a248c97 100755
---- a/android-configure.sh
-+++ b/android-configure.sh
-@@ -143,7 +143,7 @@ fi
- 
- # By default, generate 32-bit binaries, the Makefile have targets that
- # generate 64-bit ones by using -m64 on the command-line.
--force_32bit_binaries
-+#force_32bit_binaries
- 
- case $OS in
-     linux-*)
-diff --git a/android/config/linux-x86_64/SDL_config.h b/android/config/linux-x86_64/SDL_config.h
-index 529beb0..ba3dbed 100644
---- a/android/config/linux-x86_64/SDL_config.h
-+++ b/android/config/linux-x86_64/SDL_config.h
-@@ -105,7 +105,7 @@
- 
- /* Enable various threading systems */
- #define SDL_THREAD_PTHREAD 1
--#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
-+#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
- 
- /* Enable various timer systems */
- #define SDL_TIMER_UNIX 1
-diff --git a/android/emulation/CpuAccelerator.cpp b/android/emulation/CpuAccelerator.cpp
-index be0175e..d79ba99 100644
---- a/android/emulation/CpuAccelerator.cpp
-+++ b/android/emulation/CpuAccelerator.cpp
-@@ -74,6 +74,15 @@ GlobalState gGlobals = { false, false, CPU_ACCELERATOR_NONE, { '\0' } };
- /////////////////////////////////////////////////////////////////////////
- 
- #if HAVE_KVM
-+#ifndef TEMP_FAILURE_RETRY
-+#define TEMP_FAILURE_RETRY(exp) ({         \
-+    typeof (exp) _rc;                      \
-+    do {                                   \
-+        _rc = (exp);                       \
-+    } while (_rc == ((typeof (exp)) -1) && errno == EINTR); \
-+    _rc; })
-+#endif
-+
- 
- #include <linux/kvm.h>
- 
-diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h b/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
-index f9c7df3..56ce2c8 100644
---- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
-+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
-@@ -175,7 +175,7 @@ SDL_X11_SYM(Bool,XShmQueryExtension,(Display* a),(a),return)
-  */
- #ifdef LONG64
- SDL_X11_MODULE(IO_32BIT)
--SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
-+//SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
- SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
- #endif
- 
-diff --git a/target-i386/kvm-gs-restore.c b/target-i386/kvm-gs-restore.c
-index 2ca6ab6..04db82e 100644
---- a/target-i386/kvm-gs-restore.c
-+++ b/target-i386/kvm-gs-restore.c
-@@ -35,7 +35,7 @@ static void check_and_restore_gs(void)
- struct sigact_status
- {
-     unsigned int sigaction:1;
--    __sighandler_t old_handler;
-+    sighandler_t old_handler;
-     void (*old_sigaction) (int, siginfo_t *, void *);
- };
- static struct sigact_status o_sigact[SIGUNUSED];
-- 
2.9.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---