Android:在AOSP版本中包含su二进制可执行文件 [英] Android: Include su binary executable in AOSP build
问题描述
从源代码构建Android之后,我一直试图将su二进制文件包含在/out/.../system/xbin/su中.我将su二进制文件(来自Chainfire)作为可执行文件,但似乎无法将其包含在AOSP版本中.
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.
我遇到的所有示例或解决方案都在Android_Source_Root中讨论了以下内容:
All the examples or solutions I've came across discussed about the following in the Android_Source_Root:
- 从
system/extras/
中删除su目录,并将su-binary目录(取自ChainsDD)包含在external/中. - 使用" LOCAL_MODULE_TAGS:=可选"修改文件
system/extras/su/Android.mk
,并将文件build/target/product/core.mk
修改为在PRODUCT_PACKAGES中包含su.
- Removing the su directory from
system/extras/
and include the su-binary directory (taken from ChainsDD) in external/. - Modify the file
system/extras/su/Android.mk
with "LOCAL_MODULE_TAGS := optional" and the filebuild/target/product/core.mk
to include su in the PRODUCT_PACKAGES.
所有这些文件都在su目录中包含su.c,su.h和其他文件,这些文件用于构建su软件包.
All of those have the su.c, su.h and other files in the su directory that are used to build the su package.
我想知道的是,当我只有"su二进制可执行文件"而无需包括su.c或任何这些文件时,如何将su包含在AOSP构建中?我应该把su目录放在哪里,Android.mk文件的内容是什么?
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.
*注意:我将su二进制文件放入了prebuilts/su
*Note: I put the su binary file in prebuilts/su
我修改了device/
目录中的device.mk文件.我在文件中添加了以下内容.
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
解决方案2
我修改了device/
目录中的device.mk文件.我在文件中添加了以下内容.
Solution 2
I modified the device.mk file in the device/
directory. I added the following to the file.
PRODUCT_PACKAGES += \
su
然后我添加了以下内容并将其插入到prebuilts/su/su
中的Android.mk
文件中.
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)
面临的问题
将su二进制文件复制到system/xbin
目录后,我无法对其进行chmod设置.我尝试了以下几种方法,但没有结果.
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.
-
我在解决方案1 中的各行之后添加了以下内容,它始终为我提供
chmod ... file cannot be found
的错误.
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)
我在解决方案2 Android.mk文件中的include $(BUILD_PREBUILT)
行之前添加了以下内容,但没有一个更改文件的权限.
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
有人可以建议如何chmod
文件吗?谢谢您的时间.
Could someone please advice on how to chmod
the file? Thank you for your time.
首先更改文件的权限chmod 6755 prebuilts/su/su
.在device/
目录的device.mk文件中包括以下内容.
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
解决方案2(针对问题2)
只需将以下内容添加到include $(BUILD_PREBUILT)
LOCAL_POST_INSTALL_CMD := chmod 6755 $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)
这篇关于Android:在AOSP版本中包含su二进制可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!