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

optimize DistroRelease: postpone more of package release resolving

parent 5007209c
......@@ -159,12 +159,21 @@ sub get_package ( $self, $pkg_name )
{
$self->update_sources;
if ( !exists $self->{packages}{$pkg_name} ) {
for ( $self->origins ) {
$self->{packages}{$pkg_name} = $_->get_package($pkg_name);
last;
}
$self->{packages}{$pkg_name}
//= App::DistroDelta::Package->new( name => $pkg_name );
}
return $self->{packages}{$pkg_name};
}
sub get_package_release_versions ( $self, $pkg_name )
{
return unless exists $self->{packages}{$pkg_name};
return unless exists $self->{package_releases}{$pkg_name};
$self->{package_releases}{$pkg_name}{versions} //= [
sort { version_compare( $b, $a ) }
......@@ -178,14 +187,18 @@ sub get_package_release_versions ( $self, $pkg_name )
sub get_package_releases ( $self, $pkg_name )
{
return unless exists $self->{packages}{$pkg_name};
return unless exists $self->{package_releases}{$pkg_name};
@_ = ();
for ( $self->get_package_release_versions($pkg_name) ) {
$self->get_package($pkg_name)
unless exists $self->{packages}{$pkg_name};
$self->{package_releases}{$pkg_name}{obj}{$_}
= $self->{packages}{$pkg_name}->add_release(
%{ $self->{package_releases}{$pkg_name}{args}{$_} } )
unless exists $self->{package_releases}{$pkg_name}{obj}{$_};
sources => $self->{package_releases}{$pkg_name}{sources}{$_},
%{ $self->{package_releases}{$pkg_name}{args}{$_} },
) unless exists $self->{package_releases}{$pkg_name}{obj}{$_};
return $self->{package_releases}{$pkg_name}{obj}{$_}
unless wantarray;
push @_, $self->{package_releases}{$pkg_name}{obj}{$_};
......@@ -202,37 +215,13 @@ sub add_package_release ( $self, %args )
$pkg_name = $args{name};
$version = $args{version};
# lookup or create package project, and register with distro release
if ( exists $self->{packages}{$pkg_name} ) {
$pkg = $self->{packages}{$pkg_name};
}
else {
# TODO: try inheritance recursively (or reintroduce global pool?)
for ( $self->origins ) {
$pkg = $_->get_package($pkg_name);
last;
}
$pkg //= App::DistroDelta::Package->new( name => $pkg_name );
# register package with distro release
$self->{packages}{$pkg_name} = $pkg;
}
# lookup or create package release, and register with distro release
if ( exists $self->{package_releases}{$pkg_name}{obj}{$version} ) {
$self->{package_releases}{$pkg_name}{obj}{$version}->add_source($src);
}
else {
delete $args{source};
delete $args{name};
$self->{package_releases}{$pkg_name}{args}{$version} = {
project => $pkg,
sources => [$src],
%args,
};
delete $self->{package_releases}{$pkg_name}{versions};
}
delete $args{source};
delete $args{name};
$self->{package_releases}{$pkg_name}{args}{$version} = {
project => $pkg,
%args,
};
push @{ $self->{package_releases}{$pkg_name}{sources}{$version} }, $src;
}
sub pkgnames ( $self, @pkg_names )
......@@ -245,8 +234,8 @@ sub pkgnames ( $self, @pkg_names )
@_
= (@pkg_names)
? grep { exists $filter->{$_} } keys %{ $self->{packages} }
: keys %{ $self->{packages} };
? grep { exists $filter->{$_} } keys %{ $self->{package_releases} }
: keys %{ $self->{package_releases} };
if ( $self->log->is_trace ) {
$self->log->trace( "resolved pkgnames:", @_ );
......
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