[PATCH 07/20] kernel: copy all built kernel modules to root filesystem image

Elliott Mitchell ehem+openwrt at m5p.com
Fri Nov 10 16:21:22 PST 2023


This removes the requirement for to create a package for all modules.
Now devices can simply specify in-tree drivers/other to be built as
modules and they will be present in the resultant image.

Signed-off-by: Elliott Mitchell <ehem+openwrt at m5p.com>
---
I'm pretty sure this is the right general approach.  Why build
modules and simply dump them in the garbage.  I have an odd suspicion
a particular sort of adjustment will be requested.  Issue there is
the OpenWRT use of Make is quite something, I'm unsure about which
timestamp files to use.
---
 include/kernel-defaults.mk | 2 ++
 include/kernel.mk          | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index 05ec9afe09..0b421d2cc3 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -151,6 +151,8 @@ define Kernel/CompileImage/Default
 	rm -f $(TARGET_DIR)/init
 	+$(KERNEL_MAKE) $(KERNEL_MAKEOPTS_IMAGE) $(if $(KERNELNAME),$(KERNELNAME),all)
 	$(call Kernel/CopyImage)
+	+$(KERNEL_MAKE) $(KERNEL_MAKEOPTS_IMAGE) modules
+	find $(LINUX_DIR) -name \*.ko -a -links 1 -print0 | xargs -0 -r cp -lf -t $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
 endef
 
 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
diff --git a/include/kernel.mk b/include/kernel.mk
index 8236416132..82d87e8491 100644
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -247,7 +247,7 @@ $(call KernelPackage/$(1)/config)
 				echo "NOTICE: module '$$$$$$$$mod' is built-in."; \
 			elif [ -e $$$$$$$$mod ]; then \
 				mkdir -p $$(1)/$(MODULES_SUBDIR) ; \
-				$(CP) -L $$$$$$$$mod $$(1)/$(MODULES_SUBDIR)/ ; \
+				$(CP) -L -l $$$$$$$$mod $$(1)/$(MODULES_SUBDIR)/ ; \
 			else \
 				echo "ERROR: module '$$$$$$$$mod' is missing." >&2; \
 				exit 1; \
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+openwrt at m5p.com     PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445






More information about the openwrt-devel mailing list