From 710c3c7b2d545faf86a22cfbc61a1e88ebf38461 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Wed, 29 Nov 2023 22:06:22 +0000 Subject: iurt: Make generation of the chroot archive more atomic We may still use the wrong chroot but at least the .tar shoudl not be corrupted. --- lib/Iurt/Chroot.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/Iurt/Chroot.pm') diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index 4949828..d87a6b9 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -344,7 +344,15 @@ sub create_build_chroot_tar { $clean->(); return; } + my $tmp_tar = mktemp("$chroot_tar.tmp.XXXXXX"); sudo($config, "--tar", $chroot_tar, $tmp_chroot); + if (rename($tmp_tar, $chroot_tar)) { + plog('NOTIFY', "archive creation failed."); + unlink($tmp_tar); + $clean->(); + return; + } + } if (!-d $chroot) { -- cgit v1.2.1