kbuild: deb-pkg: Include modules.builtin* even if non-modular

Message ID 36a4014c73a52af27d930d3ca31d362b60f4461c.1686356364.git.josh@joshtriplett.org
State New
Headers
Series kbuild: deb-pkg: Include modules.builtin* even if non-modular |

Commit Message

Josh Triplett June 10, 2023, 12:28 a.m. UTC
  Even for a non-modular kernel, the kernel builds modules.builtin and
modules.builtin.modinfo, with information about the built-in modules.
Tools such as initramfs-tools need these files to build a working
initramfs on some systems, such as those requiring firmware.

Install modules.builtin and modules.builtin.modinfo into the linux-image
package even for a non-modular kernel.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
 scripts/package/builddeb | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Nicolas Schier June 14, 2023, 7:14 p.m. UTC | #1
On Fri 09 Jun 2023 17:28:09 GMT, Josh Triplett wrote:
> Even for a non-modular kernel, the kernel builds modules.builtin and
> modules.builtin.modinfo, with information about the built-in modules.
> Tools such as initramfs-tools need these files to build a working
> initramfs on some systems, such as those requiring firmware.

Searching via source.debian.org, I was suprised that there are really 
numerous other tools as well, that attempt to read modules.builtin.

> 
> Install modules.builtin and modules.builtin.modinfo into the linux-image
> package even for a non-modular kernel.
> 
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> ---

Thanks!

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Tested-by: Nicolas Schier <nicolas@fjasle.eu>

>  scripts/package/builddeb | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 252faaa5561c..91261529f2c7 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -70,6 +70,12 @@ install_linux_image () {
>  			mkdir -p "${pdir}/usr/lib/uml/modules"
>  			mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
>  		fi
> +	elif [ -f modules.builtin ]; then
> +		mkdir -p "${pdir}/lib/modules/${KERNELRELEASE}"
> +		cp modules.builtin "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin"
> +		if [ -f modules.builtin.modinfo ]; then
> +			cp modules.builtin.modinfo "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin.modinfo"
> +		fi
>  	fi
>  
>  	# Install the kernel
> -- 
> 2.40.1
  
Masahiro Yamada June 15, 2023, 11:22 a.m. UTC | #2
On Sat, Jun 10, 2023 at 9:28 AM Josh Triplett <josh@joshtriplett.org> wrote:
>
> Even for a non-modular kernel, the kernel builds modules.builtin and
> modules.builtin.modinfo, with information about the built-in modules.
> Tools such as initramfs-tools need these files to build a working
> initramfs on some systems, such as those requiring firmware.
>
> Install modules.builtin and modules.builtin.modinfo into the linux-image
> package even for a non-modular kernel.
>
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>



OK, I understood.
But, this patch only aids Debian in an ad-hoc file copy.

I think chaning modules_install would be a more
general solution.

Can you use this patch as a prerequisite?
https://patchwork.kernel.org/project/linux-kbuild/patch/20230615111743.883891-1-masahiroy@kernel.org/

Then, you can simply remove
"if is_enabled CONFIG_MODULES; then"
so you can install the files unconditionally.



> ---
>  scripts/package/builddeb | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 252faaa5561c..91261529f2c7 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -70,6 +70,12 @@ install_linux_image () {
>                         mkdir -p "${pdir}/usr/lib/uml/modules"
>                         mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
>                 fi
> +       elif [ -f modules.builtin ]; then
> +               mkdir -p "${pdir}/lib/modules/${KERNELRELEASE}"
> +               cp modules.builtin "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin"
> +               if [ -f modules.builtin.modinfo ]; then
> +                       cp modules.builtin.modinfo "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin.modinfo"
> +               fi
>         fi
>
>         # Install the kernel
> --
> 2.40.1
>
  

Patch

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 252faaa5561c..91261529f2c7 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -70,6 +70,12 @@  install_linux_image () {
 			mkdir -p "${pdir}/usr/lib/uml/modules"
 			mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
 		fi
+	elif [ -f modules.builtin ]; then
+		mkdir -p "${pdir}/lib/modules/${KERNELRELEASE}"
+		cp modules.builtin "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin"
+		if [ -f modules.builtin.modinfo ]; then
+			cp modules.builtin.modinfo "${pdir}/lib/modules/${KERNELRELEASE}/modules.builtin.modinfo"
+		fi
 	fi
 
 	# Install the kernel