forked from openSUSE/obs-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adding support for susetags to download on demand
- moved the susetags parser into an own module (this is basically based on createyastdeps) (see http://lists.opensuse.org/opensuse-buildservice/2008-12/msg00055.html) - fixed createyastdeps so that it uses the module (parsing a current packages.gz with the old and the new createyastdeps code results in the same output)
- Loading branch information
Showing
2 changed files
with
65 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package Susetags; | ||
|
||
use strict; | ||
use warnings; | ||
use Data::Dumper; | ||
|
||
sub parse { | ||
my ($file, $tmap, $order, @arches) = @_; | ||
# if @arches is empty take all arches | ||
|
||
my @needed = keys %$tmap; | ||
my $r = '(' . join('|', @needed) . '|Pkg):\s*(.*)'; | ||
|
||
if (!open(F, '<', $file)) { | ||
if (!open(F, '-|', "gzip -dc $file".'.gz')) { | ||
die "$file: $!"; | ||
} | ||
} | ||
|
||
my $cur; | ||
my $pkgs = {}; | ||
while (<F>) { | ||
chomp; | ||
next unless $_ =~ /([\+=])$r/; | ||
my ($multi, $tag, $data) = ($1, $2, $3); | ||
if ($multi eq '+') { | ||
while (<F>) { | ||
chomp; | ||
last if $_ =~ /-$tag/; | ||
push @{$cur->{$tmap->{$tag}}}, $_; | ||
} | ||
} elsif ($tag eq 'Pkg') { | ||
$pkgs->{"$cur->{'name'}-$cur->{'arch'}"} = $cur if defined $cur && (!@arches || grep { /$cur->{'arch'}/ } @arches); | ||
# keep order (or should we use Tie::IxHash?) | ||
push @{$order}, "$cur->{'name'}-$cur->{'arch'}" if defined $order && defined $cur; | ||
$cur = {}; | ||
($cur->{'name'}, $cur->{'version'}, $cur->{'release'}, $cur->{'arch'}) = split(' ', $data); | ||
} else { | ||
$cur->{$tmap->{$tag}} = $data; | ||
} | ||
} | ||
$pkgs->{"$cur->{'name'}-$cur->{'arch'}"} = $cur if defined $cur && (!@arches || grep { /$cur->{'arch'}/ } @arches); | ||
push @{$order}, "$cur->{'name'}-$cur->{'arch'}" if defined $order && defined $cur; | ||
close(F); | ||
return $pkgs; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters