* [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH
@ 2026-03-20 14:30 Janne Grunau
2026-03-21 15:02 ` Simon Glass
2026-03-21 15:18 ` Nicolas Schier
0 siblings, 2 replies; 5+ messages in thread
From: Janne Grunau @ 2026-03-20 14:30 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Ahmad Fatoum, Sascha Hauer
Cc: Simon Glass, Thomas Weißschuh, linux-kbuild, linux-kernel,
Janne Grunau
The modules-cpio-pkg target added in commit 2a9c8c0b59d3 ("kbuild: add
target to build a cpio containing modules") is incompatible with
initramfs with merged /lib and /usr/lib directories [1]. "/lib" cannot
be a link and directory at the same time.
Respect a non-empty INSTALL_MOD_PATH in the modules-cpio-pkg target so
that `make INSTALL_MOD_PATH=/usr modules-cpio-pkg` results in the same
module install location as `make INSTALL_MOD_PATH=/usr modules_install`.
Tested with Fedora distribution initramfs produced by dracut.
Link: https://systemd.io/THE_CASE_FOR_THE_USR_MERGE/ [1]
Signed-off-by: Janne Grunau <j@jannau.net>
---
Hej,
this patch allows to produce modules-cpio initramfs which are compatible
with initramfs with merged /lib and /usr/lib (/lib as symlink to
/usr/lib). I expect initramfs of distributions with merged /usr to have
a merged /usr as well. This is at least true for Fedora initramfs built
with dracut.
I'm not sure whether the trickery to avoid repeated '/' is justified. It
is necessary to add a slash between "$@" and a non empty
$(INSTALL_MOD_PATH) to avoid make failures due to non existing
.tmp_modules_cpio when INSTALL_MOD_PATH without leading slash is used.
modules-cpio-pkg`.
Better or shorter ways to document this not completely obvious behavior
would be appreciated.
Janne
---
scripts/Makefile.package | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 0ec946f9b905f74f8698d8d6967d22f5b76f64e0..ab18cf81622ae319380528c401f9aeb6d32070c6 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -195,7 +195,9 @@ tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
.tmp_modules_cpio: FORCE
$(Q)$(MAKE) -f $(srctree)/Makefile
$(Q)rm -rf $@
- $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
+ $(Q)$(MAKE) -f $(srctree)/Makefile \
+ INSTALL_MOD_PATH=$@$(if $(INSTALL_MOD_PATH),/$(INSTALL_MOD_PATH:/%=%)) \
+ modules_install
quiet_cmd_cpio = CPIO $@
cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
@@ -263,7 +265,7 @@ help:
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
@echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
@echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
- @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
+ @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive (modules installed in INSTALL_MOD_PATH (default: /))'
@echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
@echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
@echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260320-kbuild-modules-cpio-pkg-usr-merge-4266a460282c
Best regards,
--
Janne Grunau <j@jannau.net>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH
2026-03-20 14:30 [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH Janne Grunau
@ 2026-03-21 15:02 ` Simon Glass
2026-03-21 15:18 ` Nicolas Schier
1 sibling, 0 replies; 5+ messages in thread
From: Simon Glass @ 2026-03-21 15:02 UTC (permalink / raw)
To: Janne Grunau
Cc: Nathan Chancellor, Nicolas Schier, Ahmad Fatoum, Sascha Hauer,
Thomas Weißschuh, linux-kbuild, linux-kernel
Hi Janne,
On Fri, 20 Mar 2026 at 08:30, Janne Grunau <j@jannau.net> wrote:
>
> The modules-cpio-pkg target added in commit 2a9c8c0b59d3 ("kbuild: add
> target to build a cpio containing modules") is incompatible with
> initramfs with merged /lib and /usr/lib directories [1]. "/lib" cannot
> be a link and directory at the same time.
> Respect a non-empty INSTALL_MOD_PATH in the modules-cpio-pkg target so
> that `make INSTALL_MOD_PATH=/usr modules-cpio-pkg` results in the same
> module install location as `make INSTALL_MOD_PATH=/usr modules_install`.
>
> Tested with Fedora distribution initramfs produced by dracut.
>
> Link: https://systemd.io/THE_CASE_FOR_THE_USR_MERGE/ [1]
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
> Hej,
>
> this patch allows to produce modules-cpio initramfs which are compatible
> with initramfs with merged /lib and /usr/lib (/lib as symlink to
> /usr/lib). I expect initramfs of distributions with merged /usr to have
> a merged /usr as well. This is at least true for Fedora initramfs built
> with dracut.
>
> I'm not sure whether the trickery to avoid repeated '/' is justified. It
> is necessary to add a slash between "$@" and a non empty
> $(INSTALL_MOD_PATH) to avoid make failures due to non existing
> .tmp_modules_cpio when INSTALL_MOD_PATH without leading slash is used.
> modules-cpio-pkg`.
>
> Better or shorter ways to document this not completely obvious behavior
> would be appreciated.
>
> Janne
> ---
> scripts/Makefile.package | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 0ec946f9b905f74f8698d8d6967d22f5b76f64e0..ab18cf81622ae319380528c401f9aeb6d32070c6 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -195,7 +195,9 @@ tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> .tmp_modules_cpio: FORCE
> $(Q)$(MAKE) -f $(srctree)/Makefile
> $(Q)rm -rf $@
> - $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
How about a comment for this line, e.g.:
# Prepend INSTALL_MOD_PATH inside the staging dir, stripping leading /
> + $(Q)$(MAKE) -f $(srctree)/Makefile \
> + INSTALL_MOD_PATH=$@$(if $(INSTALL_MOD_PATH),/$(INSTALL_MOD_PATH:/%=%)) \
> + modules_install
>
> quiet_cmd_cpio = CPIO $@
> cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
> @@ -263,7 +265,7 @@ help:
> @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
> @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
> @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
> - @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
> + @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive (modules installed in INSTALL_MOD_PATH (default: /))'
Would this be clear enough? :
Build modules as cpio archive (respects INSTALL_MOD_PATH)
> @echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
> @echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
> @echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
>
> ---
> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
> change-id: 20260320-kbuild-modules-cpio-pkg-usr-merge-4266a460282c
Reviewed-by: Simon Glass <sjg@chromium.org>
Regards,
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH
2026-03-20 14:30 [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH Janne Grunau
2026-03-21 15:02 ` Simon Glass
@ 2026-03-21 15:18 ` Nicolas Schier
2026-03-25 14:48 ` Janne Grunau
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Schier @ 2026-03-21 15:18 UTC (permalink / raw)
To: Janne Grunau
Cc: Nathan Chancellor, Ahmad Fatoum, Sascha Hauer, Simon Glass,
Thomas Weißschuh, linux-kbuild, linux-kernel
On Fri, Mar 20, 2026 at 03:30:32PM +0100, Janne Grunau wrote:
> The modules-cpio-pkg target added in commit 2a9c8c0b59d3 ("kbuild: add
> target to build a cpio containing modules") is incompatible with
> initramfs with merged /lib and /usr/lib directories [1]. "/lib" cannot
> be a link and directory at the same time.
> Respect a non-empty INSTALL_MOD_PATH in the modules-cpio-pkg target so
> that `make INSTALL_MOD_PATH=/usr modules-cpio-pkg` results in the same
> module install location as `make INSTALL_MOD_PATH=/usr modules_install`.
>
> Tested with Fedora distribution initramfs produced by dracut.
>
> Link: https://systemd.io/THE_CASE_FOR_THE_USR_MERGE/ [1]
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
> Hej,
>
> this patch allows to produce modules-cpio initramfs which are compatible
> with initramfs with merged /lib and /usr/lib (/lib as symlink to
> /usr/lib). I expect initramfs of distributions with merged /usr to have
> a merged /usr as well. This is at least true for Fedora initramfs built
> with dracut.
>
> I'm not sure whether the trickery to avoid repeated '/' is justified. It
> is necessary to add a slash between "$@" and a non empty
> $(INSTALL_MOD_PATH) to avoid make failures due to non existing
> .tmp_modules_cpio when INSTALL_MOD_PATH without leading slash is used.
> modules-cpio-pkg`.
>
> Better or shorter ways to document this not completely obvious behavior
> would be appreciated.
>
> Janne
> ---
> scripts/Makefile.package | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 0ec946f9b905f74f8698d8d6967d22f5b76f64e0..ab18cf81622ae319380528c401f9aeb6d32070c6 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -195,7 +195,9 @@ tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> .tmp_modules_cpio: FORCE
> $(Q)$(MAKE) -f $(srctree)/Makefile
> $(Q)rm -rf $@
> - $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
> + $(Q)$(MAKE) -f $(srctree)/Makefile \
> + INSTALL_MOD_PATH=$@$(if $(INSTALL_MOD_PATH),/$(INSTALL_MOD_PATH:/%=%)) \
> + modules_install
Thanks for the patch along with its detailed description!
For completeness: I'd rather use $(addprefix):
INSTALL_MOD_PATH=$@$(addprefix /,$(INSTALL_MOD_PATH:/%=%))
but as POSIX states:
| Multiple successive <slash> characters are considered to be the same
| as one <slash>, except it is implementation-defined whether the case
| of exactly two leading <slash> characters is treated specially.
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/
there is no need for handling possible repeated slashes here. So, from
my point of view we can keep it as simple as:
INSTALL_MOD_PATH=$@/$(INSTALL_MOD_PATH)
as a trailing slash in INSTALL_MOD_PATH should not be a problem here.
>
> quiet_cmd_cpio = CPIO $@
> cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
> @@ -263,7 +265,7 @@ help:
> @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
> @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
> @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
> - @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
> + @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive (modules installed in INSTALL_MOD_PATH (default: /))'
Please break that line, e.g.:
@echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
@echo ' (modules installed in INSTALL_MOD_PATH (default: /))'
Fixes: 2a9c8c0b59d3 (\"kbuild: add target to build a cpio containing modules\")
Kind regards,
Nicolas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH
2026-03-21 15:18 ` Nicolas Schier
@ 2026-03-25 14:48 ` Janne Grunau
2026-03-25 15:25 ` Nicolas Schier
0 siblings, 1 reply; 5+ messages in thread
From: Janne Grunau @ 2026-03-25 14:48 UTC (permalink / raw)
To: Nicolas Schier, Nathan Chancellor, Ahmad Fatoum, Sascha Hauer,
Simon Glass, Thomas Weißschuh, linux-kbuild, linux-kernel
On Sat, Mar 21, 2026 at 04:18:46PM +0100, Nicolas Schier wrote:
> On Fri, Mar 20, 2026 at 03:30:32PM +0100, Janne Grunau wrote:
> > The modules-cpio-pkg target added in commit 2a9c8c0b59d3 ("kbuild: add
> > target to build a cpio containing modules") is incompatible with
> > initramfs with merged /lib and /usr/lib directories [1]. "/lib" cannot
> > be a link and directory at the same time.
> > Respect a non-empty INSTALL_MOD_PATH in the modules-cpio-pkg target so
> > that `make INSTALL_MOD_PATH=/usr modules-cpio-pkg` results in the same
> > module install location as `make INSTALL_MOD_PATH=/usr modules_install`.
> >
> > Tested with Fedora distribution initramfs produced by dracut.
> >
> > Link: https://systemd.io/THE_CASE_FOR_THE_USR_MERGE/ [1]
> > Signed-off-by: Janne Grunau <j@jannau.net>
> > ---
> > Hej,
> >
> > this patch allows to produce modules-cpio initramfs which are compatible
> > with initramfs with merged /lib and /usr/lib (/lib as symlink to
> > /usr/lib). I expect initramfs of distributions with merged /usr to have
> > a merged /usr as well. This is at least true for Fedora initramfs built
> > with dracut.
> >
> > I'm not sure whether the trickery to avoid repeated '/' is justified. It
> > is necessary to add a slash between "$@" and a non empty
> > $(INSTALL_MOD_PATH) to avoid make failures due to non existing
> > .tmp_modules_cpio when INSTALL_MOD_PATH without leading slash is used.
> > modules-cpio-pkg`.
> >
> > Better or shorter ways to document this not completely obvious behavior
> > would be appreciated.
> >
> > Janne
> > ---
> > scripts/Makefile.package | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index 0ec946f9b905f74f8698d8d6967d22f5b76f64e0..ab18cf81622ae319380528c401f9aeb6d32070c6 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -195,7 +195,9 @@ tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> > .tmp_modules_cpio: FORCE
> > $(Q)$(MAKE) -f $(srctree)/Makefile
> > $(Q)rm -rf $@
> > - $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
> > + $(Q)$(MAKE) -f $(srctree)/Makefile \
> > + INSTALL_MOD_PATH=$@$(if $(INSTALL_MOD_PATH),/$(INSTALL_MOD_PATH:/%=%)) \
> > + modules_install
>
> Thanks for the patch along with its detailed description!
>
> For completeness: I'd rather use $(addprefix):
>
> INSTALL_MOD_PATH=$@$(addprefix /,$(INSTALL_MOD_PATH:/%=%))
>
> but as POSIX states:
>
> | Multiple successive <slash> characters are considered to be the same
> | as one <slash>, except it is implementation-defined whether the case
> | of exactly two leading <slash> characters is treated specially.
> https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/
argh, I did read this but confused myself by the second part to think it
was only for leading slashes.
> there is no need for handling possible repeated slashes here. So, from
> my point of view we can keep it as simple as:
>
> INSTALL_MOD_PATH=$@/$(INSTALL_MOD_PATH)
>
> as a trailing slash in INSTALL_MOD_PATH should not be a problem here.
ack, I'll just do that and I would have sent it if I did not confuse
myself with the POSIX wording.
>
> >
> > quiet_cmd_cpio = CPIO $@
> > cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
> > @@ -263,7 +265,7 @@ help:
> > @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
> > @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
> > @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
> > - @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
> > + @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive (modules installed in INSTALL_MOD_PATH (default: /))'
>
> Please break that line, e.g.:
>
> @echo ' modules-cpio-pkg - Build the kernel modules as cpio archive'
> @echo ' (modules installed in INSTALL_MOD_PATH (default: /))'
>
>
> Fixes: 2a9c8c0b59d3 (\"kbuild: add target to build a cpio containing modules\")
I saw it more as an additional thing but without the complications of
suppressing repeated slashes the change is easy enough
thanks,
Janne
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH
2026-03-25 14:48 ` Janne Grunau
@ 2026-03-25 15:25 ` Nicolas Schier
0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Schier @ 2026-03-25 15:25 UTC (permalink / raw)
To: Janne Grunau
Cc: Nathan Chancellor, Ahmad Fatoum, Sascha Hauer, Simon Glass,
Thomas Weißschuh, linux-kbuild, linux-kernel
On Wed, Mar 25, 2026 at 03:48:26PM +0100, Janne Grunau wrote:
> On Sat, Mar 21, 2026 at 04:18:46PM +0100, Nicolas Schier wrote:
> > On Fri, Mar 20, 2026 at 03:30:32PM +0100, Janne Grunau wrote:
> > > The modules-cpio-pkg target added in commit 2a9c8c0b59d3 ("kbuild: add
> > > target to build a cpio containing modules") is incompatible with
> > > initramfs with merged /lib and /usr/lib directories [1]. "/lib" cannot
> > > be a link and directory at the same time.
> > > Respect a non-empty INSTALL_MOD_PATH in the modules-cpio-pkg target so
> > > that `make INSTALL_MOD_PATH=/usr modules-cpio-pkg` results in the same
> > > module install location as `make INSTALL_MOD_PATH=/usr modules_install`.
> > >
> > > Tested with Fedora distribution initramfs produced by dracut.
> > >
> > > Link: https://systemd.io/THE_CASE_FOR_THE_USR_MERGE/ [1]
> > > Signed-off-by: Janne Grunau <j@jannau.net>
> > > ---
> > > Hej,
> > >
> > > this patch allows to produce modules-cpio initramfs which are compatible
> > > with initramfs with merged /lib and /usr/lib (/lib as symlink to
> > > /usr/lib). I expect initramfs of distributions with merged /usr to have
> > > a merged /usr as well. This is at least true for Fedora initramfs built
> > > with dracut.
> > >
> > > I'm not sure whether the trickery to avoid repeated '/' is justified. It
> > > is necessary to add a slash between "$@" and a non empty
> > > $(INSTALL_MOD_PATH) to avoid make failures due to non existing
> > > .tmp_modules_cpio when INSTALL_MOD_PATH without leading slash is used.
> > > modules-cpio-pkg`.
> > >
> > > Better or shorter ways to document this not completely obvious behavior
> > > would be appreciated.
> > >
> > > Janne
> > > ---
> > > scripts/Makefile.package | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > > index 0ec946f9b905f74f8698d8d6967d22f5b76f64e0..ab18cf81622ae319380528c401f9aeb6d32070c6 100644
> > > --- a/scripts/Makefile.package
> > > +++ b/scripts/Makefile.package
> > > @@ -195,7 +195,9 @@ tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> > > .tmp_modules_cpio: FORCE
> > > $(Q)$(MAKE) -f $(srctree)/Makefile
> > > $(Q)rm -rf $@
> > > - $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
> > > + $(Q)$(MAKE) -f $(srctree)/Makefile \
> > > + INSTALL_MOD_PATH=$@$(if $(INSTALL_MOD_PATH),/$(INSTALL_MOD_PATH:/%=%)) \
> > > + modules_install
> >
> > Thanks for the patch along with its detailed description!
> >
> > For completeness: I'd rather use $(addprefix):
> >
> > INSTALL_MOD_PATH=$@$(addprefix /,$(INSTALL_MOD_PATH:/%=%))
> >
> > but as POSIX states:
> >
> > | Multiple successive <slash> characters are considered to be the same
> > | as one <slash>, except it is implementation-defined whether the case
> > | of exactly two leading <slash> characters is treated specially.
> > https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/
>
> argh, I did read this but confused myself by the second part to think it
> was only for leading slashes.
:) you are by far not the only one who gets confused by that.
--
Nicolas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-25 15:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 14:30 [PATCH] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH Janne Grunau
2026-03-21 15:02 ` Simon Glass
2026-03-21 15:18 ` Nicolas Schier
2026-03-25 14:48 ` Janne Grunau
2026-03-25 15:25 ` Nicolas Schier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox