common: DLKM: update module sign file to support 4.4 kernel

In 4.4 kernel, module sign file gets built as a host executable.
To enable signing the modules on 4.4 kernel, sign file used while
signing DLKMs needs to be updated.

CRs-Fixed: 1018761
Change-Id: I1c4229f4fcf0db0982e9889168b76111e85d3ccd
This commit is contained in:
Satya Durga Srinivasu Prabhala 2016-06-28 18:13:31 -07:00
parent 18a9c3586e
commit 3219130413
1 changed files with 20 additions and 12 deletions

View File

@ -70,11 +70,30 @@ ifneq "$(LOCAL_MODULE_KBUILD_NAME)" ""
mv -f $(kbuild_out) $@ mv -f $(kbuild_out) $@
endif endif
# To ensure KERNEL_OUT and TARGET_PREBUILT_INT_KERNEL are defined,
# kernel/AndroidKernel.mk must be included. While m and regular
# make builds will include kernel/AndroidKernel.mk, mm and mmm builds
# do not. Therefore, we need to explicitly include kernel/AndroidKernel.mk.
# It is safe to include it more than once because the entire file is
# guarded by "ifeq ($(TARGET_PREBUILT_KERNEL),) ... endif".
TARGET_KERNEL_PATH := $(TARGET_KERNEL_SOURCE)/AndroidKernel.mk
include $(TARGET_KERNEL_PATH)
# Simply copy the kernel module from where the kernel build system # Simply copy the kernel module from where the kernel build system
# created it to the location where the Android build system expects it. # created it to the location where the Android build system expects it.
# If LOCAL_MODULE_DEBUG_ENABLE is set, strip debug symbols. So that, # If LOCAL_MODULE_DEBUG_ENABLE is set, strip debug symbols. So that,
# the final images generated by ABS will have the stripped version of # the final images generated by ABS will have the stripped version of
# the modules # the modules
ifeq ($(TARGET_KERNEL_VERSION),3.18)
MODULE_SIGN_FILE := perl ./$(TARGET_KERNEL_SOURCE)/scripts/sign-file
MODSECKEY := $(KERNEL_OUT)/signing_key.priv
MODPUBKEY := $(KERNEL_OUT)/signing_key.x509
else
MODULE_SIGN_FILE := $(KERNEL_OUT)/scripts/sign-file
MODSECKEY := $(KERNEL_OUT)/certs/signing_key.pem
MODPUBKEY := $(KERNEL_OUT)/certs/signing_key.x509
endif
$(LOCAL_BUILT_MODULE): $(KBUILD_MODULE) | $(ACP) $(LOCAL_BUILT_MODULE): $(KBUILD_MODULE) | $(ACP)
ifneq "$(LOCAL_MODULE_DEBUG_ENABLE)" "" ifneq "$(LOCAL_MODULE_DEBUG_ENABLE)" ""
mkdir -p $(dir $@) mkdir -p $(dir $@)
@ -87,10 +106,8 @@ endif
KMOD_SIG_HASH=`cat $(KERNEL_OUT)/.config | grep CONFIG_MODULE_SIG_HASH | cut -d'=' -f2 | sed 's/\"//g'`; \ KMOD_SIG_HASH=`cat $(KERNEL_OUT)/.config | grep CONFIG_MODULE_SIG_HASH | cut -d'=' -f2 | sed 's/\"//g'`; \
if [ \"\$$KMOD_SIG_ALL\" = \"y\" ] && [ -n \"\$$KMOD_SIG_HASH\" ]; then \ if [ \"\$$KMOD_SIG_ALL\" = \"y\" ] && [ -n \"\$$KMOD_SIG_HASH\" ]; then \
echo \"Signing kernel module: \" `basename $<`; \ echo \"Signing kernel module: \" `basename $<`; \
MODSECKEY=$(KERNEL_OUT)/signing_key.priv; \
MODPUBKEY=$(KERNEL_OUT)/signing_key.x509; \
cp $< $<.unsigned; \ cp $< $<.unsigned; \
perl ./$(TARGET_KERNEL_SOURCE)/scripts/sign-file \$$KMOD_SIG_HASH \$$MODSECKEY \$$MODPUBKEY $<; \ $(MODULE_SIGN_FILE) \$$KMOD_SIG_HASH $(MODSECKEY) $(MODPUBKEY) $<; \
fi; \ fi; \
" "
$(transform-prebuilt-to-target) $(transform-prebuilt-to-target)
@ -111,15 +128,6 @@ $(cleantarget): PRIVATE_CLEAN_FILES := $(PRIVATE_CLEAN_FILES) $(KBUILD_OUT_DIR)
ifndef $(KBUILD_TARGET)_RULE ifndef $(KBUILD_TARGET)_RULE
$(KBUILD_TARGET)_RULE := 1 $(KBUILD_TARGET)_RULE := 1
# To ensure KERNEL_OUT and TARGET_PREBUILT_INT_KERNEL are defined,
# kernel/AndroidKernel.mk must be included. While m and regular
# make builds will include kernel/AndroidKernel.mk, mm and mmm builds
# do not. Therefore, we need to explicitly include kernel/AndroidKernel.mk.
# It is safe to include it more than once because the entire file is
# guarded by "ifeq ($(TARGET_PREBUILT_KERNEL),) ... endif".
TARGET_KERNEL_PATH := $(TARGET_KERNEL_SOURCE)/AndroidKernel.mk
include $(TARGET_KERNEL_PATH)
# Kernel modules have to be built after: # Kernel modules have to be built after:
# * the kernel config has been created # * the kernel config has been created
# * host executables, like scripts/basic/fixdep, have been built # * host executables, like scripts/basic/fixdep, have been built