Skip to content

Commit

Permalink
[backend] debmd: Fix DebMd parsing of Packages files
Browse files Browse the repository at this point in the history
Debian packages file use a newline to signal the end of a record, not
Size. While e.g. the main Debian archive always uses Size as the last
record that's not the case for e.g. the Raspbian archives.
  • Loading branch information
sjoerdsimons authored and adrianschroeter committed Nov 12, 2014
1 parent abc1e65 commit a509465
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/backend/Meta/Debmd.pm
Expand Up @@ -45,6 +45,17 @@ sub parse {
open(F, '<', $fn) or die("open: $!\n");
while (<F>) {
chomp;
# Empty line signifies the end of a package section
if (/^$/) {
$cur->{'hdrmd5'} = 0;
my $rel = exists $cur->{'release'} ? "-$cur->{'release'}" : '';
push @{$cur->{'provides'}}, "$cur->{'name'} = $cur->{'version'}$rel";
$cur->{'requires'} = [] unless exists $cur->{'requires'};
$cur->{'source'} = $cur->{'name'} unless exists $cur->{'source'};
$packs{$cur->{'name'}} = $cur;
$cur = {};
next;
}
next unless /^(Package|Version|Provides|Depends|Pre-Depends|Filename|Source|Architecture|Size):\s(.*)/;
my ($tag, $what) = ($1, $2);
if ($tag =~ /^[\w-]*Depends|Provides/) {
Expand All @@ -63,16 +74,8 @@ sub parse {
push @{$cur->{$tagmap{$tag}}}, @l;
next;
}
# Size is the last entry in a package section
if ($tag eq 'Size') {
$cur->{'id'} = "-1/$what/-1";
$cur->{'hdrmd5'} = 0;
my $rel = exists $cur->{'release'} ? "-$cur->{'release'}" : '';
push @{$cur->{'provides'}}, "$cur->{'name'} = $cur->{'version'}$rel";
$cur->{'requires'} = [] unless exists $cur->{'requires'};
$cur->{'source'} = $cur->{'name'} unless exists $cur->{'source'};
$packs{$cur->{'name'}} = $cur;
$cur = {};
next;
}
$cur->{$tagmap{$tag}} = $what;
Expand Down

0 comments on commit a509465

Please sign in to comment.