my $base_spec;
my @spec;
my @sources;
+my $sources;
+my %patchset;
sub next_spec($)
{
push @spec, $_;
} elsif (/^NoSource\s*:\s*(\d+)\s*$/i) {
$no_source{ "source" . $1 } = 1;
+ } elsif (my ($patchset_pattern, $patchset_start, $patchset_end) = /^%patchset_source.+-f\s+(\S+)\s+(\S+)\s+(\S+)/i) {
+ %patchset = (
+ pattern => $patchset_pattern,
+ start => $patchset_start,
+ end => $patchset_end
+ );
}
}
close(F);
shift @spec;
} # }}}
+sub process_patchset($) {
+ my $macros = shift;
+ return unless %patchset or $sources;
+
+ # parse sources file
+ my %files;
+ open(my $fh, '<', $sources) or die $!;
+ while (<$fh>) {
+ chomp;
+ next unless my ($hash, $filename) = /^([a-f0-9]{32})\s+\*?(.+)$/;
+ $files{$filename} = $hash;
+ }
+
+ # print out patchset entries which source md5 is present in source file
+ my $start = expand($patchset{start}, $macros);
+ my $end = expand($patchset{end}, $macros);
+ for (my $i = $start; $i < $end; $i++) {
+ my $url = sprintf($patchset{pattern}, $i);
+ my ($basename) = $url =~ m{/([^/]+$)};
+ my $hash = $files{$basename} or next;
+ printf "%s %s\n", $hash, $url;
+ }
+}
+
my $total = 0;
}
}
+ # so we have macros now, can parse patchset source
+ process_patchset($macros);
+
# the end, yuppie !
foreach my $s (@sources) {
my $src = expand( $s->[2], $macros );
} # }}}
next_spec(shift);
+$sources = shift if @ARGV;
+undef $sources if $sources and not -e $sources;
preparse_spec($spec);
add_md5_to_print($spec);
cont( \@spec, { "nil" => "" } );