From 5135907fe3eb681d74eada852d135a3ad761dd0a Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sat, 29 Jul 2017 13:49:51 +0100 Subject: Add support for resuming rebuild --- iurt | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'iurt') diff --git a/iurt b/iurt index 871610b..a379926 100755 --- a/iurt +++ b/iurt @@ -182,6 +182,9 @@ $run{todo} = []; [ "", "shard_id", 1, "", "Shard id (starts at 0)", sub { ($run{shard_id}) = @_; 1 }, 'Setting shard id' ], + [ "", "resume", 0, "", + "Only build packages not yet done during previous build-all run", + sub { $run{resume} = 1 }, "Setting the resume flag" ], [ "n", "no", 0, "", "Perform all the check but do not compile anything", sub { ($run{no_compile}) = 1 }, "Setting the no compilation flag" ], @@ -603,7 +606,11 @@ my $cache = { }; $run{cache} = $cache; -empty_status($local_spool, \%run); +if ($run{resume}) { + load_status($local_spool, \%run); +} else { + empty_status($local_spool, \%run); +} my (%srpm_version, @wrong_rpm, %provides, %pack_provide, $to_compile, %maint); $to_compile = @{$run{todo}}; @@ -1311,10 +1318,24 @@ sub check_media { $nb; } +sub guess_release_tag_from_status { + my ($run) = @_; + while (my ($srpm, $status) = each %{$run->{status}}) { + if ($status eq 'ok' || $status eq 'build_failure' || $status eq 'install_deps_failure') { + # The regex should probably be in the config + my ($tag) = $srpm =~ /.*\.([^.]*)\.src\.rpm$/; + plog('INFO', "Guessed release tag: $tag"); + return $tag; + } + } +} + sub search_packages { my ($clean, $cache, $provides, $run, $_maint, $srpm_version, @dir) = @_; my ($to_compile, %rep); plog("iurt search_package: @dir"); + # Status is written with the current release tag which may be different + my $reltag = guess_release_tag_from_status($run); foreach my $dir (@dir) { plog("checking SRPMS dir $dir"); opendir my $rpmdir, $dir or next; @@ -1326,7 +1347,15 @@ sub search_packages { $srpm = $1; } $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next; - $run->{status}{$srpm} ||= 0; + $run->{status}{$srpm} and next; + # If the package was rebuilt, its release tag may have changed + if ($reltag && $srpm !~ /$reltag.src.rpm/) { + my $s = $srpm; + $s =~ s/\.[^.]*\.src\.rpm$/.$reltag.src.rpm/; + $run->{status}{$s} and next; + } + #print $run->{status}{$srpm}; + #print " $srpm\n"; if ($config->{unwanted_packages} && $srpm =~ /$config->{unwanted_packages}/) { next } my $ok = 1; if (check_version($run, $srpm, $srpm_version)) { @@ -1402,6 +1431,22 @@ sub empty_status { truncate($status_file, 0); } +sub load_status { + my ($local_spool, $run) = @_; + my $status_file = status_file($local_spool, $run); + plog('INFO', "Loading status from $status_file"); + if (open my $file, "<$status_file") { + while (my $row = <$file>) { + chomp $row; + if ($row =~ /^(.*): (.*)$/) { + my $srpm = $1; + $run->{status}{$srpm} = $2; + } + } + } + plog('INFO', "Loaded " . (keys %{$run->{status}}) . " status") if $run->{status}; +} + sub write_status { my ($local_spool, $run, $srpm) = @_; return unless $run{status}{$srpm}; -- cgit v1.2.1