kbuild: deb-pkg: propagate hook script failures in builddeb
PATCH 1/1 kbuild: deb-pkg: propagate hook script failures in builddeb
From 1d7c7d8bf70c3d2b2abbb5ead3c654978ead419a Mon Sep 17 00:00:00 2001
From: jillravaliya <[email protected]>
Date: Wed, 22 Apr 2026 23:37:39 +0530
Subject: [PATCH] kbuild: deb-pkg: propagate hook script failures in builddeb
The 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0. This masks failures from downstream hooks (e.g., initramfs generation or DKMS).
On systems with modular storage drivers (CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated. This results in a successful package installation exit code despite a broken boot configuration, leading to a 'VFS: unknown-block(0,0)' panic on reboot.
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
--- scripts/package/builddeb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/package/builddeb +6 -3
@@ -98,7 +98,12 @@ install_maint_scripts () { hookdirs="\$hookdirs \$dir/${script}.d" done hookdirs="\${hookdirs# }" - test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs + if [ -n "\$hookdirs" ]; then + if ! run-parts --arg="\${KERNELRELEASE}" --arg="/\${installed_image_path}" \$hookdirs; then + echo "E: Post-install hooks failed." >&2 + exit 1 + fi + fi exit 0
EOF
chmod 755 "${pdir}/DEBIAN/${script}"
Signature · 1 line
2.51.1
Nathan Chancellor
maintainerHi Jill,
Thanks for the patch!
Quoted 33 lines · Jill Ravaliya
Quoted 1 line
From
1d7c7d8bf70c3d2b2abbb5ead3c654978ead419aMon Sep 17 00:00:00 2001From: jillravaliya <[email protected]>
Date: Wed, 22 Apr 2026 23:37:39 +0530
Subject: [PATCH] kbuild: deb-pkg: propagate hook script failures in builddebThe 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0. This masks failures from downstream hooks (e.g., initramfs generation or DKMS).
On systems with modular storage drivers (
CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated. This results in a successful package installation exit code despite a broken boot configuration, leading to a 'VFS: unknown-block(0,0)' panic on reboot.This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
Signed-off-by jillravaliya <[email protected]>--- scripts/package/builddeb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)scripts/package/builddeb +0
-0@@ -98,7 +98,12 @@ install_maint_scripts () { hookdirs="\$hookdirs \$dir/${script}.d" done
scripts/package/builddeb install_maint_scripts () { · line 106
Quoted 10 lines
scripts/package/builddeb +6
-3hookdirs="\${hookdirs# }" - test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs + if [ -n "\$hookdirs" ]; then + if ! run-parts --arg="\${KERNELRELEASE}" --arg="/\${installed_image_path}" \$hookdirs; then + echo "E: Post-install hooks failed." >&2 + exit 1 + fi + fi
Unfortunately, this patch is malformed so it cannot be applied. Please see
https://docs.kernel.org/process/submitting-patches.html#no-mime-no-links-no-compression-no-attachments-just-plain-text
https://git-send-email.io/
https://docs.kernel.org/process/email-clients.html
for information on using git send-email (the traditional way) or
https://b4.docs.kernel.org/en/latest/contributor/overview.html
https://github.com/ClangBuiltLinux/linux/issues/2093#issuecomment-2932754317
for information on using b4 (the new way).
Otherwise, the premise of this patch seems reasonable and I would be happy to test it properly once it can be properly applied to the tree.
Quoted 6 lines
scripts/package/builddeb +0
-0exit 0 EOF chmod 755 "${pdir}/DEBIAN/${script}"Signature · 1 line
2.51.1
PATCH 1/1 kbuild: deb-pkg: propagate hook script failures in builddeb
In reply to Jill RavaliyaThe 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0. This masks failures from downstream hooks (e.g., initramfs generation or DKMS).
On systems with modular storage drivers (CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated, leading to a panic on reboot.
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
---
v2:
- Resending via git send-email to fix formatting issues.
- Refined commit message for clarity and professional tone.
--- scripts/package/builddeb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/package/builddeb +6 -1
@@ -98,7 +98,12 @@ install_maint_scripts () { hookdirs="\$hookdirs \$dir/${script}.d" done hookdirs="\${hookdirs# }" - test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs + if [ -n "\$hookdirs" ]; then + if ! run-parts --arg="\${KERNELRELEASE}" --arg="/\${installed_image_path}" \$hookdirs; then + echo "E: Post-install hooks failed." >&2 + exit 1 + fi + fi exit 0 EOF chmod 755 "${pdir}/DEBIAN/${script}"
Signature · 1 line
2.51.1
Nathan Chancellor
maintainerOn Thu, 30 Apr 2026 14:24:42 +0530, Jill Ravaliya <[email protected]> wrote:
Hi Jill,
Thanks for a quick v2!
Quoted 9 lines
The 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0. This masks failures from downstream hooks (e.g., initramfs generation or DKMS).
On systems with modular storage drivers (
CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated, leading to a panic on reboot.
Quoted 5 lines
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
Signed-off-by jillravaliya <[email protected]>
Please use proper name formatting here.
scripts/package/builddeb install_maint_scripts () { · line 102
Quoted 13 lines
scripts/package/builddeb +2
-1@@ -98,7 +98,12 @@ install_maint_scripts () { hookdirs="\$hookdirs \$dir/${script}.d" done hookdirs="\${hookdirs# }" - test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs + if [ -n "\$hookdirs" ]; then + if ! run-parts --arg="\${KERNELRELEASE}" --arg="/\${installed_image_path}" \$hookdirs; then
Is the escaping of '$' correct here? Prior to this change, these values would be expanded when the scripts were written to disk but now they will be expanded when the script is run, which seems incorrect since those variables will not be set in this environment.
| diff --git a/build/kbuild-7.1-rc1/debian/linux-image-7.1.0-rc1-00002-ge96b61aad8d5-dirty/DEBIAN/postinst b/build/kbuild/debian/linux-image-7.1.0-rc1-00002-ge96b61aad8d5/DEBIAN/postinst
| index d9fc953e73c6..30ef722cfebf 100755
| --- a/build/kbuild-7.1-rc1/debian/linux-image-7.1.0-rc1-00002-ge96b61aad8d5-dirty/DEBIAN/postinst
| +++ b/build/kbuild/debian/linux-image-7.1.0-rc1-00002-ge96b61aad8d5/DEBIAN/postinst
| @@ -16,5 +16,10 @@ test -d "$dir/postinst.d" || continue
| hookdirs="$hookdirs $dir/postinst.d"
| done
| hookdirs="${hookdirs# }"
| -test -n "$hookdirs" && run-parts --arg="7.1.0-rc1-00002-ge96b61aad8d5-dirty" --arg="/boot/vmlinuz-7.1.0-rc1-00002-ge96b61aad8d5-dirty" $hookdirs
| +if [ -n "$hookdirs" ]; then
| + if ! run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" $hookdirs; then
| + echo "E: Post-install hooks failed." >&2
| + exit 1
| + fi
| + fi
| exit 0Was this a leftover from testing?
scripts/package/builddeb install_maint_scripts () { · line 106
Quoted 4 lines
scripts/package/builddeb +4
-0+ echo "E: Post-install hooks failed." >&2 + exit 1 + fi + fi
Please fix up the indentation, as your change uses spaces but the rest of this script uses tabs.
Signature · 2 lines
Cheers, Nathan
PATCH 1/1 kbuild: deb-pkg: propagate hook script failures in builddeb
In reply to Jill RavaliyaThe 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0. This masks failures from downstream hooks (e.g., initramfs generation or DKMS).
On systems with modular storage drivers (CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated, leading to a panic on reboot.
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
---
v3:
- Fix variable escaping in run-parts invocation
- Fix indentation to use tabs consistently
- Fix Signed-off-by name formatting
v2:
- Resending via git send-email to fix formatting issues.
- Refined commit message for clarity and professional tone.
--- scripts/package/builddeb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/package/builddeb +6 -1
@@ -98,7 +98,12 @@ install_maint_scripts () { hookdirs="\$hookdirs \$dir/${script}.d" done hookdirs="\${hookdirs# }" - test -n "\$hookdirs" && run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs + if [ -n "\$hookdirs" ]; then + if ! run-parts --arg="${KERNELRELEASE}" --arg="/${installed_image_path}" \$hookdirs; then + echo "E: Post-install hooks failed." >&2 + exit 1 + fi + fi exit 0 EOF chmod 755 "${pdir}/DEBIAN/${script}"
Signature · 1 line
2.51.1
Nicolas Schier
maintainerQuoted 3 lines · Jill Ravaliya
The 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0.
Are you sure? On my Debian trixie, run-parts exits with 1 as soon as a single script from the given directory exists with non-zero.
Quoted 7 lines
This masks failures
from downstream hooks (e.g., initramfs generation or DKMS).On systems with modular storage drivers (
CONFIG_BLK_DEV_NVME=m), an unnoticed failure in an early hook can prevent the initrd from being correctly updated, leading to a panic on reboot.
Quoted 6 lines
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
From skimming through that bug report, I don't think that the run-parts part is the problem; but it seems to me that Ubuntu's '55-initrd.install' script is the problem.
Kind regards,
Nicolas
Nathan Chancellor
maintainerQuoted 7 lines · Nicolas Schier
Quoted 3 lines · Jill Ravaliya
The 'builddeb' script generates maintainer scripts for Debian-based distributions. Currently, it invokes post-installation hooks via run-parts but unconditionally exits with code 0.
Are you sure? On my Debian trixie, run-parts exits with 1 as soon as a single script from the given directory exists with non-zero.
...
Quoted 3 lines
Quoted 3 lines
This patch ensures that failures in 'run-parts' are correctly propagated, allowing the package manager to abort the installation upon hook failure.
Hmmm, yeah, I had missed the 'set -e' in this script, so I think this change should be unnecessary because run-parts failures should already be propagated up from 'set -e'. If a script in /{etc,usr/share}/kernel does not error when it should, there is nothing we can do about that (which appears to be the cause of the original issue). Thanks for the review!
Signature · 2 lines
Cheers, Nathan