From 043bdaac34236a8505238dc8d99a6822fe0c3107 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 17 Apr 2012 20:50:23 +0000 Subject: (_clean_mounts) factorize cleaning --- lib/Iurt/Chroot.pm | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index a897d5d..25949bd 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -40,11 +40,7 @@ sub clean_chroot { plog('DEBUG', "clean chroot"); if (-d $chroot) { - sudo($config, "--umount", "$chroot/proc"); - sudo($config, "--umount", "$chroot/dev/pts"); - if ($run->{icecream}) { - sudo($config, "--umount", "$chroot/var/cache/icecream"); - } + _clean_mounts($run, $config, $chroot); if (-d "$chroot/urpmi_medias/") { sudo($config, "--umount", "$chroot/urpmi_medias"); } @@ -85,8 +81,7 @@ sub clean_chroot { system("$sudo mkdir -p $chroot/var/cache/icecream"); if (!sudo($config, '--bindmount', "/var/cache/icecream", "$chroot/var/cache/icecream")) { plog('ERROR', "Failed to mount var/cache/icecream"); - sudo($config, "--umount", "$chroot/proc"); - sudo($config, "--umount", "$chroot/dev/pts"); + _clean_mounts($run, $config, $chroot); return; } } @@ -99,11 +94,7 @@ sub clean_chroot { sudo($config, '--mkdir', '-p', $mount_point); if (!sudo($config, '--bindmount', $url, $mount_point)) { plog('ERROR', "Failed to mount $url on $mount_point"); - sudo($config, "--umount", "$chroot/proc"); - sudo($config, "--umount", "$chroot/dev/pts"); - if ($run->{icecream}) { - sudo($config, "--umount", "$chroot/var/cache/icecream"); - } + _clean_mounts($run, $config, $chroot); return; } } @@ -111,6 +102,16 @@ sub clean_chroot { 1; } +sub _clean_mounts { + my ($run, $config, $chroot) = @_; + sudo($config, "--umount", "$chroot/proc"); + sudo($config, "--umount", "$chroot/dev/pts"); + + if ($run->{icecream}) { + sudo($config, "--umount", "$chroot/var/cache/icecream"); + } +} + sub dump_rpmmacros { my ($run, $config, $file) = @_; my $f; -- cgit v1.2.1