From deb2e54dfcd4819571645a9385d5088e06d5de89 Mon Sep 17 00:00:00 2001 From: Marcelo Leitner Date: Tue, 6 Nov 2007 15:21:54 +0000 Subject: - Replace a chdir call with tar -C option and avoid further errors due to the path change. - Better syntax putting in evidence a duplicated code. --- lib/Iurt/Chroot.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index d80fc1b..93c63cd 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -70,13 +70,22 @@ sub clean_chroot { mkdir $chroot; # various integrity checking - return 1 if $o_only_tar && -f "$chroot/home/builder/.rpmmacros" && -d "$chroot/home/builder" && -d "$chroot/proc"; + if ($o_only_tar + && -f "$chroot/home/builder/.rpmmacros" + && -d "$chroot/home/builder" + && -d "$chroot/proc") { + return 1; + } - chdir $chroot; - - system($sudo, 'tar', 'xf', $chroot_tar) and create_build_chroot($chroot, $chroot_tar, $run, $config); + # First try + if (system($sudo, 'tar', '-C', $chroot, '-xf', $chroot_tar)) { + create_build_chroot($chroot, $chroot_tar, $run, $config); + } - create_build_chroot($chroot, $chroot_tar, $run, $config) if !-d "$chroot/proc" || !-d "$chroot/home/builder"; + # 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"); -- cgit v1.2.1