Android:在AOSP版本中包含su二进制可执行文件 [英] Android: Include su binary executable in AOSP build

查看:747
本文介绍了Android:在AOSP版本中包含su二进制可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从源代码构建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:

  1. system/extras/中删除su目录,并将su-binary目录(取自ChainsDD)包含在external/中.
  2. 使用" LOCAL_MODULE_TAGS:=可选"修改文件system/extras/su/Android.mk,并将文件build/target/product/core.mk修改为在PRODUCT_PACKAGES中包含su.
  1. Removing the su directory from system/extras/ and include the su-binary directory (taken from ChainsDD) in external/.
  2. Modify the file 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.

所有这些文件都在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. 我在解决方案1 ​​中的各行之后添加了以下内容,它始终为我提供chmod ... file cannot be found的错误.

  1. 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆