aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt/Chroot.pm
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2023-11-26 21:38:04 +0000
committerPascal Terjan <pterjan@mageia.org>2023-11-26 21:51:06 +0000
commit7ff06658a899afdc3a3445b66a88cb67ddc00fed (patch)
tree53112dc9809995274eadee07733392333d265893 /lib/Iurt/Chroot.pm
parent92a5f7b1c1980be0ed210f03d44b1160d1d801de (diff)
downloadiurt-7ff06658a899afdc3a3445b66a88cb67ddc00fed.tar
iurt-7ff06658a899afdc3a3445b66a88cb67ddc00fed.tar.gz
iurt-7ff06658a899afdc3a3445b66a88cb67ddc00fed.tar.bz2
iurt-7ff06658a899afdc3a3445b66a88cb67ddc00fed.tar.xz
iurt-7ff06658a899afdc3a3445b66a88cb67ddc00fed.zip
iurt: Fix / of the chroot belonging to the user instead of root
Diffstat (limited to 'lib/Iurt/Chroot.pm')
-rw-r--r--lib/Iurt/Chroot.pm19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index 34520d1..4949828 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -272,12 +272,13 @@ sub check_mounted {
}
sub check_chroot_need_update {
- my ($tmp_chroot, $run) = @_;
+ my ($tmp_chroot, $run, $config) = @_;
- my $tmp_urpmi = mktemp("$tmp_chroot/tmp.XXXXXX");
+ sudo($config, '--mkdir', "-m", 01777, "$tmp_chroot/tmp");
+ my $tmp_urpmi = mktemp("$tmp_chroot/tmp/tmp.XXXXXX");
mkdir_p("$tmp_urpmi/tmp");
my @installed_pkgs = grep { !/^gpg-pubkey/ } chomp_(cat_("$tmp_chroot/var/log/qa"));
- my @available_pkgs = chomp_(`urpmq --urpmi-root $tmp_urpmi --use-distrib $run->{urpmi}{distrib_url} --list -f 2>/dev/null`);
+ my @available_pkgs = chomp_(`urpmq --urpmi-root $tmp_urpmi --use-distrib $run->{urpmi}{distrib_url} --list -f`);
my @removed_pkgs = difference2(\@installed_pkgs, \@available_pkgs);
rm_rf($tmp_urpmi);
@@ -325,14 +326,15 @@ sub create_build_chroot_tar {
plog('NOTIFY', "creating chroot");
- mkdir_p($tmp_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);
+ $rebuild = check_chroot_need_update($tmp_chroot, $run, $config);
}
if ($rebuild) {
@@ -343,15 +345,12 @@ sub create_build_chroot_tar {
return;
}
sudo($config, "--tar", $chroot_tar, $tmp_chroot);
- # This rename may fail if for example tmp chroots are in another FS
- # This does not matter as it will then be rm + untar
- rename $tmp_chroot, $chroot;
}
if (!-d $chroot) {
plog('DEBUG', "recreate chroot $chroot");
plog('NOTIFY', "recreate chroot");
- mkdir_p $chroot;
+ sudo($config, "--mkdir", "-p", "$tmp_chroot");
sudo($config, '--untar', $chroot_tar, $chroot);
plog('NOTIFY', "chroot recreated in $chroot_tar (live in $chroot)");
}
@@ -367,7 +366,7 @@ sub create_build_chroot_btrfs {
plog('NOTIFY', "creating btrfs chroot");
# TODO: Handle $run{fixed_media}
- if (check_chroot_need_update($chroot_ref, $run)) {
+ if (check_chroot_need_update($chroot_ref, $run, $config)) {
sudo($config, '--btrfs_delete', $chroot_ref);
if (!sudo($config, '--btrfs_create', $chroot_ref)) {
plog('ERROR', "creating btrfs subvolume failed.");