+tmpfs on newbuild/tmp/work/debian-bookworm-amd64/sbuild-chroot-target/1.0-r0/rootfs/dev type tmpfs (rw,nosuid,size=4096k,nr_inodes=65536,mode=755,inode64)
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/rootfs.bbclass | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
@@ -248,18 +248,21 @@ python do_rootfs_install() {
progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
d.rootfs_progress = progress_reporter
- for cmd in cmds:
- progress_reporter.next_stage()
+ try:
+ for cmd in cmds:
+ progress_reporter.next_stage()
- if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "acquire-before":
- lock = bb.utils.lockfile(d.getVar("REPO_ISAR_DIR") + "/isar.lock",
- shared=True)
+ if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "acquire-before":
+ lock = bb.utils.lockfile(d.getVar("REPO_ISAR_DIR") + "/isar.lock",
+ shared=True)
- bb.build.exec_func(cmd, d)
+ bb.build.exec_func(cmd, d)
- if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "release-after":
- bb.utils.unlockfile(lock)
- progress_reporter.finish()
+ if (d.getVarFlag(cmd, 'isar-apt-lock') or "") == "release-after":
+ bb.utils.unlockfile(lock)
+ progress_reporter.finish()
+ finally:
+ bb.build.exec_func('rootfs_do_umounts', d)
}
addtask rootfs_install before do_rootfs_postprocess after do_unpack
@@ -379,9 +382,13 @@ python do_rootfs_postprocess() {
if cmds is None or not cmds.strip():
return
cmds = cmds.split()
- for i, cmd in enumerate(cmds):
- bb.build.exec_func(cmd, d)
- progress_reporter.update(int(i / len(cmds) * 100))
+
+ try:
+ for i, cmd in enumerate(cmds):
+ bb.build.exec_func(cmd, d)
+ progress_reporter.update(int(i / len(cmds) * 100))
+ finally:
+ bb.build.exec_func('rootfs_do_umounts', d)
}
addtask rootfs_postprocess before do_rootfs after do_unpack
From: Florian Bezdeka <florian.bezdeka@siemens.com> Calls to rootfs_do_mounts should always be paired with calls to rootfs_do_umounts. With this change, it is done in do_rootfs_install and do_rootfs_postprocess. In case there was an exception thrown within the try blocks they will be re-raised after the finally block has been processed. This way we try to avoid leaking mounts but unmounting might still fail. In any case we tried our best to clean up. To reproduce: . ./isar-init-build-env newbuild mount >01.txt cat >conf/local.conf <<EOF MACHINE = "qemuamd64" DISTRO = "debian-bookworm" DISTRO_ARCH = "amd64" EOF bitbake sbuild-chroot-target mount >02.txt