aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2023-11-29 22:06:22 +0000
committerPascal Terjan <pterjan@mageia.org>2023-11-29 22:06:22 +0000
commit710c3c7b2d545faf86a22cfbc61a1e88ebf38461 (patch)
tree197655a48b4d8d91233a94f6112ffc01d2f2da61
parent7ff06658a899afdc3a3445b66a88cb67ddc00fed (diff)
downloadiurt-710c3c7b2d545faf86a22cfbc61a1e88ebf38461.tar
iurt-710c3c7b2d545faf86a22cfbc61a1e88ebf38461.tar.gz
iurt-710c3c7b2d545faf86a22cfbc61a1e88ebf38461.tar.bz2
iurt-710c3c7b2d545faf86a22cfbc61a1e88ebf38461.tar.xz
iurt-710c3c7b2d545faf86a22cfbc61a1e88ebf38461.zip
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.
-rw-r--r--NEWS1
-rw-r--r--lib/Iurt/Chroot.pm8
2 files changed, 9 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 2ab56eb..e31303d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
- rebuild_perl_iurt: set --target to correctly build for armv7hl on aarch64
machines
- iurt: Fix / of the chroot belonging to the user instead of root
+- iurt: Make generation of the chroot archive more atomic
0.8.2.2
- ulri: Fix a crash after build failures
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) {