Message ID | 32b332af189bfca8acdb231cee294355aa4af290.1701892062.git.msuchanek@suse.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4340003vqy; Wed, 6 Dec 2023 11:48:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2uXmSe2JHsud4W3WkiaykwESqg4W2Qvye/8Rn2EH1G8DD3LDru6LeuyU57iHjBj9La5+v X-Received: by 2002:a17:90a:d315:b0:286:6cc0:886b with SMTP id p21-20020a17090ad31500b002866cc0886bmr1192218pju.88.1701892094831; Wed, 06 Dec 2023 11:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701892094; cv=none; d=google.com; s=arc-20160816; b=p+ca30GIGmnpTcqmTjbNPxar2D0TMIoA2bASCuLIP1TAeFEzmj2GEtm1LvwUwTt87i DEBivS4ogOboS82UFm7/l5xcH08GNKODlVRuoeer8o+OnnliRpYRmP+cp0ll8y5282k0 o57lXbyGNLGEL5LwCRSPLTBmyGo5kDDzfT3d5yKpAOrQIIjRuJEWa0fdc/RWRMeykYTg /bE7h0Gm/aRE9Dhv2ati07GN4i3d9y+yrb5v2X6tAEODcmDMhUFDg8NQOQx04qhEKVYF Vlghqa5mRDlLk/McxCOx2Cpvg2lAIxm+1SZFXWI5c16p5McBRMGGirM1gw+YoWkkr85x kuaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=ov8zefNWK8DeiwA8wNVUU354vvSd05uhQtoU+uecmDY=; fh=kEv7l62vJ3XIkrK43m8eV/ZlyXa9griX1gawn6N+7MU=; b=vDW/rO8UsDUzoAH5k1ut2DzNFfhVD1AOmPwChlryAU66xvOkin6KDuU+uZPY3T+Zmm TQ4mxTj0IiaiMDgSVoBOciOrRBMIdrzH63f7twLIsF0/iMmBHjxLjAg2Bb3zztkfbWiI Paqe0EBf9NN8YOi6xLEbuIwMi45h9iUvuUxhlW/o/5Wg6gzULEM1KxJRoiw0HbNuqx3P McqV1cwSpEiKL1MlQV7PVTI0HijjFVlp2zS1slcIDEOU2KHFs/L4xu+moN85ZR5ZqwCn s1xJnPtBejZtdQKjXPXoCvUssBnWa+XljazpfXefmqHvg/Pf28fuJhJAdpE5Ia1g3qOB mZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vxde8W9L; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="N/kQZ0uf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z91-20020a17090a6d6400b002802d12083fsi286180pjj.54.2023.12.06.11.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 11:48:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Vxde8W9L; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="N/kQZ0uf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A76A78027163; Wed, 6 Dec 2023 11:48:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379412AbjLFTsB (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 14:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379439AbjLFTr7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 14:47:59 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17DC122; Wed, 6 Dec 2023 11:48:04 -0800 (PST) Received: from kitsune.suse.cz (unknown [10.100.12.127]) by smtp-out2.suse.de (Postfix) with ESMTP id 5D17F1FD37; Wed, 6 Dec 2023 19:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701892082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ov8zefNWK8DeiwA8wNVUU354vvSd05uhQtoU+uecmDY=; b=Vxde8W9L32OvzV66naFp5LegxWVnktfLOQxSU4r2/FXOT34vlgbTXtHpxOWhAmLK+B/73L XR7cyCG/NfI/yekcCSh6V7DvfjtfTOZFjGmrc8rJNA3nTr1Mhz5atOsuYiqOU5VArTjIZ2 puZSYGGMG1lLHqUnVgttqtciGYmgU9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701892082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ov8zefNWK8DeiwA8wNVUU354vvSd05uhQtoU+uecmDY=; b=N/kQZ0ufcHLHHyNCe4PUoNU9JEE5asxwqf4vJAwKHJ8E6geEd+ueA8Yt5ZuVaK/+qC5uLv e8D7K+euUDf37vCA== From: Michal Suchanek <msuchanek@suse.de> To: linux-modules@vger.kernel.org Cc: Michal Suchanek <msuchanek@suse.de>, Takashi Iwai <tiwai@suse.com>, Lucas De Marchi <lucas.de.marchi@gmail.com>, =?utf-8?q?Michal_Koutn=C3=BD?= <mkoutny@suse.com>, Jiri Slaby <jslaby@suse.com>, Jan Engelhardt <jengelh@inai.de>, Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/2] depmod: Handle installing modules under a different directory Date: Wed, 6 Dec 2023 20:47:51 +0100 Message-ID: <32b332af189bfca8acdb231cee294355aa4af290.1701892062.git.msuchanek@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <CAK7LNAT3N82cJD3GsF+yUBEfPNOBkhzYPk37q3k0HdU7ukz9vQ@mail.gmail.com> References: <CAK7LNAT3N82cJD3GsF+yUBEfPNOBkhzYPk37q3k0HdU7ukz9vQ@mail.gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 5.20 X-Spamd-Result: default: False [5.20 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; RCPT_COUNT_TWELVE(0.00)[13]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[suse.de,suse.com,gmail.com,inai.de,kernel.org,google.com,fjasle.eu,vger.kernel.org]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 11:48:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784563204879380074 X-GMAIL-MSGID: 1784563204879380074 |
Series |
[v6,1/2] depmod: Handle installing modules under a different directory
|
|
Commit Message
Michal Suchánek
Dec. 6, 2023, 7:47 p.m. UTC
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 kmod.pc, use it to determine the correct module
installation path.
With kmod that does not provide the config /lib/modules is used as
before.
While pkg-config does not return an error when a variable does not exist
the kmod configure script puts some effort into ensuring that
module_directory is non-empty. With that empty module_directory from
pkg-config can be used to detect absence of the variable.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
v6:
- use ?= instead of := to make it easier to override the value
- use shorter expression for determining the module directory assuming
it's non-empty
---
Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > 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 kmod.pc, use it to determine the correct module > installation path. > > With kmod that does not provide the config /lib/modules is used as > before. > > While pkg-config does not return an error when a variable does not exist > the kmod configure script puts some effort into ensuring that > module_directory is non-empty. With that empty module_directory from > pkg-config can be used to detect absence of the variable. > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > v6: > - use ?= instead of := to make it easier to override the value "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" will override the install destination, but depmod will not be not aware of it. How to avoid the depmod error? > - use shorter expression for determining the module directory assuming > it's non-empty > --- > Makefile | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 511b5616aa41..84f32bd563d4 100644 > --- a/Makefile > +++ b/Makefile > @@ -1081,7 +1081,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 ?= $(or $(shell pkg-config --variable=module_directory kmod 2>/dev/null),/lib/modules) > + > +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > export MODLIB > > PHONY += prepare0 > -- > 2.42.0 > > -- Best Regards Masahiro Yamada
Masahiro Yamada wrote: > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: >> 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 kmod.pc, use it to determine the correct module >> installation path. >> >> With kmod that does not provide the config /lib/modules is used as >> before. >> >> While pkg-config does not return an error when a variable does not exist >> the kmod configure script puts some effort into ensuring that >> module_directory is non-empty. With that empty module_directory from >> pkg-config can be used to detect absence of the variable. >> >> Signed-off-by: Michal Suchanek <msuchanek@suse.de> >> --- >> v6: >> - use ?= instead of := to make it easier to override the value > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > will override the install destination, but > depmod will not be not aware of it. > > How to avoid the depmod error? > > I think the depmod -b option can be used to ran depmod in an arbitrary location: The following options are useful for people managing distributions: -b, --basedir=DIR Use an image of a module tree. Woody > > > > > > > > > > > >> - use shorter expression for determining the module directory assuming >> it's non-empty >> --- >> Makefile | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/Makefile b/Makefile >> index 511b5616aa41..84f32bd563d4 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -1081,7 +1081,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 ?= $(or $(shell pkg-config --variable=module_directory kmod 2>/dev/null),/lib/modules) >> + >> +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) >> export MODLIB >> >> PHONY += prepare0 >> -- >> 2.42.0 >> >> > > -- > Best Regards > Masahiro Yamada
Hello! On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > 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 kmod.pc, use it to determine the correct module > > installation path. > > > > With kmod that does not provide the config /lib/modules is used as > > before. > > > > While pkg-config does not return an error when a variable does not exist > > the kmod configure script puts some effort into ensuring that > > module_directory is non-empty. With that empty module_directory from > > pkg-config can be used to detect absence of the variable. > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > --- > > v6: > > - use ?= instead of := to make it easier to override the value > > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > will override the install destination, but > depmod will not be not aware of it. At the same time if you know what you are doing you can build a src rpm for another system that uses a different location. > How to avoid the depmod error? Not override the variable? Thanks Michal > > - use shorter expression for determining the module directory assuming > > it's non-empty > > --- > > Makefile | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/Makefile b/Makefile > > index 511b5616aa41..84f32bd563d4 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -1081,7 +1081,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 ?= $(or $(shell pkg-config --variable=module_directory kmod 2>/dev/null),/lib/modules) > > + > > +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > export MODLIB > > > > PHONY += prepare0 > > -- > > 2.42.0 > > > > > > > -- > Best Regards > Masahiro Yamada
On Mon, Dec 11, 2023 at 6:07 AM Michal Suchánek <msuchanek@suse.de> wrote: > > Hello! > > On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > 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 kmod.pc, use it to determine the correct module > > > installation path. > > > > > > With kmod that does not provide the config /lib/modules is used as > > > before. > > > > > > While pkg-config does not return an error when a variable does not exist > > > the kmod configure script puts some effort into ensuring that > > > module_directory is non-empty. With that empty module_directory from > > > pkg-config can be used to detect absence of the variable. > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > --- > > > v6: > > > - use ?= instead of := to make it easier to override the value > > > > > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > > will override the install destination, but > > depmod will not be not aware of it. > > At the same time if you know what you are doing you can build a src rpm > for another system that uses a different location. > > > How to avoid the depmod error? > > Not override the variable? You are not answering my question. You intentionally changed := to ?=. This implies that KERNEL_MODULE_DIRECTORY is an interface to users, and should be documented in Documentation/kbuild/kbuild.rst However, it never works if it is overridden from the env variable or make command line because there is no way to let depmod know the fact that KERNEL_MODULE_DIRECTORY has been overridden. In my understanding, depmod does not provide an option to specify the module directory from a command line option, does it? If not, is it reasonable to add a new option to depmod? depmod provides the "-b basedir" option, but it only allows adding a prefix to the default "/lib/modules/<version>". (My original idea to provide the prefix_part, it would have worked like -b "${INSTALL_MOD_PATH}${MOD_PREFIX}", which you refused) > Thanks > > Michal > > > > - use shorter expression for determining the module directory assuming > > > it's non-empty > > > --- > > > Makefile | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 511b5616aa41..84f32bd563d4 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -1081,7 +1081,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 ?= $(or $(shell pkg-config --variable=module_directory kmod 2>/dev/null),/lib/modules) > > > + > > > +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > > export MODLIB > > > > > > PHONY += prepare0 > > > -- > > > 2.42.0 > > > > > > > > > > > > -- > > Best Regards > > Masahiro Yamada >
On Mon, Dec 11, 2023 at 01:29:15PM +0900, Masahiro Yamada wrote: > On Mon, Dec 11, 2023 at 6:07 AM Michal Suchánek <msuchanek@suse.de> wrote: > > > > Hello! > > > > On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > > > 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 kmod.pc, use it to determine the correct module > > > > installation path. > > > > > > > > With kmod that does not provide the config /lib/modules is used as > > > > before. > > > > > > > > While pkg-config does not return an error when a variable does not exist > > > > the kmod configure script puts some effort into ensuring that > > > > module_directory is non-empty. With that empty module_directory from > > > > pkg-config can be used to detect absence of the variable. > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > > --- > > > > v6: > > > > - use ?= instead of := to make it easier to override the value > > > > > > > > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > > > will override the install destination, but > > > depmod will not be not aware of it. > > > > At the same time if you know what you are doing you can build a src rpm > > for another system that uses a different location. > > > > > How to avoid the depmod error? > > > > Not override the variable? > > You are not answering my question. > You intentionally changed := to ?=. > > This implies that KERNEL_MODULE_DIRECTORY is an interface to users, > and should be documented in Documentation/kbuild/kbuild.rst That's reasonable > However, it never works if it is overridden from the env variable > or make command line because there is no way to let depmod know > the fact that KERNEL_MODULE_DIRECTORY has been overridden. And there should not. kmod is not aware, kbuild is. That's the direction of information flow. kmod defines where it looks for the modules, and kbuild shoukld install the modules there. If the user knows better (eg. possibility of building src-rpm for a different you brought up) they can override the autodetection. > In my understanding, depmod does not provide an option to > specify the module directory from a command line option, does it? No it does not. > If not, is it reasonable to add a new option to depmod? I don't think so. The module directory is intentionally in a fixed location. It can be set at compile time, and that's it. Then when running depmod on the target distribution either kbuild and kmod agree on the location or the build fails. That's the intended outcome. kmod recently grew the ability to use modules outside of module directory. For that to work internally the path to these out-of-kernel modules is stored as absolute path, and the path of modules that are in the module directory is stored relative to the module directory. Setting the module directory location dynamically still should not break this but I am not sure it's a great idea. In the end modprobe needs to find those modules, and if depmod puts the modules.dep in arbitrary location it will not. > depmod provides the "-b basedir" option, but it only allows > adding a prefix to the default "/lib/modules/<version>". Yes, that's for installation into a staging directory, and there again the modules that are inside the module directory are considedred 'in-kernel'. Not sure how well this even works with 'out-of-kernel' modules. > (My original idea to provide the prefix_part, it would have worked > like -b "${INSTALL_MOD_PATH}${MOD_PREFIX}", which you refused) It's not clear that adding a prefix covers all use cases. It is an arbitrary limitation that the module path must end with '/lib/modules'. It may allow taking some shortcuts in some places but is unnecessarily limiting. Thanks Michal
On Tue, Dec 12, 2023 at 10:03 PM Michal Suchánek <msuchanek@suse.de> wrote: > > On Mon, Dec 11, 2023 at 01:29:15PM +0900, Masahiro Yamada wrote: > > On Mon, Dec 11, 2023 at 6:07 AM Michal Suchánek <msuchanek@suse.de> wrote: > > > > > > Hello! > > > > > > On Mon, Dec 11, 2023 at 03:43:44AM +0900, Masahiro Yamada wrote: > > > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > > > > > 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 kmod.pc, use it to determine the correct module > > > > > installation path. > > > > > > > > > > With kmod that does not provide the config /lib/modules is used as > > > > > before. > > > > > > > > > > While pkg-config does not return an error when a variable does not exist > > > > > the kmod configure script puts some effort into ensuring that > > > > > module_directory is non-empty. With that empty module_directory from > > > > > pkg-config can be used to detect absence of the variable. > > > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > > > --- > > > > > v6: > > > > > - use ?= instead of := to make it easier to override the value > > > > > > > > > > > > "KERNEL_MODULE_DIRECTORY=/local/usr/lib/modules make modules_install" > > > > will override the install destination, but > > > > depmod will not be not aware of it. > > > > > > At the same time if you know what you are doing you can build a src rpm > > > for another system that uses a different location. > > > > > > > How to avoid the depmod error? > > > > > > Not override the variable? > > > > You are not answering my question. > > You intentionally changed := to ?=. > > > > This implies that KERNEL_MODULE_DIRECTORY is an interface to users, > > and should be documented in Documentation/kbuild/kbuild.rst > > That's reasonable > > > However, it never works if it is overridden from the env variable > > or make command line because there is no way to let depmod know > > the fact that KERNEL_MODULE_DIRECTORY has been overridden. > > And there should not. kmod is not aware, kbuild is. That's the > direction of information flow. kmod defines where it looks for the > modules, and kbuild shoukld install the modules there. Then, you cannot explain why KERNEL_MODULE_DIRECTORY should be exposed as a user interface. The MODULE_DIRECTORY in depmod is determined when kmod is compiled. Kbuild takes KERNEL_MODULE_DIRECTORY from pkg-config. If these two do not agree, it never works. > If the user knows better (eg. possibility of building src-rpm for a > different you brought up) they can override the autodetection. No, it does not work. The user has no way to override the MODULE_DIRECTORY in depmod. > > In my understanding, depmod does not provide an option to > > specify the module directory from a command line option, does it? > > No it does not. > > > If not, is it reasonable to add a new option to depmod? > > I don't think so. The module directory is intentionally in a fixed > location. It can be set at compile time, and that's it. > > Then when running depmod on the target distribution either kbuild and > kmod agree on the location or the build fails. That's the intended > outcome. > > kmod recently grew the ability to use modules outside of module > directory. For that to work internally the path to these out-of-kernel > modules is stored as absolute path, and the path of modules that are in > the module directory is stored relative to the module directory. > > Setting the module directory location dynamically still should not break > this but I am not sure it's a great idea. In the end modprobe needs to > find those modules, and if depmod puts the modules.dep in arbitrary > location it will not. That is true when modules are compiled and installed on the local machine. If you create an SRPM with KERNEL_MODULE_DIRECTORY, builders must follow it. > > > depmod provides the "-b basedir" option, but it only allows > > adding a prefix to the default "/lib/modules/<version>". > > Yes, that's for installation into a staging directory, and there again > the modules that are inside the module directory are considedred > 'in-kernel'. Not sure how well this even works with 'out-of-kernel' > modules. > > > (My original idea to provide the prefix_part, it would have worked > > like -b "${INSTALL_MOD_PATH}${MOD_PREFIX}", which you refused) > > It's not clear that adding a prefix covers all use cases. It is an > arbitrary limitation that the module path must end with '/lib/modules'. > > It may allow taking some shortcuts in some places but is unnecessarily > limiting. > > Thanks > > Michal
diff --git a/Makefile b/Makefile index 511b5616aa41..84f32bd563d4 100644 --- a/Makefile +++ b/Makefile @@ -1081,7 +1081,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 ?= $(or $(shell pkg-config --variable=module_directory kmod 2>/dev/null),/lib/modules) + +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) export MODLIB PHONY += prepare0