=item source -- returns source/version instead of just versions
+=item no_source_arch -- discards the source architecture when arch is
+not passed. [Used for finding the versions of binary packages only.]
+Defaults to 0, which does not discard the source architecture. (This
+may change in the future, so if you care, please code accordingly.)
+
+=item return_archs -- returns a version=>[archs] hash indicating which
+architectures are at which versions.
+
=back
=cut
sub get_versions{
my %param = validate_with(params => \@_,
- spec => {package => {type => SCALAR,
+ spec => {package => {type => SCALAR|ARRAYREF,
},
dist => {type => SCALAR|ARRAYREF,
default => 'unstable',
source => {type => BOOLEAN,
default => 0,
},
+ no_source_arch => {type => BOOLEAN,
+ default => 0,
+ },
+ return_archs => {type => BOOLEAN,
+ default => 0,
+ },
},
);
my $versions;
for my $dist (make_list($param{dist})) {
for my $arch (exists $param{arch}?
make_list($param{arch}):
- (keys %{$version->{$dist}})) {
+ (grep {not $param{no_source_arch} or
+ $_ ne 'source'
+ } keys %{$version->{$dist}})) {
next unless defined $version->{$dist}{$arch};
for my $ver (ref $version->{$dist}{$arch} ?
keys %{$version->{$dist}{$arch}} :
my $f_ver = $ver;
if ($param{source}) {
($f_ver) = makesourceversions($package,$arch,$ver);
+ next unless defined $f_ver;
}
if ($param{time}) {
$versions{$f_ver} = max($versions{$f_ver}||0,$version->{$dist}{$arch}{$ver});
}
else {
- $versions{$f_ver} = 1;
+ push @{$versions{$f_ver}},$arch;
}
}
}
}
}
if ($param{time}) {
- return %versions
+ return %versions;
+ }
+ elsif ($param{return_archs}) {
+ return %versions;
}
return keys %versions;
}
my $pkg = shift;
my $arch = shift;
my %sourceversions;
+ die "Package $pkg is multiple packages; split on , and call makesourceversions multiple times"
+ if $pkg =~ /,/;
for my $version (@_) {
if ($version =~ m[/]) {