From 6c7e02e74e047bbbb9901c8d86e45cd638abc87f Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Sun, 4 Apr 2021 21:30:48 +0800 Subject: [PATCH] Support installing modules.options file Usage: ``` BOARD_(VENDOR|VENDOR_RAMDISK)_KERNEL_MODULES_OPTIONS_FILE(_ver) := \ $(wildcard ) ``` Then the modules.options would be installed as (vendor_dlkm|vendor_ramdisk)/lib/modules/(ver/)modules.options. Also fix bug where the kernel version subdir is missing when generating modules.blocklists file. Bug: 182417593 Bug: 184238876 Test: Create a options file with incorrect syntax, verify build fails Test: Verify the new macro indeed installs the options file Change-Id: I7ba56e9dd8d73055bc276446c385a8d79080c2a6 --- core/Makefile | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index 7975d3a66c..1a7008e7c7 100644 --- a/core/Makefile +++ b/core/Makefile @@ -315,14 +315,34 @@ $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2) @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@) endef +# $(1): source options file +# $(2): destination pathname +# Returns a build rule that checks the syntax of and installs a kernel modules +# options file. Strip and squeeze any extra space and blank lines. +# For use via $(eval). +define build-image-kernel-modules-options-file +$(2): $(1) + @echo "libmodprobe options $$(@)" + $(hide) mkdir -p "$$(dir $$@)" + $(hide) rm -f "$$@" + $(hide) awk <"$$<" >"$$@" \ + '/^#/ { print; next } \ + NF == 0 { next } \ + NF < 2 || $$$$1 != "options" \ + { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \ + exit_status = 1; next } \ + { $$$$1 = $$$$1; print } \ + END { exit exit_status }' +endef + # $(1): source blocklist file # $(2): destination pathname # Returns a build rule that checks the syntax of and installs a kernel modules -# blocklist file. Strip and squeeze any extra space in the blocklist. +# blocklist file. Strip and squeeze any extra space and blank lines. # For use via $(eval). define build-image-kernel-modules-blocklist-file $(2): $(1) - @echo "modprobe blocklist $$(@)" + @echo "libmodprobe blocklist $$(@)" $(hide) mkdir -p "$$(dir $$@)" $(hide) rm -f "$$@" $(hide) awk <"$$<" >"$$@" \ @@ -352,11 +372,19 @@ $(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODU $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\ $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \ $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver)))) \ +$(if $(_kver), \ + $(eval _dir := $(_kver)/), \ + $(eval _dir :=)) \ +$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \ + $(eval $(call build-image-kernel-modules-options-file, \ + $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \ + $(2)/lib/modules/$(_dir)modules.options)) \ + $(2)/lib/modules/$(_dir)modules.options) \ $(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \ $(eval $(call build-image-kernel-modules-blocklist-file, \ $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \ - $(2)/lib/modules/modules.blocklist)) \ - $(2)/lib/modules/modules.blocklist) + $(2)/lib/modules/$(_dir)modules.blocklist)) \ + $(2)/lib/modules/$(_dir)modules.blocklist) endef # $(1): kernel module directory name (top is an out of band value for no directory)