Android: include su binary executable in AOSP assembly
I'm trying to get the su binar included in /out/.../system/xbin/su after you've built Android from source. I have su binary (from Chainfire) as executable, but I cannot include it in the AOSP build.
All examples or solutions I came across have been discussed in Android_Source_Root:
- Removing the su directory from
system/extras/
and including the su-binary directory (taken from ChainsDD) in external /. - Change the file
system/extras/su/Android.mk
to "LOCAL_MODULE_TAGS: = optional" and the filebuild/target/product/core.mk
to include su in PRODUCT_PACKAGES.
All of them have su.c, su.h and other files in the su directory which are used to build the su package.
I would like to know how to include su in an AOSP build when I have a "su executable", only without having to include su.c or any of those files? Where should I put the su directory and what is the content of the Android.mk file?
I ask for advice and thanks for your time.
source to share
I managed to solve the problem I was talking about. Below are two ways to solve the problem, but I ran into another problem described in the heading "A problem occurred".
* Note: I put the su binary in prebuilts / su
Solution 1
I changed the device.mk file in the directory device/
. I added the following to the file.
PRODUCT_COPY_FILES += \ prebuilts/su/su:system/xbin
Solution 2
I changed the device.mk file in the directory device/
. I added the following to the file.
PRODUCT_PACKAGES += \ su
Then I added and paste the following into the file Android.mk
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)
The problem arose
I cannot chmod su the binary after it has been copied to the directory system/xbin
. I have tried several ways as follows, but no result.
-
I added the following after the lines in Solution 1 and it keeps giving me an error
chmod ... file cannot be found
.$(shell chmod 6755 out/<product>/system/xbin/su)
-
I added the following to Solution 2 Android.mk file before the line
include $(BUILD_PREBUILT)
, but none of them changed the file permissions.#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
Can anyone consult the chmod
file for advice ? Thank you for your time.
Problems solved
Solution 1 (for issue 1)
First change the resolution of the file chmod 6755 prebuilts/su/su
. Include the following in the device.mk file in the directory device/
.
PRODUCT_COPY_FILES += \ prebuilts/su/su:system/xbin
Solution 2 (for issue 2)
Just add the following to your Android.mk file before include $(BUILD_PREBUILT)
LOCAL_POST_INSTALL_CMD := chmod 6755 $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)
source to share