我对su-binary(https://github.com/git-core/su-binary)做了一些小改动,添加了一个目标来设置SUID。 我使用的Android.mk:http://pastebin.com/N0gMJT4u 在Android源代码树的根目录下运行make时,运行正常:
$ make -j5
[...]
system/core/rootdir/Android.mk:42: warning: ignoring old commands for target `out/target/product/panda/root/init.rc'
echo "Setting SUID/GUID to su-binary"
Setting SUID/GUID to su-binary
Installing busybox
chmod ug+s out/target/product/panda/system/xbin/su
[...]
在external / su-binary中运行mm -B
时:http://pastebin.com/8HmUJBA0
mmm external/su-binary
根据https://groups.google.com/forum/#!msg/android-building/dtNZFj5pe1w/PRY2MXADXG4J
除了Ying Wang建议的“make name-of-module”之外,你可以 在目录中运行“mm”以构建(和安装)所有已定义的模块 那里。但是,这将构建仅那些模块,任何依赖 模块将不构建。因此,它仅对增量有用 现有树的构建,您可以跟踪依赖关系。
试过:
$ rm out/target/product/panda/system/xbin/su
$ make external/su-binary
[...]
make: Nothing to be done for `external/su-binary'.
$ rm out/target/product/panda/obj/EXECUTABLES/su_intermediates/su
$ make external/su-binary
[...]
make: Nothing to be done for `external/su-binary`.
模块依赖如何在Android中运行?
答案 0 :(得分:4)
好的,我通过更改Android.mk来运行它:
$(SU_BINARY)
目标,即$(SU_BINARY)-post
。更好,因为之前它与LOCAL_MODULE
和BUILD_EXECUTABLE
组合定义的目标具有相同的名称。include $(BUILD_EXECUTABLE)
看起来像:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := su
LOCAL_SRC_FILES := su.c db.c activity.cpp
SU_SHARED_LIBRARIES := liblog libsqlite
ifeq ($(PLATFORM_SDK_VERSION),4)
LOCAL_CFLAGS += -DSU_LEGACY_BUILD
SU_SHARED_LIBRARIES += libandroid_runtime
else
SU_SHARED_LIBRARIES += libcutils libbinder libutils
LOCAL_MODULE_TAGS := eng
endif
LOCAL_C_INCLUDES += external/sqlite/dist
LOCAL_SHARED_LIBRARIES := $(SU_SHARED_LIBRARIES)
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
SU_INSTALL_DIR := $(TARGET_OUT)/xbin
SU_BINARY := $(SU_INSTALL_DIR)/su
# taken from busybox-android
$(SU_BINARY)-post: su
@echo "Setting SUID/GUID to su-binary..."
chmod ug+s $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su
ln -sf $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su $(TARGET_OUT_EXECUTABLES)/su
ALL_DEFAULT_INSTALLED_MODULES += $(SU_BINARY)-post
include $(BUILD_EXECUTABLE)
ALL_DEFAULT_INSTALLED_MODULES
是我认为安装模块后很晚才出现的规则。但我必须深入研究这是否是我想在这里做的最佳解决方案。