From: "Michal Suchánek" <msuchanek@suse.de>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
"Nicolas Schier" <nicolas@fjasle.eu>,
linux-modules@vger.kernel.org, "Takashi Iwai" <tiwai@suse.com>,
"Lucas De Marchi" <lucas.de.marchi@gmail.com>,
"Michal Koutný" <mkoutny@suse.com>,
"Jiri Slaby" <jslaby@suse.com>,
"Jan Engelhardt" <jengelh@inai.de>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>
Subject: Re: [PATCH rebased] kbuild: rpm-pkg: Fix build with non-default MODLIB
Date: Tue, 17 Oct 2023 12:44:53 +0200 [thread overview]
Message-ID: <20231017104453.GG6241@kitsune.suse.cz> (raw)
In-Reply-To: <CAK7LNASX2_-xt3Qvxie_G=Q4fuVYR6eE47QjQ5NZf7QxY-4_tQ@mail.gmail.com>
On Tue, Oct 17, 2023 at 07:15:50PM +0900, Masahiro Yamada wrote:
> > >
> > > Let me add more context to my question.
> > >
> > >
> > > I am interested in the timing when
> > > 'pkg-config --print-variables kmod | grep module_directory'
> > > is executed.
> > >
> > >
> > >
> > > 1. Build a SRPM on machine A
> > >
> > > 2. Copy the SRPM from machine A to machine B
> > >
> > > 3. Run rpmbuild on machine B to build the SRPM into a RPM
> > >
> > > 4. Copy the RPM from machine B to machine C
> > >
> > > 5. Install the RPM to machine C
> >
> > As far as I am aware the typical use case is two step:
> >
> > 1. run make rpm-pkg on machine A
> > 2. install the binary rpm on machine C that might not have build tools
> > or powerful enough CPU
> >
> > While it's theoretically possible to use the srpm to rebuild the binary
> > rpm independently of the kernel git tree I am not aware of people
> > commonly doing this.
>
>
>
> If I correctly understand commit
> 8818039f959b2efc0d6f2cb101f8061332f0c77e,
> those Redhat guys pack a SRPM on a local machine,
> then send it to their build server called 'koji'.
>
> Otherwise, there is no reason
> to have 'make srcrpm-pkg'.
>
>
>
> I believe "A == B" is not always true,
> but we can assume "distro(A) == distro(B)" is always met
> for simplicity.
>
> So, I am OK with configuration at the SRPM time.
Even if the distro does not match it will likely work to configure SRPM
for non-matching distro and then build it on the target distro but I have
not tested it.
> > If rebuilding the source rpm on a different machine from where the git
> > tree is located, and possibly on a different distribution is desirable
> > then the detection of the KERNEL_MODULE_DIRECTORY should be added in the
> > rpm spec file as well.
> >
> > > Of course, we are most interested in the module path
> > > of machine C, but it is difficult/impossible to
> > > guess it at the time of building.
> > >
> > > We can assume machine B == machine C.
> > >
> > > We are the second most interested in the module
> > > path on machine B.
> > >
> > > The module path of machine A is not important.
> > >
> > > So, I am asking where you would inject
> > > 'pkg-config --print-variables kmod | grep module_directory'.
> >
> > I don't. I don't think there will be a separate machine B.
> >
> > And I can't really either - so far any attempt at adding support for
> > this has been rejected.
> >
> > Technically the KERNEL_MODULE_DIRECTORY could be set in two steps - one
> > giving the script to run, and one running it, and then it could be run
> > independently in the SRPM as well.
>
>
> At first, I thought your patch [1] was very ugly,
> but I do not think it is so ugly if cleanly implemented.
>
> It won't hurt to allow users to specify the middle part of MODLIB.
>
>
> There are two options.
>
>
> [A] Add 'MOD_PREFIX' to specify the middle part of MODLIB
>
>
> The top Makefile will look as follows:
>
>
> MODLIB = $(INSTALL_MOD_PATH)$(MOD_PREFIX)/lib/modules/$(KERNELRELEASE)
> export MODLIB
>
>
> It is easier than specifying the entire MODLIB, but you still need
> to manually pass "MOD_PREFIX=/usr" from an env variable or
> the command line.
>
> If MOD_PREFIX is not given, MODLIB is the same as the current one.
>
> [B] Support a dynamic configuration as well
>
>
> MOD_PREFIX ?= $(shell pkg-config --variable=module_prefix libkmod 2>/dev/null)
> export MOD_PREFIX
>
> MODLIB = $(INSTALL_MOD_PATH)$(MOD_PREFIX)/lib/modules/$(KERNELRELEASE)
> export MODLIB
That's basically the same thing as the patch that has been rejected.
I used := to prevent calling pkg-config every time MODLIB is used but it
might not be the most flexible wrt overrides.
> If MOD_PREFIX is given from an env variable or from the command line,
> it is respected.
>
> If "pkg-config --variable=module_prefix libkmod" works,
> that configuration is applied.
>
> Otherwise, MOD_PREFIX is empty, i.e. fall back to the current behavior.
>
>
> I prefer 'MOD_PREFIX' to 'KERNEL_MODULE_DIRECTORY' in your patch [1]
> because "|| echo /lib/modules" can be omitted.
>
> I do not think we will have such a crazy distro that
> installs modules under /opt/ directory.
However, I can easily imagine a distribution that would want to put
modules in /usr/lib-amd64-linux/modules.
> I could not understand why you inserted
> "--print-variables kmod 2>/dev/null | grep '^module_directory$$' >/dev/null"
> but I guess the reason is the same.
> "pkg-config --variable=module_directory kmod" always succeeds,
> so "|| echo /lib/modules" is never processed.
Yes, that's the semantics of the tool. The jq version was slightly less
convoluted but required additional tool for building the kernel.
> I do not know why you parsed kmod.pc instead of libkmod.pc [2]
Because it's kmod property, not libkmod property.
Distributions would install libkmod.pc only with development files
whereas the kmod.pc should be installed with the binaries.
Thanks
Michal
>
>
> [1] https://lore.kernel.org/linux-kbuild/20230718120348.383-1-msuchanek@suse.de/
> [2] https://github.com/kmod-project/kmod/blob/v31/configure.ac#L295
next prev parent reply other threads:[~2023-10-17 10:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 15:07 [PATCH rebased] kbuild: rpm-pkg: Fix build with non-default MODLIB Michal Suchanek
2023-10-06 16:58 ` Nathan Chancellor
2023-10-09 8:31 ` Masahiro Yamada
2023-10-09 8:52 ` Michal Suchánek
2023-10-09 12:34 ` Masahiro Yamada
2023-10-09 14:07 ` Michal Suchánek
2023-10-09 15:14 ` Masahiro Yamada
2023-10-09 16:01 ` Jan Engelhardt
2023-10-10 10:15 ` Michal Suchánek
2023-10-17 10:15 ` Masahiro Yamada
2023-10-17 10:44 ` Michal Suchánek [this message]
2023-10-17 12:05 ` Masahiro Yamada
2023-10-17 12:27 ` Michal Suchánek
2023-10-17 14:46 ` Masahiro Yamada
2023-10-17 15:10 ` Michal Suchánek
2023-10-18 1:12 ` Jan Engelhardt
2023-11-10 17:44 ` Michal Suchánek
2023-11-10 17:57 ` Jan Engelhardt
2023-12-06 19:47 ` [PATCH v6 1/2] depmod: Handle installing modules under a different directory Michal Suchanek
2023-12-10 18:43 ` Masahiro Yamada
2023-12-10 18:51 ` Woody Suwalski
2023-12-10 21:07 ` Michal Suchánek
2023-12-11 4:29 ` Masahiro Yamada
2023-12-12 13:03 ` Michal Suchánek
2023-12-18 14:05 ` Masahiro Yamada
2023-12-06 19:47 ` [PATCH v6 2/2] kbuild: rpm-pkg: Fix build with non-default MODLIB Michal Suchanek
2023-12-10 18:44 ` Masahiro Yamada
2023-12-10 21:08 ` Michal Suchánek
2023-12-11 4:33 ` Masahiro Yamada
2023-12-12 13:12 ` Michal Suchánek
2023-12-18 14:16 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231017104453.GG6241@kitsune.suse.cz \
--to=msuchanek@suse.de \
--cc=jengelh@inai.de \
--cc=jslaby@suse.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.de.marchi@gmail.com \
--cc=masahiroy@kernel.org \
--cc=mkoutny@suse.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).