From 6141ed458a08389136e0a89878bb33b96e5ca6f4 Mon Sep 17 00:00:00 2001 From: Marcelo Leitner Date: Tue, 19 Jun 2007 14:00:10 +0000 Subject: - Protect chroot removal if there is still mount points referencing it. - Also list our two new mountpoints in yet other chroot cleanup function. --- lib/Iurt/Chroot.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Iurt') 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/"); } -- cgit v1.2.1