From 77628f7a30edac08d38ca9f8b008608e5db98c86 Mon Sep 17 00:00:00 2001 From: Marcelo Leitner Date: Tue, 4 Sep 2007 16:20:58 +0000 Subject: - Applies Blino's fix for removing chroot tarball if its build failed. - Enhance checking if the build failed by also checking if /usr/lib/rpm/rpmb is in place. - Scream and shout something when aborting due to this reason. --- lib/Iurt/Chroot.pm | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index 5167e93..d80fc1b 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -431,6 +431,7 @@ sub create_chroot { $rebuild = 1; if (!build_chroot($run, $config, $tmp_chroot, $chroot_tar, $opt)) { $clean->(); + sudo($run, $config, '--rm', '-r', $chroot, $chroot_tar); return; } } else { @@ -528,31 +529,34 @@ sub build_chroot { @{$opt->{packages}} ); - # FIXME: A proper warn could be given here, instead of aborting silently. - if (-f "$tmp_chroot/bin/rpm") { - system($sudo, 'sh', '-c', "chroot $tmp_chroot rpm -qa --qf '\%{NAME}-\%{VERSION}-\%{RELEASE}.\%{ARCH}.rpm\n' > $tmp_chroot/var/log/qa"); - # - # CM: Choose a sub-500 uid to prevent collison with $luser - # - system($sudo, 'chroot', $tmp_chroot, 'adduser', '-o', '--uid', 499, 'builder'); - sudo($run, $config, "--mkdir", "-p", "$tmp_chroot/home/builder/rpm"); - foreach my $p (qw(RPMS BUILD SPECS SRPMS SOURCES tmp)) { - -d "$tmp_chroot/home/builder/rpm/$p" and next; - sudo($run, $config, "--mkdir", "$tmp_chroot/home/builder/rpm/$p"); - } - system($sudo, 'chown', '-R', 499, "$tmp_chroot/home/builder"); - # FIXME: Be careful! Damn ugly hack right below! - sudo($run, $config, "--rm", "$tmp_chroot/var/lib/rpm/__db*"); - system("$sudo umount $tmp_chroot/proc &> /dev/null"); - system("$sudo umount $tmp_chroot/dev/pts &> /dev/null"); - if ($run->{icecream}) { - system("$sudo umount $tmp_chroot/var/cache/icecream &> /dev/null"); - } - if (-d "$tmp_chroot/urpmi_medias/") { - system ("$sudo umount $tmp_chroot/urpmi_medias"); - } - return !system($sudo, 'tar', 'czf', $chroot_tar, '-C', $tmp_chroot, '.'); + # Yes, /usr/lib/rpm/rpmb even for x86_64 + if (! -f "$tmp_chroot/bin/rpm" || ! -f "$tmp_chroot/usr/lib/rpm/rpmb") { + plog('ERROR', "Base packages missing in genenrated chroot."); + return 0; + } + + system($sudo, 'sh', '-c', "chroot $tmp_chroot rpm -qa --qf '\%{NAME}-\%{VERSION}-\%{RELEASE}.\%{ARCH}.rpm\n' > $tmp_chroot/var/log/qa"); + # + # CM: Choose a sub-500 uid to prevent collison with $luser + # + system($sudo, 'chroot', $tmp_chroot, 'adduser', '-o', '--uid', 499, 'builder'); + sudo($run, $config, "--mkdir", "-p", "$tmp_chroot/home/builder/rpm"); + foreach my $p (qw(RPMS BUILD SPECS SRPMS SOURCES tmp)) { + -d "$tmp_chroot/home/builder/rpm/$p" and next; + sudo($run, $config, "--mkdir", "$tmp_chroot/home/builder/rpm/$p"); + } + system($sudo, 'chown', '-R', 499, "$tmp_chroot/home/builder"); + # FIXME: Be careful! Damn ugly hack right below! + sudo($run, $config, "--rm", "$tmp_chroot/var/lib/rpm/__db*"); + system("$sudo umount $tmp_chroot/proc &> /dev/null"); + system("$sudo umount $tmp_chroot/dev/pts &> /dev/null"); + if ($run->{icecream}) { + system("$sudo umount $tmp_chroot/var/cache/icecream &> /dev/null"); + } + if (-d "$tmp_chroot/urpmi_medias/") { + system ("$sudo umount $tmp_chroot/urpmi_medias"); } + return !system($sudo, 'tar', 'czf', $chroot_tar, '-C', $tmp_chroot, '.'); } sub check_build_chroot { -- cgit v1.2.1