From dd9fe45232d5d7713d1a589b966e18e2bf908f82 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Thu, 28 Apr 2011 11:55:20 +0000 Subject: Improve error cases and fix previous commit (thanks blino) --- lib/Iurt/Chroot.pm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index 33a1ef3..b7b2f3b 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -77,19 +77,12 @@ sub clean_chroot { return 1; } - # First try - if (sudo($run, $config, '--untar', $chroot_tar, $chroot)) { - create_build_chroot($chroot, $chroot_tar, $run, $config); - } else { - plog('ERROR', "Failed to untar chroot"); + sudo($run, $config, '--untar', $chroot_tar, $chroot); + if (!create_build_chroot($chroot, $chroot_tar, $run, $config)) { + plog('ERROR', "Failed to create chroot"); return; } - # 20071106 Second try? - if (!-d "$chroot/proc" || !-d "$chroot/home/builder") { - create_build_chroot($chroot, $chroot_tar, $run, $config); - } - if (!dump_rpmmacros($run, $config, "$chroot/home/builder/.rpmmacros")) { plog('ERROR', "Failed to dump macros"); return; @@ -100,12 +93,15 @@ sub clean_chroot { } if (!sudo($run, $config, '--bindmount', "/dev/pts", "$chroot/dev/pts")) { plog('ERROR', "Failed to mount dev/pts"); + sudo($run, $config, "--umount", "$chroot/proc"); return; } if ($run->{icecream}) { system("$sudo mkdir -p $chroot/var/cache/icecream"); if (!sudo($run, $config, '--bindmount', "/var/cache/icecream", "$chroot/var/cache/icecream")) { plog('ERROR', "Failed to mount var/cache/icecream"); + sudo($run, $config, "--umount", "$chroot/proc"); + sudo($run, $config, "--umount", "$chroot/dev/pts"); return; } } @@ -119,6 +115,11 @@ sub clean_chroot { sudo($run, $config, '--mkdir', '-p', $mount_point); if (!sudo($run, $config, '--bindmount', $url, $mount_point)) { plog('ERROR', "Failed to mount $url on $mount_point"); + sudo($run, $config, "--umount", "$chroot/proc"); + sudo($run, $config, "--umount", "$chroot/dev/pts"); + if ($run->{icecream}) { + sudo($run, $config, "--umount", "$chroot/var/cache/icecream"); + } return; } } -- cgit v1.2.1