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
Solution 1
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
Solution 2
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)
Issue faced
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.
Issues Resolved
Solution 1 (for Issue 1)
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
Solution 2 (for Issue 2)
Just add the following to the Android.mk file before include $(BUILD_PREBUILT)
LOCAL_POST_INSTALL_CMD := chmod 6755 $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)