Michal Suchanek 8a9c42
From bb1a83cf109eee56c8dee26f7910c772f8c246fc Mon Sep 17 00:00:00 2001
Michal Suchanek 457deb
From: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek 457deb
Date: Thu, 29 Jun 2023 17:47:16 +0200
Michal Suchanek b2abe8
Subject: [PATCH] depmod: Handle installing modules under a prefix
Michal Suchanek 457deb
Michal Suchanek 457deb
References: bsc#1212835
Michal Suchanek ec1f87
Patch-mainline: Never, upstream rejected
Michal Suchanek 457deb
Michal Suchanek ec1f87
Some distributions aim at shipping all files in /usr.
Michal Suchanek 457deb
Michal Suchanek ec1f87
The path under which kernel modules are installed is hardcoded to /lib
Michal Suchanek b2abe8
which conflicts with this goal.
Michal Suchanek b2abe8
Michal Suchanek ec1f87
When kmod provides the config command, use it to determine the correct
Michal Suchanek ec1f87
module installation path.
Michal Suchanek b2abe8
Michal Suchanek ec1f87
With kmod that does not provide the config command /lib/modules is used
Michal Suchanek ec1f87
as before.
Michal Suchanek ec1f87
Michal Suchanek ec1f87
Note: users can use
Michal Suchanek ec1f87
Michal Suchanek ec1f87
make MODLIB='$(INSTALL_MOD_PATH)/usr/lib/modules/$(KERNELRELEASE)'
Michal Suchanek ec1f87
Michal Suchanek ec1f87
to install modules from mainline kernel on usrmerged system.
Michal Suchanek ec1f87
Not great for KMPs, though
Michal Suchanek 457deb
Michal Suchanek 457deb
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek ec1f87
Nacked-by: Masahiro Yamada <masahiroy@kernel.org>
Michal Suchanek ec1f87
---
Michal Suchanek ec1f87
v2: Avoid error on systems with kmod that does not support config
Michal Suchanek ec1f87
command
Michal Suchanek ec1f87
v3: More verbose commit message
Michal Suchanek ec1f87
v4:
Michal Suchanek ec1f87
  - Document jq requirement
Michal Suchanek ec1f87
  - fix bashism
Michal Suchanek ec1f87
  - Update to getting full module path, not just additional prefix
Michal Suchanek ec1f87
v5: switch to pkgconfig
Michal Suchanek 457deb
---
Michal Suchanek 8a9c42
 Makefile | 4 +++-
Michal Suchanek 8a9c42
 1 file changed, 3 insertions(+), 1 deletion(-)
Michal Suchanek 457deb
Michal Suchanek 457deb
diff --git a/Makefile b/Makefile
Michal Suchanek ec1f87
index 658ec2b8aa74..5a1889fc43c7 100644
Michal Suchanek 457deb
--- a/Makefile
Michal Suchanek 457deb
+++ b/Makefile
Michal Suchanek b2abe8
@@ -1165,7 +1165,9 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
Michal Suchanek 457deb
 # makefile but the argument can be passed to make if needed.
Michal Suchanek 457deb
 #
Michal Suchanek 457deb
 
Michal Suchanek 457deb
-MODLIB	= $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
Michal Suchanek ec1f87
+export KERNEL_MODULE_DIRECTORY := $(shell pkg-config --print-variables kmod 2>/dev/null | grep '^module_directory$$' >/dev/null && pkg-config --variable=module_directory kmod || echo /lib/modules)
Michal Suchanek ea6269
+
Michal Suchanek ec1f87
+MODLIB	= $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE)
Michal Suchanek 457deb
 export MODLIB
Michal Suchanek 457deb
 
Michal Suchanek 457deb
 PHONY += prepare0
Michal Suchanek 457deb
-- 
Michal Suchanek 457deb
2.41.0
Michal Suchanek 457deb