commit 736b2879713cd577cde026be549d9a34e1638ed0
Author: Elan Ruusamäe <[email protected]>
Date:   Sun Jan 5 15:07:06 2014 +0200

    patchset: parse -s option support

 specparser.pl | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/specparser.pl b/specparser.pl
index 1e5900f..3b7e787 100755
--- a/specparser.pl
+++ b/specparser.pl
@@ -124,11 +124,15 @@ sub preparse_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) {
+               } elsif (my ($patchset) = /^%patchset_source\s+(.+)$/) {
+                       use Getopt::Long qw(GetOptionsFromString);
+                       my ($f, $s);
+                       my ($ret, $args) = GetOptionsFromString($patchset, 
's=s' => \$s, 'f=s' => \$f);
                        %patchset = (
-                               pattern => $patchset_pattern,
-                               start => $patchset_start,
-                               end => $patchset_end
+                               pattern => $f,
+                               filelist => $s,
+                               start => $args->[0],
+                               end => $args->[1],
                        );
                }
        }
@@ -138,13 +142,13 @@ sub preparse_spec($) # {{{
 } # }}}
 
 # read in 'sources' file
-sub read_sources_file() {
-       return () unless $sources_file and -e $sources_file;
+sub read_sources_file {
+       my $filename = $_[0] || $sources_file;
+       return () unless $filename and -e $filename;
 
-       our %files;
-       return \%files if %files;
+       my %files;
 
-       open(my $fh, '<', $sources_file) or die $!;
+       open(my $fh, '<', $filename) or die $!;
        while (<$fh>) {
                chomp;
                next unless my ($hash, $filename) = 
/^([a-f0-9]{32})\s+\*?(.+)$/;
@@ -155,10 +159,24 @@ sub read_sources_file() {
 
 sub process_patchset($) {
        my $macros = shift;
+       my $checksums;
+
        return unless %patchset;
 
-       # parse sources file
-       my $checksums = read_sources_file() or return;
+       # print all files from sources file
+       if ($patchset{filelist}) {
+               my $prefix = expand($patchset{pattern}, $macros);
+               my $filelist = expand($patchset{filelist}, $macros);
+               $checksums = read_sources_file($filelist);
+               while (my($file, $hash) = each %$checksums) {
+                       my $url = $prefix . $file;
+                       print_source "patchset $file", $hash, $url;
+               }
+               return;
+       }
+
+       # parse sources file sequences
+       $checksums = read_sources_file() or return;
 
        # print out patchset entries which source md5 is present in source file
        my $start = expand($patchset{start}, $macros);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/distfiles.git/commitdiff/736b2879713cd577cde026be549d9a34e1638ed0

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to