diff options
author | Florent Villard <warly@mandriva.com> | 2005-12-29 15:24:49 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2005-12-29 15:24:49 +0000 |
commit | 7ca577dcb8ded863910112ab3f2c39bd4922e2e2 (patch) | |
tree | 51a2b20a1a9d9af044349ff90f1bbc9ca30baa24 /iurt2 | |
parent | 09499a12408238635b2df0f1d3b94ed320e18506 (diff) | |
download | iurt-7ca577dcb8ded863910112ab3f2c39bd4922e2e2.tar iurt-7ca577dcb8ded863910112ab3f2c39bd4922e2e2.tar.gz iurt-7ca577dcb8ded863910112ab3f2c39bd4922e2e2.tar.bz2 iurt-7ca577dcb8ded863910112ab3f2c39bd4922e2e2.tar.xz iurt-7ca577dcb8ded863910112ab3f2c39bd4922e2e2.zip |
Add a debug mode; try to guess who is responsible when a package dependency cannot be installed
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 127 |
1 files changed, 87 insertions, 40 deletions
@@ -29,12 +29,18 @@ use File::NCopy qw(copy); use MIME::Words qw(encode_mimewords); use Fcntl ':flock'; -my $distro_version = shift @ARGV; +my ($debug); +my @argv = grep { + if (/--debug/) { $debug = 1; 0 } + else { 1 } +} @ARGV; + +my $distro_version = shift @argv; my $distro_tag = $distro_version; $distro_tag =~ s,/,-,g; -my $my_arch = shift @ARGV; -my $media = shift @ARGV; -my @special_srpm_dir = @ARGV; +my $my_arch = shift @argv; +my $media = shift @argv; +my @special_srpm_dir = @argv; $my_arch or usage(); @@ -72,38 +78,40 @@ if ($distro_version ne 'cooker') { -d $config->{upload} or usage("$config->{upload} does not exist"); my $pidfile = "$config->{cache_home}/iurt.$distro_tag.$my_arch.pid"; -open my $lock, "$pidfile.lock"; -flock($lock,LOCK_EX); -if (-f $pidfile) { - my (@stat) = stat $pidfile; - open my $test_PID, $pidfile; - my $pid = <$test_PID>; - close $test_PID; - if ($pid && getpgrp $pid != -1) { - my $time = $stat[9]; - if ($time < time - 36000) { - print "iurt: an other iurt pid $pid is running for a very long time, killing it\n"; - my $i; - while ($i < 5 && getpgrp $pid != -1) { - kill_for_good($pid); - $i++; - sleep 1 +if (!$debug) { + open my $lock, "$pidfile.lock"; + flock($lock,LOCK_EX); + if (-f $pidfile) { + my (@stat) = stat $pidfile; + open my $test_PID, $pidfile; + my $pid = <$test_PID>; + close $test_PID; + if ($pid && getpgrp $pid != -1) { + my $time = $stat[9]; + if ($time < time - 36000) { + print "iurt: an other iurt pid $pid is running for a very long time, killing it\n"; + my $i; + while ($i < 5 && getpgrp $pid != -1) { + kill_for_good($pid); + $i++; + sleep 1 + } + } else { + print "iurt: an other iurt is running for $my_arch, pid $pid, since ",time - $time," seconds\n"; + # exit } - } else { - print "iurt: an other iurt is running for $my_arch, pid $pid, since ",time - $time," seconds\n"; - exit + } else { + print "iurt: a previous iurt for $my_arch seems dead, cleaning.\n"; + unlink $pidfile } - } else { - print "iurt: a previous iurt for $my_arch seems dead, cleaning.\n"; - unlink $pidfile } -} -open my $PID, ">$pidfile" or die "FATAL iurt: could not open pidfile $pidfile for writing"; -print $PID $$; -close $PID; + open my $PID, ">$pidfile" or die "FATAL iurt: could not open pidfile $pidfile for writing"; + print $PID $$; + close $PID; -flock($lock,LOCK_UN); -close $lock; + flock($lock,LOCK_UN); + close $lock; +} my $cachefile = "$config->{cache_home}/iurt.$distro_tag.cache"; print "iurt: loading cache file $cachefile\n"; @@ -188,7 +196,7 @@ foreach my $dir ("$config->{repository}/$distro_version/SRPMS/$media/", @special dump_cache(); -if (!@todo) { +if (!@todo && !$debug) { print "iurt: nothing to do\n"; unlink $pidfile; exit @@ -198,12 +206,14 @@ my $run = $cache->{run}{$distro_tag}{$my_arch}++; print "iurt: checking basesystem tar\n"; -my $chroot = "$config->{local_home}/chroot"; +my $debug_tag = '_debug' if $debug; +my $chroot = "$config->{local_home}/chroot$debug_tag"; my $chroot_tar = "$chroot-$distro_tag.$my_arch.tar.gz"; perform_command("sudo $config->{install_chroot_binary} cooker $config->{repository}/$distro_version/$my_arch/media/main/ $chroot_tar $chroot 501 basesystem rpm-build", mail => 'maintainers@mandriva.com', error => "[REBUILD] Creating the inital chroot for $distro_tag on $my_arch failed", hash => 'chroot_inititialization', + debug_mail => $debug, die => 1); my $local_spool = "$config->{local_home}/iurt/$distro_tag/$my_arch"; @@ -221,17 +231,20 @@ foreach my $t (@todo) { $done{$srpm} and next; $done{$srpm} = 1; check_version($srpm) or next; + $debug++ == 2 and exit; print "iurt: installing a new chroot for $srpm in $chroot\n"; -d $chroot and perform_command("sudo rm -rf $chroot", mail => $config->{admin}, error => "[REBUILD] Deleting of old chroot $chroot failed", hash => 'chroot_deletion', + debug_mail => $debug, die => 1); mkdir $chroot; perform_command("pushd $chroot && sudo tar xvf $chroot_tar", mail => $config->{admin}, error => "[REBUILD] creating the initial chroot $chroot failed", hash => 'chroot_init', + debug_mail => $debug, die => 1); dump_rpmmacros("$chroot/home/builder/.rpmmacros") or next; @@ -255,17 +268,33 @@ foreach my $t (@todo) { timeout => 600, freq => 48, cc => $cc, + debug_mail => $debug, error_regexp => 'cannot be installed', wait_regexp => 'database locked', - log => "$local_spool/log/") or next; + log => "$local_spool/log/", + callback => sub { + my ($opt, $output) = @_; + print "Calling callback for $opt->{hash}\n" if $debug; + my ($missing_deps) = $output =~ /\(due to unsatisfied ([^[)]*)/; + my $other_maint = `rpmmon -p $missing_deps`; + chomp $other_maint; + print "Missing Dep: $missing_deps ($other_maint)\n"; + if ($other_maint) { + $opt->{mail} = $other_maint; + $opt->{error} = "[MISSING] $missing_deps, needed to build $srpm, is not available on $my_arch"; + } + }, + ) or next; perform_command("sudo chroot $chroot rpm -qa", hash => "rpm_qa_$srpm", timeout => 60, + debug_mail => $debug, log => "$local_spool/log/") or next; print "Copying $srpm to $chroot\n"; perform_command("sudo cp $dir/$srpm $chroot/home/builder/rpm/SRPMS/", mail => $config->{admin}, error => "[REBUILD] cannot copy $srpm to $chroot", + debug_mail => $debug, hash => "copy_$srpm") or next; print "Compiling $srpm\n"; #system(qq{sudo chroot $chroot /bin/su builder -c "mkdir rpm/RPMS/x86_64 rpm/RPMS/noarch"}); @@ -274,6 +303,7 @@ foreach my $t (@todo) { error => "[REBUILD] $srpm from $distro_tag does not build correctly on $my_arch", hash => "build_$srpm", timeout => 18000, + debug_mail => $debug, cc => $cc, log => "$local_spool/log/", error_regexp => 'rror.*ailed|Bad exit status|RPM build error', @@ -286,14 +316,20 @@ foreach my $t (@todo) { error => "[REBUILD] binaries packages generated from $srpm do not install correctly", hash => "binary_test_$srpm", timeout => 300, + debug_mail => $debug, freq => 1, error_regexp => 'unable to access', log => "$local_spool/log/")) { $cache->{failure}{$srpm}{$my_arch} = 1; next } - system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool") and print "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; - process_queue(); + if ($debug) { + print "iurt: debug mode, skip other packages\n"; + exit + } else { + system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool") and print "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; + process_queue() + } } print "iurt: reprocess generated packages queue\n"; @@ -324,9 +360,13 @@ sub usage { usage: - iurt <distro version> <arch> <media> + iurt [options] <distro version> <arch> <media> e.g. iurt community/2006.0 x86_64 main + options: + --debug: Compile one package in debug mode (do not send mail, create + chroot_debug directory). This mode can be used on a system + where a iurt is already running. "; exit } @@ -428,6 +468,10 @@ sub perform_command { print "Timeout $opt{timeout}\n"; # from alarm perldoc my $output; + if ($opt{debug}) { + print "Would have rum $command with a timeout of $opt{timeout}\n"; + return 1 + } eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $opt{timeout}; @@ -444,15 +488,18 @@ sub perform_command { die unless $@ eq "alarm\n"; # propagate unexpected errors return 0 } else { + if ($opt{callback}) { + $opt{callback}(\%opt, $output) + } if ($output =~ /$opt{wait_regexp}/) { return 0 } if ($? || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) { if ($opt{mail} && $config->{sendmail}) { if (! $cache->{warning}{$opt{hash}}{$my_arch}{$opt{mail}} % $opt{freq}) { - sendmail($opt{mail}, $opt{cc} , $opt{error} , $output, 0, 0); + sendmail($opt{mail}, $opt{cc} , $opt{error} , $output, 0, 0, $opt{debug_mail}); } elsif ($config->{admin}) { - sendmail($config->{admin}, '' , $opt{error}, $output, 0, 0); + sendmail($config->{admin}, '' , $opt{error}, $output, 0, 0, $opt{debug_mail}); } } $cache->{warning}{$opt{hash}}{$my_arch}{$opt{mail}}++; |