I have been trying to get the su binary included in the <android_source_root>/out/.../system/xbin/su after building Android from source. I have the su binary (from Chainfire) as an executable file but I can't seem to get it included in the AOSP build.
All the examples or solutions I've came across discussed about the following in the android_source_root:
system/extras/ and include the su-binary directory (taken from ChainsDD) in external/.system/extras/su/Android.mk with "LOCAL_MODULE_TAGS := optional" and the file build/target/product/core.mk to include su in the PRODUCT_PACKAGES.All of those have the su.c, su.h and other files in the su directory that are used to build the su package.
What I would like to know is how to include su in the AOSP build when I have the "su binary executable file" only without the need to include the su.c or any of those files? Where should I put the su directory and what is the content of the Android.mk file?
Please advice and thank you for your time.
PRODUCT_COPY_FILES += \
prebuilts/su/su:system/xbin
$(shell chmod 6755 <destination_path_to_out_system>/xbin/su)
PRODUCT_PACKAGES += \
su
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := su
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_UNSTRIPPED_PATH := $(LOCAL_MODULE_PATH)
###->Inserted chmod command here. Ways I've tried are listed below.
include $(BUILD_PREBUILT)
SU_BINARY := $(LOCAL_MODULE_PATH)/su
$(SU_BINARY)-post: su
chmod 6755 $(LOCAL_MODULE_PATH)/su
SU_BINARY := $(LOCAL_MODULE_PATH)/su
$(SU_BINARY)-post: su
$(shell chmod 6755 $(LOCAL_MODULE_PATH)/su)
PRODUCT_COPY_FILES += prebuilts/su/su:system/xbin/su
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := suLOCAL_SRC_FILES := $(LOCAL_MODULE)LOCAL_MODULE_TAGS := optionalLOCAL_MODULE_CLASS := EXECUTABLESLOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)LOCAL_UNSTRIPPED_PATH :=
LOCAL_POST_INSTALL_CMD := chmod 6755 $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(LOCAL_MODULE)include $(BUILD_PREBUILT)