public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v2] initramfs: Avoid hanging mounts on failed update-initramfs
@ 2024-10-24 10:10 Anton Mikanovich
  2024-10-24 10:40 ` Uladzimir Bely
  2024-10-25 13:58 ` Uladzimir Bely
  0 siblings, 2 replies; 4+ messages in thread
From: Anton Mikanovich @ 2024-10-24 10:10 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

If update-initramfs fails during do_generate_initramfs task execution
there will be mounts left behind:

| E: /usr/share/initramfs-tools/hooks/isar-example failed with return 1.
| update-initramfs: failed for /boot/initrd.img-6.1.0-26-amd64 with 1.
| WARNING: exit code 1 from a shell command.
ERROR: Task (mc:qemuamd64-bookworm:isar/meta-isar/recipes-initramfs/images/isar-initramfs.bb:do_generate_initramfs) failed with exit code '1'
NOTE: Tasks Summary: Attempted 38 tasks of which 27 didn't need to be rerun and 1 failed.
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/isar-apt left mounted, unmounting...
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/sys left mounted, unmounting...
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/proc left mounted, unmounting...
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/dev/pts left mounted, unmounting...
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/dev/shm left mounted, unmounting...
WARNING: build/tmp/work/debian-bookworm-amd64/isar-initramfs-qemuamd64/1.0-r0/rootfs/dev left mounted, unmounting...

Protect mounting with a trap for cleanup in case of failure.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/initramfs.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/classes/initramfs.bbclass b/meta/classes/initramfs.bbclass
index 42013356..0197a60b 100644
--- a/meta/classes/initramfs.bbclass
+++ b/meta/classes/initramfs.bbclass
@@ -35,6 +35,10 @@ do_generate_initramfs[sstate-inputdirs] = "${DEPLOYDIR}"
 do_generate_initramfs[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
 do_generate_initramfs() {
     rootfs_do_mounts
+
+    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+    trap 'rootfs_do_umounts' EXIT
+
     rootfs_do_qemu
 
     sudo -E chroot "${INITRAMFS_ROOTFS}" sh -c '\
-- 
2.34.1

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20241024101004.214465-1-amikan%40ilbers.de.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-25 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-24 10:10 [PATCH v2] initramfs: Avoid hanging mounts on failed update-initramfs Anton Mikanovich
2024-10-24 10:40 ` Uladzimir Bely
2024-10-24 10:42   ` Uladzimir Bely
2024-10-25 13:58 ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox