[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230717104100.6146-1-msuchanek@suse.de>
Date: Mon, 17 Jul 2023 12:40:58 +0200
From: Michal Suchanek <msuchanek@...e.de>
To: linux-modules@...r.kernel.org
Cc: Michal Suchanek <msuchanek@...e.de>, Takashi Iwai <tiwai@...e.com>,
Lucas De Marchi <lucas.de.marchi@...il.com>,
Michal Koutný <mkoutny@...e.com>,
Jiri Slaby <jslaby@...e.com>, Jan Engelhardt <jengelh@...i.de>,
Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nicolas Schier <nicolas@...sle.eu>,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v4] depmod: Handle installing modules under a prefix
Some distributions aim at shipping all files in /usr.
The path under which kernel modules are installed is hardcoded to /lib
which conflicts with this goal.
When kmod provides the config command, use it to determine the correct
module installation path.
With kmod that does not provide the config command /lib/modules is used
as before.
Signed-off-by: Michal Suchanek <msuchanek@...e.de>
---
v2: Avoid error on systems with kmod that does not support config
command
v3: More verbose commit message
v4:
- Document jq requirement
- fix bashism
- Update to getting full module path, not just additional prefix
---
Documentation/process/changes.rst | 15 +++++++++++++++
Makefile | 4 +++-
scripts/depmod.sh | 8 ++++----
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
index 5561dae94f85..f96a867ab85f 100644
--- a/Documentation/process/changes.rst
+++ b/Documentation/process/changes.rst
@@ -41,6 +41,7 @@ bison 2.0 bison --version
pahole 1.16 pahole --version
util-linux 2.10o fdformat --version
kmod 13 depmod -V
+jq any jq --version
e2fsprogs 1.41.4 e2fsck -V
jfsutils 1.1.3 fsck.jfs -V
reiserfsprogs 3.6.3 reiserfsck -V
@@ -176,6 +177,15 @@ You will need openssl to build kernels 3.7 and higher if module signing is
enabled. You will also need openssl development packages to build kernels 4.3
and higher.
+
+Kmod
+----
+
+``depmod`` is needed for building modular kernels. ``jq`` is additionally needed
+when support for installing modules outside of the default location
+``/lib/modules`` is required. Missing ``jq`` will result in an error message
+during build even if the tool is not needed.
+
Tar
---
@@ -463,6 +473,11 @@ Kmod
- <https://www.kernel.org/pub/linux/utils/kernel/kmod/>
- <https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git>
+jq
+--
+
+- <https://github.com/jqlang/jq/tags>
+
Ksymoops
--------
diff --git a/Makefile b/Makefile
index 47690c28456a..5eb04baaac58 100644
--- a/Makefile
+++ b/Makefile
@@ -1165,7 +1165,9 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
# makefile but the argument can be passed to make if needed.
#
-MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
+export KERNEL_MODULE_DIRECTORY := $(shell kmod config >/dev/null 2>&1 && kmod config | jq -r .module_directory || echo /lib/modules)
+
+MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE)
export MODLIB
PHONY += prepare0
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 3643b4f896ed..06961f990fcb 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -27,16 +27,16 @@ fi
# numbers, so we cheat with a symlink here
depmod_hack_needed=true
tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
-mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
+mkdir -p "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE"
if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
- if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
- -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
+ if test -e "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE/modules.dep" -o \
+ -e "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE/modules.dep.bin"; then
depmod_hack_needed=false
fi
fi
rm -rf "$tmp_dir"
if $depmod_hack_needed; then
- symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
+ symlink="$INSTALL_MOD_PATH$KERNEL_MODULE_DIRECTORY/99.98.$KERNELRELEASE"
ln -s "$KERNELRELEASE" "$symlink"
KERNELRELEASE=99.98.$KERNELRELEASE
fi
--
2.41.0
Powered by blists - more mailing lists