diff mbox series

[v2] kbuild: deb-pkg: Don't fail if modules.order is missing

Message ID 20241105205658.349180-1-matt@readmodwrite.com (mailing list archive)
State New
Headers show
Series [v2] kbuild: deb-pkg: Don't fail if modules.order is missing | expand

Commit Message

Matt Fleming Nov. 5, 2024, 8:56 p.m. UTC
From: Matt Fleming <mfleming@cloudflare.com>

Kernels built without CONFIG_MODULES might still want to create -dbg deb
packages but install_linux_image_dbg() assumes modules.order always
exists. This obviously isn't true if no modules were built, so we should
skip reading modules.order in that case.

Fixes: 16c36f8864e3 ("kbuild: deb-pkg: use build ID instead of debug link for dbg package")
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
---
 scripts/package/builddeb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Masahiro Yamada Nov. 5, 2024, 11:03 p.m. UTC | #1
On Wed, Nov 6, 2024 at 5:57 AM Matt Fleming <matt@readmodwrite.com> wrote:
>
> From: Matt Fleming <mfleming@cloudflare.com>
>
> Kernels built without CONFIG_MODULES might still want to create -dbg deb
> packages but install_linux_image_dbg() assumes modules.order always
> exists. This obviously isn't true if no modules were built, so we should
> skip reading modules.order in that case.

Good catch.

> Fixes: 16c36f8864e3 ("kbuild: deb-pkg: use build ID instead of debug link for dbg package")
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
> ---
>  scripts/package/builddeb | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 404587fc71fe..9739b0429337 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -96,6 +96,11 @@ install_linux_image_dbg () {
>
>         # Parse modules.order directly because 'make modules_install' may sign,
>         # compress modules, and then run unneeded depmod.
> +       modules_file=modules.order
> +       if [ ! -s $modules_file ]; then
> +               modules_file=/dev/null
> +       fi

This leaves a possibility to pick up a stale modules.order
in incremental builds without 'make clean'.

(1) build with CONFIG_MODULES=y
(2) disable CONFIG_MODULES
(3) 'make bindeb-pkg'


(3) picks up an unrelated modules.order
in the previous build (1).


>         while read -r mod; do
>                 mod="${mod%.o}.ko"
>                 dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}"
> @@ -105,7 +110,7 @@ install_linux_image_dbg () {
>                 mkdir -p "${dbg%/*}" "${link%/*}"
>                 "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
>                 ln -sf --relative "${dbg}" "${link}"
> -       done < modules.order
> +       done < $modules_file

Please enclose this block with CONFIG_MODULES.

if is_enabled CONFIG_MODULES; then
         while read -r mod; do
                 ...
         done < modules.order
fi
diff mbox series

Patch

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 404587fc71fe..9739b0429337 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -96,6 +96,11 @@  install_linux_image_dbg () {
 
 	# Parse modules.order directly because 'make modules_install' may sign,
 	# compress modules, and then run unneeded depmod.
+	modules_file=modules.order
+	if [ ! -s $modules_file ]; then
+		modules_file=/dev/null
+	fi
+
 	while read -r mod; do
 		mod="${mod%.o}.ko"
 		dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}"
@@ -105,7 +110,7 @@  install_linux_image_dbg () {
 		mkdir -p "${dbg%/*}" "${link%/*}"
 		"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
 		ln -sf --relative "${dbg}" "${link}"
-	done < modules.order
+	done < $modules_file
 
 	# Build debug package
 	# Different tools want the image in different locations