[v2,1/3] image: Avoid breaking the build when mounts are no longer present on umount

Message ID c84a1a48568e0204b0eb36fedb8af4a2809f199a.1727795639.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series Start to address umount problems | expand

Commit Message

Jan Kiszka Oct. 1, 2024, 3:13 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

This does not seem to trigger yet because we always have those
mountpoints present. But if that is no longer the case, we will bail out
when mountpoint fails due to the set -e.

Fixes: 165519a7b314 ("sudo: Fail on the first error")
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/image.bbclass | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index c29d9e26..ef25df49 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -406,24 +406,31 @@  do_rootfs_finalize() {
                 -maxdepth 1 -name 'qemu-*-static' -type f -delete
         fi
 
-        mountpoint -q '${ROOTFSDIR}/isar-apt' && \
-            umount '${ROOTFSDIR}/isar-apt' && \
+        if mountpoint -q '${ROOTFSDIR}/isar-apt'; then
+            umount '${ROOTFSDIR}/isar-apt'
             rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
+        fi
 
-        mountpoint -q '${ROOTFSDIR}/base-apt' && \
-            umount '${ROOTFSDIR}/base-apt' && \
+        if mountpoint -q '${ROOTFSDIR}/base-apt'; then
+            umount '${ROOTFSDIR}/base-apt'
             rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
+        fi
 
-        mountpoint -q '${ROOTFSDIR}/dev/pts' && \
+        if mountpoint -q '${ROOTFSDIR}/dev/pts'; then
             umount '${ROOTFSDIR}/dev/pts'
-        mountpoint -q '${ROOTFSDIR}/dev/shm' && \
+        fi
+        if mountpoint -q '${ROOTFSDIR}/dev/shm'; then
             umount '${ROOTFSDIR}/dev/shm'
-        mountpoint -q '${ROOTFSDIR}/dev' && \
+        fi
+        if mountpoint -q '${ROOTFSDIR}/dev'; then
             umount '${ROOTFSDIR}/dev'
-        mountpoint -q '${ROOTFSDIR}/proc' && \
+        fi
+        if mountpoint -q '${ROOTFSDIR}/proc'; then
             umount '${ROOTFSDIR}/proc'
-        mountpoint -q '${ROOTFSDIR}/sys' && \
+        fi
+        if mountpoint -q '${ROOTFSDIR}/sys'; then
             umount '${ROOTFSDIR}/sys'
+        fi
 
         if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ]; then
             mv "${ROOTFSDIR}/etc/apt/sources-list" \