aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2023-12-03 18:31:21 +0000
committerPascal Terjan <pterjan@mageia.org>2023-12-03 18:34:20 +0000
commit42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0 (patch)
tree7023b65faeef2fc7fd0e44f1a152c794aae4c5c1
parent710c3c7b2d545faf86a22cfbc61a1e88ebf38461 (diff)
downloadiurt-42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0.tar
iurt-42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0.tar.gz
iurt-42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0.tar.bz2
iurt-42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0.tar.xz
iurt-42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0.zip
iurt: Use the target dir when rebuilding chroot
Currently we when building a tmpdir, making a tar of it, deleting it and then untar into the target.
-rw-r--r--NEWS1
-rw-r--r--lib/Iurt/Chroot.pm41
2 files changed, 17 insertions, 25 deletions
diff --git a/NEWS b/NEWS
index e31303d..e76243e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@
machines
- iurt: Fix / of the chroot belonging to the user instead of root
- iurt: Make generation of the chroot archive more atomic
+- iurt: Use the target directory when reference chroot needs to be updated
0.8.2.2
- ulri: Fix a crash after build failures
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index d87a6b9..8a2e04b 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -317,53 +317,44 @@ sub create_build_chroot {
sub create_build_chroot_tar {
my ($chroot, $chroot_tar, $run, $config) = @_;
- my $tmp_chroot = mktemp("$chroot.tmp.XXXXXX");
my $rebuild;
- my $clean = sub {
- plog("Remove temporary chroot");
- sudo($config, '--rm', '-r', $tmp_chroot);
- };
plog('NOTIFY', "creating chroot");
- # Create this directory as root as it will be / of the chroot
- sudo($config, "--mkdir", "-p", "$tmp_chroot");
if (!-f $chroot_tar) {
plog("rebuild chroot tarball");
$rebuild = 1;
} elsif (!$run->{fixed_media}) {
- plog('DEBUG', "decompressing /var/log/qa from $chroot_tar in $tmp_chroot");
- sudo($config, '--untar', $chroot_tar, $tmp_chroot, "./var/log/qa");
- $rebuild = check_chroot_need_update($tmp_chroot, $run, $config);
+ my $tmp_chroot = mktemp("$chroot.tmp.XXXXXX");
+ sudo($config, "--mkdir", "-p", "$tmp_chroot");
+ plog('DEBUG', "decompressing /var/log/qa from $chroot_tar in $tmp_chroot");
+ sudo($config, '--untar', $chroot_tar, $tmp_chroot, "./var/log/qa");
+ $rebuild = check_chroot_need_update($tmp_chroot, $run, $config);
+ sudo($config, '--rm', '-r', $tmp_chroot);
}
+ sudo($config, '--rm', '-r', $chroot);
+ # Create this directory as root as it will be / of the chroot
+ sudo($config, "--mkdir", "-p", "$chroot");
if ($rebuild) {
- sudo($config, '--rm', '-r', $chroot);
- if (!build_chroot($run, $config, $tmp_chroot)) {
+ if (!build_chroot($run, $config, $chroot)) {
plog('NOTIFY', "creating chroot failed.");
- $clean->();
+ sudo($config, '--rm', '-r', $chroot);
return;
}
+ plog('NOTIFY', "chroot recreated in $chroot");
my $tmp_tar = mktemp("$chroot_tar.tmp.XXXXXX");
- sudo($config, "--tar", $chroot_tar, $tmp_chroot);
+ sudo($config, "--tar", $chroot_tar, $chroot);
if (rename($tmp_tar, $chroot_tar)) {
plog('NOTIFY', "archive creation failed.");
unlink($tmp_tar);
- $clean->();
return;
}
-
- }
-
- if (!-d $chroot) {
- plog('DEBUG', "recreate chroot $chroot");
- plog('NOTIFY', "recreate chroot");
- sudo($config, "--mkdir", "-p", "$tmp_chroot");
+ plog('NOTIFY', "chroot archived in $chroot_tar");
+ } else {
sudo($config, '--untar', $chroot_tar, $chroot);
- plog('NOTIFY', "chroot recreated in $chroot_tar (live in $chroot)");
+ plog('NOTIFY', "chroot recreated in $chroot (from $chroot_tar)");
}
-
- $clean->();
1;
}