deb-dl-dir: Avoid hanging mounts on failed download

Message ID 20241017075727.101424-1-amikan@ilbers.de
State Accepted, archived
Headers show
Series deb-dl-dir: Avoid hanging mounts on failed download | expand

Commit Message

Anton Mikanovich Oct. 17, 2024, 7:57 a.m. UTC
If apt-get fails during debsrc_download execution there will be mount
left behind. Protect it with a trap for cleanup in case of failure.

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

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index 55e56c50..7ebd057e 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -48,6 +48,9 @@  debsrc_download() {
 
     debsrc_do_mounts "${rootfs}"
 
+    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+    trap 'debsrc_undo_mounts "${rootfs}"' EXIT
+
     ( flock 9
     set -e
     printenv | grep -q BB_VERBOSE_LOGS && set -x