Skip Menu |

This queue is for tickets about the DPKG-Parse CPAN distribution.

Report information
The Basics
Id: 69920
Status: resolved
Priority: 0/
Queue: DPKG-Parse

People
Owner: ether [...] cpan.org
Requestors: midenok [...] bk.ru
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.01
Fixed in: 0.02-TRIAL



Subject: [PATCH] Fix to work with current dpkg 'status'
see patch
Subject: u.diff
diff -uarpd a/DPKG/Parse/Entry.pm b/DPKG/Parse/Entry.pm --- a/DPKG/Parse/Entry.pm 2005-12-21 04:17:28.000000000 +0300 +++ b/DPKG/Parse/Entry.pm 2011-07-31 21:24:15.299320396 +0400 @@ -105,8 +105,31 @@ DPKG::Parse::Entry->mk_accessors(qw( tag url version + original_maintainer + homepage + breaks + python_version + multi_arch + gstreamer_decoders + gstreamer_elements + gstreamer_encoders + gstreamer_uri_sources + gstreamer_version + python_runtime + npp_applications + npp_file + npp_mimetype + npp_name + npp_description + python_runtime + gstreamer_uri_sinks + xul_appid + original_vcs_browser + original_vcs_git )); +DPKG::Parse::Entry->mk_ro_accessors(qw(__debug __line_num)); + =item Accessor Methods The following accessor methods correspond directly to the values found in @@ -159,9 +182,13 @@ sub new { { 'data' => { 'type' => SCALAR, 'optional' => 1 }, 'debug' => { 'type' => SCALAR, 'default' => 0, 'optional' => 1 }, + 'line_num' => { type => SCALAR, default => 0, optional => 1 } } ); - my $ref = {}; + my $ref = { + __debug => $p{debug}, + __line_num => $p{line_num} + }; bless($ref, $pkg); if ($p{'data'}) { $ref->parse('data' => $p{'data'}); @@ -184,7 +211,9 @@ sub parse { ); my $field; my $contents; + my $line_num = $pkg->__line_num; foreach my $line (split(/\n/, $p{'data'})) { + ++$line_num; if ($line =~ /^([\w|-]+): (.+)$/) { $field = $1; $contents = $2; @@ -193,8 +222,8 @@ sub parse { if ($pkg->can($field)) { $pkg->$field($contents); } else { - if ($pkg->debug) { - carp "I don't know about field $field\n"; + if ($pkg->__debug) { + carp "line ${line_num}: I don't know about field '${field}'\n"; } next; } @@ -209,25 +238,25 @@ sub parse { if ($pkg->can($field)) { $pkg->$field($contents); } else { - if ($pkg->debug) { - carp "I don't know about field $field\n"; + if ($pkg->__debug) { + carp "line ${line_num}: I don't know about field '${field}'\n"; } next; } - } elsif ($line =~ /^([\w|-]+):$/) { + } elsif ($line =~ /^([\w|-]+):\s*$/) { $field = $1; $field = lc($field); $field =~ s/-/_/g; if ($pkg->can($field)) { $pkg->$field(""); } else { - if ($pkg->debug) { - carp "I don't know about field $field\n"; + if ($pkg->__debug) { + carp "line ${line_num}: I don't know about field '${field}'\n"; } next; } } else { - die "I have no idea what to do with $line!\n"; + die "line ${line_num}: I have no idea what to do with '${line}'!\n"; } } } diff -uarpd a/DPKG/Parse/Status.pm b/DPKG/Parse/Status.pm --- a/DPKG/Parse/Status.pm 2005-12-21 04:17:28.000000000 +0300 +++ b/DPKG/Parse/Status.pm 2011-07-31 20:09:43.322761388 +0400 @@ -61,9 +61,10 @@ sub new { my %p = validate(@_, { 'filename' => { 'type' => SCALAR, 'default' => '/var/lib/dpkg/status', 'optional' => 1 }, + 'debug' => { 'type' => SCALAR, 'default' => 0, 'optional' => 1 } } ); - my $ref = $pkg->next::method('filename' => $p{'filename'}); + my $ref = $pkg->next::method('filename' => $p{'filename'}, debug => $p{debug}); return $ref; } diff -uarpd a/DPKG/Parse.pm b/DPKG/Parse.pm --- a/DPKG/Parse.pm 2005-12-21 04:17:28.000000000 +0300 +++ b/DPKG/Parse.pm 2011-07-31 21:18:16.838794647 +0400 @@ -53,6 +53,7 @@ use strict; use warnings; DPKG::Parse->mk_accessors(qw(filename entryarray entryhash)); +DPKG::Parse->mk_ro_accessors('debug'); my $VERSION = "0.01"; @@ -82,12 +83,14 @@ sub new { my %p = validate(@_, { 'filename' => { 'type' => SCALAR, }, + 'debug' => { 'type' => SCALAR, 'default' => 0, 'optional' => 1 } } ); my $ref = {}; if ($p{'filename'}) { $ref->{'filename'} = $p{'filename'}; }; + $ref->{debug} = $p{debug}; $ref->{'entryarray'} = []; $ref->{'entryhash'} = {}; bless($ref, $pkg); @@ -117,12 +120,16 @@ sub parse_package_format { } open(STATUS, $pkg->filename); my $entry; + my $line_num = -1; + my $entry_line = 0; STATUSLINE: while (my $line = <STATUS>) { + ++$line_num; if ($line =~ /^\n$/) { - my $dpkg_entry = DPKG::Parse::Entry->new('data' => $entry); + my $dpkg_entry = DPKG::Parse::Entry->new('data' => $entry, debug => $pkg->debug, line_num => $entry_line); push(@{$pkg->{'entryarray'}}, $dpkg_entry); $pkg->{'entryhash'}->{$dpkg_entry->package} = $dpkg_entry; $entry = undef; + $entry_line = $line_num + 1; next STATUSLINE; } $entry = $entry . $line;
Patch applied and shipped as DPKG-Parse-0.02-TRIAL.