diff options
-rw-r--r-- | lib/Iurt/Chroot.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index 42974bc..338f40d 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -51,6 +51,16 @@ sub clean_chroot { if (-d "$chroot/urpmi_medias/") { system ("$sudo umount $chroot/urpmi_medias"); } + + # Do not run rm if there is something still mounted there + open (my $FP, "/proc/mounts") or die $!; + my @list = grep { /$chroot/ } <$FP>; + close ($FP); + if ($#list >= 0) { + # Still referenced + return 1; + } + sudo($run, $config, '--rm', '-r', $chroot); } @@ -326,7 +336,7 @@ sub clean_chroot_tmp { my ($run, $chroot_dir, $dir) = @_; my $d = "$chroot_dir/$dir"; - foreach my $m ('proc', 'dev/pts') { + foreach my $m ('proc', 'dev/pts', 'urpmi_medias', 'var/cache/icecream') { if (system("$sudo umount $d/$m &>/dev/null") && $run->{verbose} > 1) { plog("ERROR: could not umount /$m in $d/"); } |