Commit ef4169e3 authored by Jonas Smedegaard's avatar Jonas Smedegaard
Browse files

generalize parser in DistributionSource, and cache fields using native keys

parent dd67f459
......@@ -212,14 +212,29 @@ sub add_package_release ( $self, %args )
my ( $src, $pkg_name, $pkg, $pkgrel, $version );
$src = $args{source};
$pkg_name = $args{name};
$version = $args{version};
delete $args{source};
delete $args{name};
$pkg_name = $args{Package};
$version = $args{Version};
my ($vcs_git)
= $args{'Vcs-Git'}
? split ' ', $args{'Vcs-Git'}
: undef;
my ($vcs_hg)
= $args{'Vcs-Hg'}
? split ' ', $args{'Vcs-Hg'}
: undef;
$self->{package_releases}{$pkg_name}{args}{$version} = {
project => $pkg,
%args,
project => $pkg,
version => $version,
vcs_browser => $args{'Vcs-Browser'},
vcs_arch => $args{'Vcs-Arch'},
vcs_bzr => $args{'Vcs-Bzr'},
vcs_cvs => $args{'Vcs-Cvs'},
vcs_darcs => $args{'Vcs-Darcs'},
vcs_git => $vcs_git,
vcs_hg => $vcs_hg,
vcs_mtn => $args{'Vcs-Mtn'},
vcs_svn => $args{'Vcs-Svn'},
};
push @{ $self->{package_releases}{$pkg_name}{sources}{$version} }, $src;
}
......
......@@ -38,11 +38,10 @@ use Storable;
use App::DistroDelta::WebAgent;
use App::DistroDelta::DateTime;
my $RE_srcsplit = qr/\n\n+/;
my $RE_srcfields
= qr/^(?:Package: *(?<name>\S+) *\n|Version: *(?<version>\S+) *\n|Vcs-Browser: *(?<vcs_browser>\S+) *\n|Vcs-Arch: *(?<vcs_arch>\S+)(?: [^\n]*)?\n|Vcs-Bzr: *(?<vcs_bzr>\S+)(?: [^\n]*)?\n|Vcs-Cvs: *(?<vcs_cvs>\S+)(?: [^\n]*)?\n|Vcs-Darcs: *(?<vcs_darcs>\S+)(?: [^\n]*)?\n|Vcs-Git: *(?<vcs_git>\S+)(?: +-b +(?<vcs_git_branch>\S+))?(?: [^\n]*)?\n|Vcs-Hg: *(?<vcs_hg>\S+)(?: +-b +(?<vcs_hg_branch>\S+))?(?: [^\n]*)?\n|Vcs-Mtn: *(?<vcs_mtn>\S+)(?: [^\n]*)?\n|Vcs-Svn: *(?<vcs_svn>\S+)(?: [^\n]*)?\n|\S+:[^\n]*\n(?: \S[^\n]*\n)*)+/m;
my $RE_pkgver = qr/^[a-z0-9]\S* \d\S*/m;
my $RE_pkgver_ = qr/^([a-z0-9]\S*) (\d\S*)/m;
my $RE_srcsplit = qr/\n\n+/;
my $RE_srcfields = qr/^([A-Z][A-Za-z0-9-]*): (\S[^\n]*)\n/m;
my $RE_pkgver = qr/^[a-z0-9]\S* \d\S*/m;
my $RE_pkgver_ = qr/^([a-z0-9]\S*) (\d\S*)/m;
sub update ($self)
{
......@@ -92,8 +91,7 @@ sub update ($self)
or $self->log->fatal("unxz failed: $UnXzError") && exit 1;
my @content;
for ( split /$RE_srcsplit/, $content ) {
/$RE_srcfields/;
push @content, {%+};
push @content, {/$RE_srcfields/g};
}
$self->{data} = [@content];
store {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment