From 6af36a4f37b06a54db28bed6cbb6dd4467489a88 Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Tue, 23 Apr 2019 20:05:28 -0400 Subject: bsd dd: include prebuilt bsd dd in twrp for Nougat and greater - Cleaned up toolbox/Android.mk so that BSD dd builds with correct Android versions Change-Id: Idb15811480ec03b05336d54b866233b5ac99dfaf --- prebuilt/Android.mk | 3 +++ toolbox/Android.mk | 38 +++++++++++++++++++++++++++++++++++--- toybox/Android.mk | 3 +-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index e0e9dbcd7..05e750a53 100644 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -27,6 +27,9 @@ else if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep" ]; then \ rm $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep; fi; ln -sr $(TARGET_RECOVERY_ROOT_OUT)/sbin/grep $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep; RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/toybox + ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0) + RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dd + endif ifneq ($(wildcard external/zip/Android.mk),) RELINK_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/zip endif diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 7d1b60251..6698491b3 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -43,8 +43,7 @@ endif ifeq ($(TW_USE_TOOLBOX), true) ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) # These are the only toolbox tools in M. The rest are now in toybox. - BSD_TOOLS := \ - $(if $(filter $(PLATFORM_SDK_VERSION), 23 24), du) + BSD_TOOLS := OUR_TOOLS := \ newfs_msdos @@ -60,9 +59,10 @@ ifeq ($(TW_USE_TOOLBOX), true) stop endif - ifneq (,$(filter $(PLATFORM_SDK_VERSION), 23)) + ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) BSD_TOOLS += \ dd \ + du \ OUR_TOOLS += \ df \ @@ -165,6 +165,7 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0) OUR_TOOLS += getevent LOCAL_C_INCLUDES += $(TWRP_TOOLBOX_PATH) LOCAL_WHOLE_STATIC_LIBRARIES += libtoolbox_dd + ifneq ($(TW_USE_TOOLBOX), true) OUR_TOOLS += newfs_msdos endif @@ -288,6 +289,37 @@ $(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ $(TOOLS_H): $(transform-generated-source) + +ifeq ($(TW_USE_TOOLBOX), true) + ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0) + include $(CLEAR_VARS) + LOCAL_MODULE := dd_twrp + LOCAL_MODULE_STEM := dd + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_MODULE_TAGS := optional + LOCAL_CFLAGS := -include bsd-compatibility.h -DNO_CONV -Wno-unused-parameter + LOCAL_C_INCLUDES := system/core/toolbox/upstream-netbsd/include/ system/core/toolbox/upstream-netbsd/bin/dd system/core/toolbox + + LOCAL_SHARED_LIBRARIES := \ + libcutils \ + + LOCAL_SRC_FILES += \ + upstream-netbsd/bin/dd/args.c \ + upstream-netbsd/bin/dd/conv.c \ + upstream-netbsd/bin/dd/dd.c \ + upstream-netbsd/bin/dd/dd_hostops.c \ + upstream-netbsd/bin/dd/misc.c \ + upstream-netbsd/bin/dd/position.c \ + upstream-netbsd/lib/libc/gen/getbsize.c \ + upstream-netbsd/lib/libc/gen/humanize_number.c \ + upstream-netbsd/lib/libc/stdlib/strsuftoll.c \ + upstream-netbsd/lib/libc/string/swab.c \ + upstream-netbsd/lib/libutil/raise_default_signal.c + + include $(BUILD_EXECUTABLE) + endif +endif + # toolbox setenforce is used during init in non-symlink form, so it was # required to be included as part of the suite above. if busybox already # provides setenforce, we can omit the toolbox symlink diff --git a/toybox/Android.mk b/toybox/Android.mk index c21a27235..5f6edec3f 100644 --- a/toybox/Android.mk +++ b/toybox/Android.mk @@ -485,7 +485,6 @@ ALL_TOOLS += \ arp \ base64 \ chattr \ - dd \ df \ diff \ flock \ @@ -547,7 +546,7 @@ ALL_TOOLS += \ gzip \ gunzip \ zcat -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0) +ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0) ALL_TOOLS += \ fmt \ start \ -- cgit v1.2.3