]> git.pld-linux.org Git - projects/distfiles.git/commitdiff
patchset: parse -s option support
authorElan Ruusamäe <glen@delfi.ee>
Sun, 5 Jan 2014 13:07:06 +0000 (15:07 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 5 Jan 2014 13:07:14 +0000 (15:07 +0200)
specparser.pl

index 1e5900f8529d4c6be455a7668c26b79671bce85a..3b7e787df512095b38a05b91717336b47a1c0fcf 100755 (executable)
@@ -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);
This page took 0.100228 seconds and 4 git commands to generate.