I have been trying to get the su binary included in the /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.
I managed to resolve the issue that I mentioned. The following are the 2 ways I solved the issue but I faced another issue explained in the "Issue Faced" heading.
*Note: I put the su binary file in prebuilts/su
I modified the device.mk file in the device/
directory. I added the following to the file.
PRODUCT_COPY_FILES += \
prebuilts/su/su:system/xbin
I modified the device.mk file in the device/
directory. I added the following to the file.
PRODUCT_PACKAGES += \
su
I then added and insert the following to the Android.mk
file in prebuilts/su/su
.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := su
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_UNSTRIPPED_PATH := $(LOCAL_MODULE_PATH)
include $(BUILD_PREBUILT)
I am unable to chmod the su binary file after it has been copied to the system/xbin
directory. I have tried a few ways as follows but yielded no result.
I added the following right after the lines in Solution 1 and it keeps giving me the error of chmod ... file cannot be found
.
$(shell chmod 6755 out/<product>/system/xbin/su)
I added the following in Solution 2 Android.mk file before the include $(BUILD_PREBUILT)
line but none changes the permission of the file.
#Trial 1.
SU_BINARY := $(LOCAL_MODULE_PATH)/su
$(SU_BINARY)-post: su
$(shell chmod 6755 $(LOCAL_MODULE_PATH)/su)
#Trial 2 without "-post".
SU_BINARY := $(LOCAL_MODULE_PATH)/su
$(SU_BINARY): su
$(shell chmod 6755 $(LOCAL_MODULE_PATH)/su)
#Trial 3.
SU_BINARY := $(LOCAL_MODULE_PATH)/su
$(SU_BINARY): su
chmod 6755 $(LOCAL_MODULE_PATH)/su
Could someone please advice on how to chmod
the file? Thank you for your time.
Change the permission of the file first chmod 6755 prebuilts/su/su
. Include the following in the device.mk file in the device/
directory.
PRODUCT_COPY_FILES += \
prebuilts/su/su:system/xbin
Just add the following to the Android.mk file before include $(BUILD_PREBUILT)
LOCAL_POST_INSTALL_CMD := chmod 6755 $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With