extends 'Debbugs::OOBase';
+=head2 name
+
+Name of the Package
+
+=head2 qualified_name
+
+name if binary, name prefixed with C<src:> if source
+
+=cut
+
has name => (is => 'ro', isa => 'Str',
required => 1,
);
+sub qualified_name {
+ my $self = shift;
+ return
+ # src: if source, nothing if binary
+ ($self->_type eq 'source' ? 'src:':'') .
+ $self->name;
+}
+
+
+=head2 type
+
+Type of the package; either C<binary> or C<source>
+
+=cut
+
has type => (is => 'bare', isa => 'Str',
lazy => 1,
builder => '_build_type',
}
}
-sub qualified_name {
- my $self = shift;
- return
- # src: if source, nothing if binary
- ($self->_type eq 'source' ? 'src:':'') .
- $self->name;
-}
+=head2 url
+
+url to the package
+
+=cut
sub url {
my $self = shift;
return $class->$orig(%args);
};
+=head2 is_source
+
+true if the package is a source package
+
+=head2 is_binary
+
+true if the package is a binary package
+
+=cut
+
sub is_source {
return $_[0]->_type eq 'source'
}
return $_[0]->_type eq 'binary'
}
+=head2 valid -- true if the package has any valid versions
+
+=cut
+
has valid => (is => 'ro', isa => 'Bool',
lazy => 1,
builder => '_build_valid',
sub _build_valid {
my $self = shift;
- if ($self->_valid_versioninfo > 0) {
+ if ($self->valid_version_info_count> 0) {
return 1;
}
return 0;
(is => 'bare', isa => 'ArrayRef',
traits => ['Array'],
lazy => 1,
- builder => '_build_valid_versioninfo',
- predicate => '_has_valid_versioninfo',
- clearer => '_clear_valid_versioninfo',
- handles => {'_get_valid_versioninfo' => 'get',
- '_grep_valid_versioninfo' => 'grep',
- '_valid_versioninfo' => 'elements',
+ builder => '_build_valid_version_info',
+ predicate => '_has_valid_version_info',
+ clearer => '_clear_valid_version_info',
+ handles => {'_get_valid_version_info' => 'get',
+ 'valid_version_info_grep' => 'grep',
+ '_valid_version_info' => 'elements',
+ 'valid_version_info_count' => 'count',
},
);
-sub _build_valid_versioninfo {
+sub _build_valid_version_info {
my $self = shift;
my $pkgs = $self->_get_valid_version_info_from_db;
for my $invalid_version (@{$pkgs->{$self->qualified_name}->{invalid_versions}}) {
},
);
}
+ my @src_packages = keys %src_packages;
my @bin_ver_search;
for my $sp (keys %bin_ver_packages) {
},
);
}
+ my @bin_packages = keys %bin_packages;
my $packages = {};
sub _default_pkg_info {
return {name => $_[0],
$bp->{$pkg->{bin_pkg}}++;
}
}
- if (keys %src_packages) {
+ if (@src_packages) {
my $src_rs = $s->resultset('SrcVer')->
- search({-or => [-and => {'src_pkg.pkg' => [keys %src_packages],
+ search({-or => [-and => {'src_pkg.pkg' => [@src_packages],
-or => {'suite.codename' => $common_dists,
'suite.suite_name' => $common_dists,
},
\%bin_packages,
);
}
- if (keys %bin_packages) {
+ if (@bin_packages) {
my $bin_assoc_rs =
$s->resultset('BinAssociation')->
- search({-and => {'bin_pkg.pkg' => [keys %bin_packages],
+ search({-and => {'bin_pkg.pkg' => [@bin_packages],
-or => {'suite.codename' => $common_dists,
'suite.suite_name' => $common_dists,
},
my $self = shift;
my $info = {};
my $i = 0;
- for my $v ($self->_valid_versioninfo) {
+ for my $v ($self->_valid_version_info) {
push @{$info->{$v->{src_ver}}}, $i;
$i++;
}
my $self = shift;
my $info = {};
my $i = 0;
- for my $v ($self->_valid_versioninfo) {
+ for my $v ($self->_valid_version_info) {
push @{$info->{$v->{bin_ver}}}, $i;
$i++;
}
my $self = shift;
my $info = {};
my $i = 0;
- for my $v ($self->_valid_versioninfo) {
- push @{$info->{$v->{dist}}}, $i;
+ for my $v ($self->_valid_version_info) {
+ next unless defined $v->{suite_name} and length($v->{suite_name});
+ push @{$info->{$v->{suite_name}}}, $i;
$i++;
}
return $info;
sub _build_binaries {
my $self = shift;
if ($self->is_binary) {
- return $self->package_collection->limit($self);
+ return $self->package_collection->limit($self->name);
}
# OK, walk through the valid_versions for this package
my @binaries =
- uniq map {$_->{bin_pkg}} $self->_valid_versioninfo;
+ uniq map {$_->{bin_pkg}} $self->_valid_version_info;
return $self->package_collection->limit(@binaries);
}
sub _build_sources {
my $self = shift;
+ return $self->package_collection->limit($self->source_names);
+}
+
+sub source_names {
+ my $self = shift;
+
if ($self->is_source) {
- return $self->package_collection->limit($self);
+ return $self->name
}
- # OK, walk through the valid_versions for this package
- my @sources =
- uniq map {'src:'.$_->{src_pkg_name}} $self->_valid_versioninfo;
- return $self->package_collection->limit(@sources);
+ return uniq map {'src:'.$_->{src_pkg}} $self->_valid_version_info;
+}
+
+=head2 maintainers
+
+L<Debbugs::Collection::Correspondent> of the maintainer(s) of the current package
+
+=cut
+
+has maintainers => (is => 'ro',
+ isa => 'Debbugs::Collection::Correspondent',
+ lazy => 1,
+ builder => '_build_maintainers',
+ predicate => '_has_maintainers',
+ );
+
+sub _build_maintainers {
+ my $self = shift;
+ my @maintainers;
+ for my $v ($self->_valid_version_info) {
+ next unless length($v->{suite_name}) and length($v->{maintainer});
+ push @maintainers,$v->{maintainer};
+ }
+ @maintainers =
+ uniq @maintainers;
+ return $self->correspondent_collection->limit(@maintainers);
}
has 'versions' => (is => 'bare',
grep {defined $_}
$self->_get_dist_to_info($dist);
for my $v ($self->
- _get_valid_versioninfo(@ver_loc)) {
+ _get_valid_version_info(@ver_loc)) {
$src_pkg_vers{$v->{src_pkg_ver}} = 1;
}
}
@{$self->_get_binary_version_to_info($ver)//[]};
next unless @ver_loc;
my @vers = map {$self->
- _get_valid_versioninfo($_)}
+ _get_valid_version_info($_)}
@ver_loc;
for my $v (@vers) {
if (keys %archs) {
push @versions,
$v,
Debbugs::Version::Source->
- new(package => $self,
+ new(pkg => $self,
version => $v,
package_collection => $self->package_collection,
$self->schema_argument,
push @versions,
$v,
Debbugs::Version::Binary->
- new(package => $self,
+ new(pkg => $self,
version => $v,
package_collection => $self->package_collection,
$self->schema_argument,
$self->_set_version(@versions);
}
+=head2 package_collection
+
+L<Debbugs::Collection::Package> to get additional packages required
+
+=cut
+
# gets used to retrieve packages
has 'package_collection' => (is => 'ro',
isa => 'Debbugs::Collection::Package',
return Debbugs::Collection::Package->new($self->schema_argument)
}
+=head2 correspondent_collection
+
+L<Debbugs::Collection::Correspondent> to get additional maintainers required
+
+=cut
+
+has 'correspondent_collection' => (is => 'ro',
+ isa => 'Debbugs::Collection::Correspondent',
+ builder => '_build_correspondent_collection',
+ lazy => 1,
+ );
+
+sub _build_correspondent_collection {
+ my $self = shift;
+ return Debbugs::Collection::Correspondent->new($self->schema_argument)
+}
+
sub CARP_TRACE {
my $self = shift;
return 'Debbugs::Package={package='.$self->qualified_name.'}';