Message ID | baa3224bece94220dfe7173432143a91f7612c09.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 r17csp4340038vqy; Wed, 6 Dec 2023 11:48:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVZC+9z2gUJPHNaXe6ZOawMqodxM3ZNqL7PU48FrFdOXWc8SMVuH2PoIo2p3iluN4QJbEp X-Received: by 2002:a05:6a20:8fa5:b0:18c:fa:17f7 with SMTP id k37-20020a056a208fa500b0018c00fa17f7mr1350280pzj.46.1701892100920; Wed, 06 Dec 2023 11:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701892100; cv=none; d=google.com; s=arc-20160816; b=SAPAQtk5MQ/IWpT+vKfZoCVwJwS27iDag7h2YzOdaX6+Ss0WheXSBbkj1levDtRfj+ +iql4rMIZMN3rWu0C8dAZYBR2y/LyO5TU3EUxJ/8X2MtWUnTYrTqEYYHRkL67z1WOgti vEL8uuhN9EL0gDO7Xr6F2HEZ8jF9fPA7vz9d7YAvetC+XguEVKn9j9ovqzebHqKLC1lj S4v+R5nSDwqzURp+zPgR1pyRa8sMPth1iKXQEYw7WbgZdPQUy5+9t4zyhcoOfxlJP3RR 6J9JGt946ojIde9b3zGtEExt5tQ0zA8Xf/MXKopwyf0koAIsrg/enIQ7vt1XIgaMu0hf qh6g== 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=WRWb+HJrZK0+DeQKF7G3lI1mi1x+bXsZpMkFr/DHwLo=; fh=kEv7l62vJ3XIkrK43m8eV/ZlyXa9griX1gawn6N+7MU=; b=bym+3DWn4M93YdOtotZJKQCKxqXIHPKPY0qtLr0BKd4J7PysEFWh3zgRtpG5N8yzxa mD+mSQBfa6vTbhEr2o5Av2LdV8UBWdV49/EGNg9MhZzH3QQfq/9K+BnkYnNGSOC+qpf1 6JEOfqG/eKJGAQPvJmhhoMmHqHdczw0X87Izr0MMN2hGNPzocpx3I3If9ZLAH4/AYae9 K7A8iZeQLkjsKrgmUg/11BaqZ4qXF1usNBbD3nzFDbEJep9x8rmOYQvSIfFmTF8v73vc 6c6m1SGgpfQk8uqhFgkWH7D+8BGTrEttr3rHseTcs9zf++2bm9FfREG0eVhHuKdVxK0l WhXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=x6K1kx8C; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=j+qDcBrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id fj13-20020a056a003a0d00b006cb75e1d713si411637pfb.193.2023.12.06.11.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 11:48:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=x6K1kx8C; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=j+qDcBrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id F260583B0098; Wed, 6 Dec 2023 11:48:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442813AbjLFTsD (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 14:48:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379438AbjLFTr7 (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 [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7720FD3; Wed, 6 Dec 2023 11:48:05 -0800 (PST) Received: from kitsune.suse.cz (unknown [10.100.12.127]) by smtp-out2.suse.de (Postfix) with ESMTP id D907D1FD38; Wed, 6 Dec 2023 19:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701892083; 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=WRWb+HJrZK0+DeQKF7G3lI1mi1x+bXsZpMkFr/DHwLo=; b=x6K1kx8CbsvgZuyz896cRajvdVXvkWeCINL7yDq/BxZUEe98u1JRDk1xb8PPi6uOWycEoL 90KJAuAYJ/uiPOnRnGZMeya5oQgwkMcu9HXgVUBAcwNyYHfIKnCbBUYryjaDUWAmyYknf6 kY5O9TBp88gAI+G4w++EdT8StxRCvp4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701892083; 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=WRWb+HJrZK0+DeQKF7G3lI1mi1x+bXsZpMkFr/DHwLo=; b=j+qDcBrV+ldOxKEIHrJohbeQHnGbUd0pXC1tKDZbmZYlmV2mQ9AHlrgMHFNSeMJojaUMfE CkypdC6TgBInaVCg== 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 2/2] kbuild: rpm-pkg: Fix build with non-default MODLIB Date: Wed, 6 Dec 2023 20:47:52 +0100 Message-ID: <baa3224bece94220dfe7173432143a91f7612c09.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 X-Spam-Score: 3.40 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [3.40 / 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)[]; R_RATELIMIT(0.00)[to_ip_from(RLbjsaozyn1c4dqqoh4tzemsye)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; 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]; BAYES_HAM(-3.00)[100.00%]; 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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 11:48:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778931326180938141 X-GMAIL-MSGID: 1784563211344077503 |
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
The default MODLIB value is composed of three variables
MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE)
However, the kernel.spec hadcodes the default value of
$(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when
building the package.
Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY
---
scripts/package/kernel.spec | 8 ++++----
scripts/package/mkspec | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
Comments
On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > The default MODLIB value is composed of three variables > > MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > However, the kernel.spec hadcodes the default value of > $(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when > building the package. > > Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem. > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY The SRPM package created by 'make srcrpm-pkg' may not work if rpmbuild is executed in a different machine. %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} KERNEL_MODULE_DIRECTORY=%{KERNEL_MODULE_DIRECTORY} modules_install will align with the specified install destination, but depmod will still fail. (same issue as 1/2) > --- > scripts/package/kernel.spec | 8 ++++---- > scripts/package/mkspec | 1 + > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec > index 3eee0143e0c5..12996ed365f8 100644 > --- a/scripts/package/kernel.spec > +++ b/scripts/package/kernel.spec > @@ -67,7 +67,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEA > %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install > cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} > cp .config %{buildroot}/boot/config-%{KERNELRELEASE} > -ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build > +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > %if %{with_devel} > %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' > %endif > @@ -98,8 +98,8 @@ fi > > %files > %defattr (-, root, root) > -/lib/modules/%{KERNELRELEASE} > -%exclude /lib/modules/%{KERNELRELEASE}/build > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE} > +%exclude %{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > /boot/* > > %files headers > @@ -110,5 +110,5 @@ fi > %files devel > %defattr (-, root, root) > /usr/src/kernels/%{KERNELRELEASE} > -/lib/modules/%{KERNELRELEASE}/build > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > %endif > diff --git a/scripts/package/mkspec b/scripts/package/mkspec > index ce201bfa8377..e952fa4f2937 100755 > --- a/scripts/package/mkspec > +++ b/scripts/package/mkspec > @@ -24,6 +24,7 @@ fi > cat<<EOF > %define ARCH ${ARCH} > %define KERNELRELEASE ${KERNELRELEASE} > +%define KERNEL_MODULE_DIRECTORY ${KERNEL_MODULE_DIRECTORY} > %define pkg_release $("${srctree}/init/build-version") > EOF > > -- > 2.42.0 > > -- Best Regards Masahiro Yamada
On Mon, Dec 11, 2023 at 03:44:35AM +0900, Masahiro Yamada wrote: > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > The default MODLIB value is composed of three variables > > > > MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > > > However, the kernel.spec hadcodes the default value of > > $(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when > > building the package. > > > > Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem. > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > --- > > Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY > > > The SRPM package created by 'make srcrpm-pkg' may not work > if rpmbuild is executed in a different machine. That's why there is an option to override KERNEL_MODULE_DIRECTORY? Thanks Michal > > > > %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} > KERNEL_MODULE_DIRECTORY=%{KERNEL_MODULE_DIRECTORY} modules_install > > > will align with the specified install destination, > but depmod will still fail. > (same issue as 1/2) > > > > > > > > > > > --- > > scripts/package/kernel.spec | 8 ++++---- > > scripts/package/mkspec | 1 + > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec > > index 3eee0143e0c5..12996ed365f8 100644 > > --- a/scripts/package/kernel.spec > > +++ b/scripts/package/kernel.spec > > @@ -67,7 +67,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEA > > %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install > > cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} > > cp .config %{buildroot}/boot/config-%{KERNELRELEASE} > > -ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build > > +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > %if %{with_devel} > > %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' > > %endif > > @@ -98,8 +98,8 @@ fi > > > > %files > > %defattr (-, root, root) > > -/lib/modules/%{KERNELRELEASE} > > -%exclude /lib/modules/%{KERNELRELEASE}/build > > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE} > > +%exclude %{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > /boot/* > > > > %files headers > > @@ -110,5 +110,5 @@ fi > > %files devel > > %defattr (-, root, root) > > /usr/src/kernels/%{KERNELRELEASE} > > -/lib/modules/%{KERNELRELEASE}/build > > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > %endif > > diff --git a/scripts/package/mkspec b/scripts/package/mkspec > > index ce201bfa8377..e952fa4f2937 100755 > > --- a/scripts/package/mkspec > > +++ b/scripts/package/mkspec > > @@ -24,6 +24,7 @@ fi > > cat<<EOF > > %define ARCH ${ARCH} > > %define KERNELRELEASE ${KERNELRELEASE} > > +%define KERNEL_MODULE_DIRECTORY ${KERNEL_MODULE_DIRECTORY} > > %define pkg_release $("${srctree}/init/build-version") > > EOF > > > > -- > > 2.42.0 > > > > > > > -- > Best Regards > Masahiro Yamada
On Mon, Dec 11, 2023 at 6:09 AM Michal Suchánek <msuchanek@suse.de> wrote: > > On Mon, Dec 11, 2023 at 03:44:35AM +0900, Masahiro Yamada wrote: > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > The default MODLIB value is composed of three variables > > > > > > MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > > > > > However, the kernel.spec hadcodes the default value of > > > $(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when > > > building the package. > > > > > > Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem. > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > --- > > > Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY > > > > > > The SRPM package created by 'make srcrpm-pkg' may not work > > if rpmbuild is executed in a different machine. > > That's why there is an option to override KERNEL_MODULE_DIRECTORY? Yes. But, as I pointed out in 1/2, depmod must follow the packager's decision. 'make srcrpm-pkg' creates a SRPM on machine A. 'rpmbuild' builds it into binary RPMs on machine B. If A and B disagree about kmod.pc, depmod will fail because there is no code to force the decision made on machine A. > Thanks > > Michal > > > > > > > > > %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} > > KERNEL_MODULE_DIRECTORY=%{KERNEL_MODULE_DIRECTORY} modules_install > > > > > > will align with the specified install destination, > > but depmod will still fail. > > (same issue as 1/2) > > > > > > > > > > > > > > > > > > > > > --- > > > scripts/package/kernel.spec | 8 ++++---- > > > scripts/package/mkspec | 1 + > > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec > > > index 3eee0143e0c5..12996ed365f8 100644 > > > --- a/scripts/package/kernel.spec > > > +++ b/scripts/package/kernel.spec > > > @@ -67,7 +67,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEA > > > %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install > > > cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} > > > cp .config %{buildroot}/boot/config-%{KERNELRELEASE} > > > -ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build > > > +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > > %if %{with_devel} > > > %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' > > > %endif > > > @@ -98,8 +98,8 @@ fi > > > > > > %files > > > %defattr (-, root, root) > > > -/lib/modules/%{KERNELRELEASE} > > > -%exclude /lib/modules/%{KERNELRELEASE}/build > > > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE} > > > +%exclude %{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > > /boot/* > > > > > > %files headers > > > @@ -110,5 +110,5 @@ fi > > > %files devel > > > %defattr (-, root, root) > > > /usr/src/kernels/%{KERNELRELEASE} > > > -/lib/modules/%{KERNELRELEASE}/build > > > +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build > > > %endif > > > diff --git a/scripts/package/mkspec b/scripts/package/mkspec > > > index ce201bfa8377..e952fa4f2937 100755 > > > --- a/scripts/package/mkspec > > > +++ b/scripts/package/mkspec > > > @@ -24,6 +24,7 @@ fi > > > cat<<EOF > > > %define ARCH ${ARCH} > > > %define KERNELRELEASE ${KERNELRELEASE} > > > +%define KERNEL_MODULE_DIRECTORY ${KERNEL_MODULE_DIRECTORY} > > > %define pkg_release $("${srctree}/init/build-version") > > > EOF > > > > > > -- > > > 2.42.0 > > > > > > > > > > > > -- > > Best Regards > > Masahiro Yamada -- Best Regards Masahiro Yamada
On Mon, Dec 11, 2023 at 01:33:23PM +0900, Masahiro Yamada wrote: > On Mon, Dec 11, 2023 at 6:09 AM Michal Suchánek <msuchanek@suse.de> wrote: > > > > On Mon, Dec 11, 2023 at 03:44:35AM +0900, Masahiro Yamada wrote: > > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > > > The default MODLIB value is composed of three variables > > > > > > > > MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > > > > > > > However, the kernel.spec hadcodes the default value of > > > > $(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when > > > > building the package. > > > > > > > > Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem. > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > > --- > > > > Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY > > > > > > > > > The SRPM package created by 'make srcrpm-pkg' may not work > > > if rpmbuild is executed in a different machine. > > > > That's why there is an option to override KERNEL_MODULE_DIRECTORY? > > > Yes. > But, as I pointed out in 1/2, depmod must follow the packager's decision. > > 'make srcrpm-pkg' creates a SRPM on machine A. > 'rpmbuild' builds it into binary RPMs on machine B. > > If A and B disagree about kmod.pc, depmod will fail > because there is no code to force the decision made > on machine A. There is. It's the ?= in the top Makefile. Currently the test that determines the module directory uses make logic so it's not possible to pass on the shell magic before executing it so it could be executed inside the rpm spec file as well. OUtsourcing it into an external script would mean that the sources need to be unpacked before the script can be executed. That would require using dynamically generated file list in the spec file because the module location would not be known at spec parse time. Possible but convoluted. In the end I do not think this is a problem that needs solving. Most distributions that build kernel packages would use their own packaging files, not rpm-pkg. That limits rpm-pkg to ad-hoc use when people want to build one-off test kernel. It's reasonable to do on the same distribution as the target system. The option to do so on a distribution with different module directory is available if somebody really needs that. Thanks Michal
On Tue, Dec 12, 2023 at 10:12 PM Michal Suchánek <msuchanek@suse.de> wrote: > > On Mon, Dec 11, 2023 at 01:33:23PM +0900, Masahiro Yamada wrote: > > On Mon, Dec 11, 2023 at 6:09 AM Michal Suchánek <msuchanek@suse.de> wrote: > > > > > > On Mon, Dec 11, 2023 at 03:44:35AM +0900, Masahiro Yamada wrote: > > > > On Thu, Dec 7, 2023 at 4:48 AM Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > > > > > The default MODLIB value is composed of three variables > > > > > > > > > > MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) > > > > > > > > > > However, the kernel.spec hadcodes the default value of > > > > > $(KERNEL_MODULE_DIRECTORY), and changed value is not reflected when > > > > > building the package. > > > > > > > > > > Pass KERNEL_MODULE_DIRECTORY to kernel.spec to fix this problem. > > > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > > > --- > > > > > Build on top of the previous patch adding KERNEL_MODULE_DIRECTORY > > > > > > > > > > > > The SRPM package created by 'make srcrpm-pkg' may not work > > > > if rpmbuild is executed in a different machine. > > > > > > That's why there is an option to override KERNEL_MODULE_DIRECTORY? > > > > > > Yes. > > But, as I pointed out in 1/2, depmod must follow the packager's decision. > > > > 'make srcrpm-pkg' creates a SRPM on machine A. > > 'rpmbuild' builds it into binary RPMs on machine B. > > > > If A and B disagree about kmod.pc, depmod will fail > > because there is no code to force the decision made > > on machine A. > > There is. It's the ?= in the top Makefile. Nope. Only Kbuild follows the specified KERNEL_MODULE_DIRECTORY. depmod still uses the MODULE_DRECTORY determined when it was compiled. > > Currently the test that determines the module directory uses make logic > so it's not possible to pass on the shell magic before executing it so > it could be executed inside the rpm spec file as well. > > OUtsourcing it into an external script would mean that the sources need > to be unpacked before the script can be executed. That would require > using dynamically generated file list in the spec file because the > module location would not be known at spec parse time. Possible but > convoluted. I do not require that. This is simple; builders must follow the packager's decision. To make it work, depmod must follow MODULE_DIRECTORY given from an external environment. > In the end I do not think this is a problem that needs solving. Most > distributions that build kernel packages would use their own packaging > files, not rpm-pkg. That limits rpm-pkg to ad-hoc use when people want > to build one-off test kernel. It's reasonable to do on the same > distribution as the target system. The option to do so on a distribution > with different module directory is available if somebody really needs > that. > > Thanks > > Michal
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec index 3eee0143e0c5..12996ed365f8 100644 --- a/scripts/package/kernel.spec +++ b/scripts/package/kernel.spec @@ -67,7 +67,7 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEA %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} cp .config %{buildroot}/boot/config-%{KERNELRELEASE} -ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build %if %{with_devel} %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' %endif @@ -98,8 +98,8 @@ fi %files %defattr (-, root, root) -/lib/modules/%{KERNELRELEASE} -%exclude /lib/modules/%{KERNELRELEASE}/build +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE} +%exclude %{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build /boot/* %files headers @@ -110,5 +110,5 @@ fi %files devel %defattr (-, root, root) /usr/src/kernels/%{KERNELRELEASE} -/lib/modules/%{KERNELRELEASE}/build +%{KERNEL_MODULE_DIRECTORY}/%{KERNELRELEASE}/build %endif diff --git a/scripts/package/mkspec b/scripts/package/mkspec index ce201bfa8377..e952fa4f2937 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -24,6 +24,7 @@ fi cat<<EOF %define ARCH ${ARCH} %define KERNELRELEASE ${KERNELRELEASE} +%define KERNEL_MODULE_DIRECTORY ${KERNEL_MODULE_DIRECTORY} %define pkg_release $("${srctree}/init/build-version") EOF