diff options
-rwxr-xr-x | iurt2 | 94 |
1 files changed, 63 insertions, 31 deletions
@@ -372,6 +372,7 @@ my $done; my $home = $config->{local_home}; my $union_id = 1; my $unionfs_tmp = $run{unionfs}; +my $chroot_tmp = "$chroot.$run{run}"; foreach (my $i ; $i < @{$run{todo}}; $i++) { my ($dir, $srpm) = @{$run{todo}[$i]}; $done{$srpm} and next; @@ -383,7 +384,7 @@ foreach (my $i ; $i < @{$run{todo}}; $i++) { print {$run{LOG}} "iurt: packages $srpm [$done/$to_compile]\n"; # FIXME unfortunately urpmi stalls quite often retry: - my $match = "urpmi $urpmi_options --root $chroot"; + my $match = "urpmi $urpmi_options --root $chroot_tmp"; if (!clean_process($match, $run{verbose})) { dump_cache(\%run); die "FATAL iurt: Could not have urpmi working !" @@ -400,23 +401,23 @@ retry: # we cannont just rm -rf $tmpfs, this create defunct processes afterwards (and lock particularly hard the urpmi database) $union_id = clean_unionfs($unionfs_dir, $run{run}, $union_id); $tmpfs = "$unionfs_dir/tmpfs.$run{run}.$union_id"; - $chroot = "$unionfs_dir/unionfs.$run{run}.$union_id"; + $chroot_tmp = "$unionfs_dir/unionfs.$run{run}.$union_id"; mkdir $tmpfs or die "Could not create $tmpfs ($!)"; - mkdir $chroot or die "Could not create $chroot ($!)"; + mkdir $chroot_tmp or die "Could not create $chroot_tmp ($!)"; if ($cache->{no_unionfs}{$srpm}) { $unionfs_tmp = 0; - clean_chroot($chroot, \%run) + clean_chroot($chroot_tmp, \%run) } else { # if the previous package has been built without unionfs, chroot need to be cleaned - clean_chroot($chroot, \%run) if !$unionfs_tmp; + clean_chroot($chroot_tmp, \%run) if !$unionfs_tmp; $unionfs_tmp = 1; system(qq{sudo mount -t tmpfs none $tmpfs &>/dev/null}) and die "FATAL iurt: could not mount $tmpfs ($!)"; - system(qq|sudo mount -o dirs=$tmpfs=rw:$home/chroot_$run{distro_tag}$debug_tag=ro -t unionfs none $chroot &>/dev/null|) and die "FATAL iurt: could not mount $tmpfs and $home/chroot_$run{distro_tag}$debug_tag with unionfs ($!)"; - system("sudo mount -t proc none $chroot/proc &>/dev/null") and die "FATAL iurt: could not mount /proc in the chroot $chroot."; + system(qq|sudo mount -o dirs=$tmpfs=rw:$home/chroot_$run{distro_tag}$debug_tag=ro -t unionfs none $chroot_tmp &>/dev/null|) and die "FATAL iurt: could not mount $tmpfs and $home/chroot_$run{distro_tag}$debug_tag with unionfs ($!)"; + system("sudo mount -t proc none $chroot_tmp/proc &>/dev/null") and die "FATAL iurt: could not mount /proc in the chroot $chroot_tmp."; } } else { - print {$run{LOG}} "iurt: installing a new chroot for $srpm in $chroot\n" if $run{verbose} > 1; - clean_chroot($chroot, \%run) + print {$run{LOG}} "iurt: installing a new chroot for $srpm in $chroot_tmp\n" if $run{verbose} > 1; + clean_chroot($chroot_tmp, \%run) } my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next; my ($maintainer, $cc); @@ -432,28 +433,28 @@ retry: #($maintainer, $cc) = ($config->{admin},''); # recreate a new srpm for buildarch condition in the spec file - print {$run{LOG}} "Copying $srpm to $chroot\n" if $run{verbose} > 1; - perform_command("sudo cp $dir/$srpm $chroot/home/builder/rpm/SRPMS/", + print {$run{LOG}} "Copying $srpm to $chroot_tmp\n" if $run{verbose} > 1; + perform_command("sudo cp $dir/$srpm $chroot_tmp/home/builder/rpm/SRPMS/", \%run, $config, mail => $config->{admin}, - error => "[REBUILD] cannot copy $srpm to $chroot", + error => "[REBUILD] cannot copy $srpm to $chroot_tmp", debug_mail => $run{debug}, hash => "copy_$srpm") or next; - perform_command(qq{sudo chroot $chroot su builder -c "rpm -i /home/builder/rpm/SRPMS/$srpm"}, + perform_command(qq{sudo chroot $chroot_tmp su builder -c "rpm -i /home/builder/rpm/SRPMS/$srpm"}, \%run, $config, mail => $config->{admin}, - error => "[REBUILD] cannot install $srpm in $chroot", + error => "[REBUILD] cannot install $srpm in $chroot_tmp", debug_mail => $run{debug}, hash => "install_$srpm") or next; - perform_command(qq{sudo chroot $chroot su builder -c "rpm --nodeps -bs /home/builder/rpm/SPECS/*.spec"}, + perform_command(qq{sudo chroot $chroot_tmp su builder -c "rpm --nodeps -bs /home/builder/rpm/SPECS/*.spec"}, \%run, $config, mail => $config->{admin}, - error => "[REBUILD] cannot create $srpm in $chroot", + error => "[REBUILD] cannot create $srpm in $chroot_tmp", debug_mail => $run{debug}, hash => "create_$srpm") or next; print {$run{LOG}} "Installing build dependencies of $srpm...\n" if $run{verbose} > 1; - perform_command("sudo urpmi $urpmi_options --root $chroot $chroot/home/builder/rpm/SRPMS/$srpm", + if (!perform_command("sudo urpmi $urpmi_options --root $chroot_tmp $chroot_tmp/home/builder/rpm/SRPMS/$srpm", \%run, $config, mail => $config->{admin}, error => "[REBUILD] install of build dependencies of $srpm failed on $run{my_arch}", @@ -488,13 +489,16 @@ retry: push @{$cache->{needed}{$srpm}}, [ $missing_deps, $version, $other_maint || $maintainer ]; } }, - ) or next; + )) { + $run{status}{$srpm} = 'install_deps_failure'; + next + } # try to workarround the rpm -qa db4 error(2) from dbcursor->c_get: No such file or directory # running rpm -qa several time seems to fix the problem foreach (1 .. 3) { - system("sudo chroot $chroot rpm -qa &> /dev/null") + system("sudo chroot $chroot_tmp rpm -qa &> /dev/null") } - perform_command("sudo chroot $chroot rpm -qa", + perform_command("sudo chroot $chroot_tmp rpm -qa", \%run, $config, hash => "rpm_qa_$srpm", timeout => 60, @@ -505,7 +509,7 @@ retry: if ($run{stop}) { $command = "rpm -b$run{stop} /home/builder/rpm/SPECS/*.spec" } - if (!perform_command(qq{TMP=/home/builder/tmp/ sudo chroot $chroot /bin/su builder -c "$command"}, + if (!perform_command(qq{TMP=/home/builder/tmp/ sudo chroot $chroot_tmp /bin/su builder -c "$command"}, \%run, $config, mail => $maintainer, error => "[REBUILD] $srpm from $run{distro_tag} does not build correctly on $run{my_arch}", @@ -519,7 +523,7 @@ retry: callback => sub { my ($opt, $output) = @_; if ($run{stop}) { - exec "sudo chroot $chroot /bin/su builder -c bash" + exec "sudo chroot $chroot_tmp /bin/su builder -c bash" } print {$run{LOG}} "iurt: calling callback for $opt->{hash}\n" if $run{debug}; if ($unionfs_tmp && $output =~ /no space left on device/i) { @@ -532,7 +536,7 @@ retry: return 1 } }, - freq => 1) && !glob "$chroot/home/builder/rpm/RPMS/*/*.rpm") { + freq => 1) && !glob "$chroot_tmp/home/builder/rpm/RPMS/*/*.rpm") { # FIXME # The simple algo used here is : # try to compile it with unionfs, if it runs out of space, compile it without the next time @@ -546,8 +550,10 @@ retry: # plus). Or to keep the faulty package a unionfs exception for some time, to save some more extra builds. # if (!$unionfs_tmp) { + $run{status}{$srpm} = 'build_failure'; $cache->{failure}{$srpm} = 1 } elsif (!$cache->{no_unionfs}{$srpm}) { + $run{status}{$srpm} = 'build_failure'; $cache->{failure}{$srpm} = 1 } else { goto retry @@ -556,7 +562,7 @@ retry: } # do some cleaning if the compilation is successful delete $cache->{needed}{$srpm} if defined $cache->{needed}{$srpm}; - if (!perform_command("sudo urpmi $urpmi_options --root $chroot $chroot/home/builder/rpm/RPMS/*/*.rpm", + if (!perform_command("sudo urpmi $urpmi_options --root $chroot_tmp $chroot_tmp/home/builder/rpm/RPMS/*/*.rpm", \%run, $config, mail => $maintainer, error => "[REBUILD] binaries packages generated from $srpm do not install correctly", @@ -568,6 +574,7 @@ retry: error_regexp => 'unable to access', log => "$local_spool/log/$srpm/")) { $cache->{failure}{$srpm} = 1; + $run{status}{$srpm} = 'binary_test_failure'; next } if ($run{debug}) { @@ -575,9 +582,10 @@ retry: exit } else { print {$run{LOG}} "iurt: build successful, copying packages to $local_spool.\n"; - system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; + $run{status}{$srpm} = 'ok'; + system("cp $chroot_tmp/home/builder/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy rpm files from $chroot_tmp/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; if ($run{copy_srpm}) { - system("cp $chroot/home/builder/rpm/SRPMS/$srpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy $srpm from $chroot/home/builder/rpm/SRPMS/ to $local_spool ($!)\n"; + system("cp $chroot_tmp/home/builder/rpm/SRPMS/$srpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy $srpm from $chroot_tmp/home/builder/rpm/SRPMS/ to $local_spool ($!)\n"; } process_queue($config, \%run, \@wrong_rpm, 1) } @@ -595,6 +603,20 @@ if (open my $file, ">$local_spool/log/wrong_srpm_names.log") { foreach (@wrong_rpm) { print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n"; } + close $file +} + +if (open my $file, ">$local_spool/log/status.$run{media}.log") { + foreach my $srpm (keys %{$run{status}}) { + print $file "$srpm: "; + if ($run{status}{$srpm}) { + print $file $run{status}{$srpm} + } else { + print $file "unknown" + } + print $file "\n" + } + close $file } if ($config->{rsync_to} && !$run{no_rsync}) { @@ -806,7 +828,6 @@ sub dump_cache { # but the idea is more to have a global parrallel build than several local ones. return if $run->{debug} || !$run->{use_cache}; open my $file, ">$filename.tmp.$daydate" or die "FATAL iurt dump_cache: cannot open $filename.tmp"; - if (flock($file,LOCK_EX)) { #seek($file, 0, 2); if ($run{concurrent_run}) { print {$run{log}} "iurt: merging cache"; @@ -825,11 +846,12 @@ sub dump_cache { $Data::Dumper::Indent = 1; $Data::Dumper::Terse = 1; print $file Data::Dumper->Dump([ $cache ], [ "cache" ]); + if (flock($file,LOCK_EX)) { unlink $filename; link "$filename.tmp.$daydate", $filename; flock($file,LOCK_UN) } else { - print {$run{LOG}} "iurt: dumping_cache failed (could not lock cache file $cachefile $!)"; + print {$run{LOG}} "iurt: dumping_cache failed (could not lock cache file $cachefile $!)"; } } @@ -1114,6 +1136,7 @@ sub check_media { my ($rarch, $srpm) = update_srpm($rpms_dir, $rpm, $wrong_rpm); $rarch or next; $cache->{queue}{$srpm} = 1; + $run{status}{$srpm} = 'ok'; check_version($srpm) } closedir $rpmdir; @@ -1164,13 +1187,22 @@ sub search_packages { $srpm = $1 } $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next; + $run->{status}{$srpm} ||= 0; if ($config->{unwanted_packages} && $srpm =~ /$config->{unwanted_packages}/) { next } my $ok = 1; if (check_version($srpm)) { - defined $cache->{failure}{$srpm} and next; - if (!$cache->{queue}{$srpm} && check_needed($srpm)) { + if (defined $cache->{failure}{$srpm}) { + $run->{status}{$srpm} = 'build_failure'; + next + } + my $check_needed = check_needed($srpm); + $run->{status}{$srpm} = 'missing_buildrequires' if !$check_needed; + if (!$cache->{queue}{$srpm} && $check_needed) { my $hdr = rpm2header("$dir/$srpm"); - check_arch($hdr) or next; + if (!check_arch($hdr)) { + $run->{status}{$srpm} = 'not_on_this_arch'; + next + } my $changelog = $hdr->queryformat("%{CHANGELOGNAME}"); my ($mail) = $changelog =~ /<(.*@.*)>/; $maint{$srpm} = $mail; |