scripts/package/builddeb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
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>
---
Changes in v3:
- Wrap modules.order logic in 'if is_enabled CONFIG_MODULES'
scripts/package/builddeb | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 441b0bb66e0d..fb686fd3266f 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -96,16 +96,18 @@ install_linux_image_dbg () {
# Parse modules.order directly because 'make modules_install' may sign,
# compress modules, and then run unneeded depmod.
- while read -r mod; do
- mod="${mod%.o}.ko"
- dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}"
- buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
- link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug"
-
- mkdir -p "${dbg%/*}" "${link%/*}"
- "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
- ln -sf --relative "${dbg}" "${link}"
- done < modules.order
+ if is_enabled CONFIG_MODULES; then
+ while read -r mod; do
+ mod="${mod%.o}.ko"
+ dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}"
+ buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
+ link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug"
+
+ mkdir -p "${dbg%/*}" "${link%/*}"
+ "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
+ ln -sf --relative "${dbg}" "${link}"
+ done < modules.order
+ fi
# Build debug package
# Different tools want the image in different locations
--
2.34.1
On Fri, Nov 8, 2024 at 12:05 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. > > 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> Applied to linux-kbuild. Thanks! > --- > > Changes in v3: > - Wrap modules.order logic in 'if is_enabled CONFIG_MODULES' > > scripts/package/builddeb | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/scripts/package/builddeb b/scripts/package/builddeb > index 441b0bb66e0d..fb686fd3266f 100755 > --- a/scripts/package/builddeb > +++ b/scripts/package/builddeb > @@ -96,16 +96,18 @@ install_linux_image_dbg () { > > # Parse modules.order directly because 'make modules_install' may sign, > # compress modules, and then run unneeded depmod. > - while read -r mod; do > - mod="${mod%.o}.ko" > - dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}" > - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') > - link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug" > - > - mkdir -p "${dbg%/*}" "${link%/*}" > - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" > - ln -sf --relative "${dbg}" "${link}" > - done < modules.order > + if is_enabled CONFIG_MODULES; then > + while read -r mod; do > + mod="${mod%.o}.ko" > + dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}" > + buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') > + link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug" > + > + mkdir -p "${dbg%/*}" "${link%/*}" > + "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" > + ln -sf --relative "${dbg}" "${link}" > + done < modules.order > + fi > > # Build debug package > # Different tools want the image in different locations > -- > 2.34.1 > -- Best Regards Masahiro Yamada
© 2016 - 2024 Red Hat, Inc.