]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Packages.pm
merge in changes from dla source tree
[debbugs.git] / Debbugs / Packages.pm
index e423bdd019c8387477d1abfd71d0b4f9a35c7048..39e5ed82ae246d5b2a274de3d3703571ed6c5b7b 100644 (file)
@@ -254,6 +254,14 @@ matching this version was uploaded
 
 =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
@@ -263,7 +271,7 @@ our %_versions_time;
 
 sub get_versions{
      my %param = validate_with(params => \@_,
-                               spec   => {package => {type => SCALAR,
+                               spec   => {package => {type => SCALAR|ARRAYREF,
                                                      },
                                           dist    => {type => SCALAR|ARRAYREF,
                                                       default => 'unstable',
@@ -277,6 +285,12 @@ sub get_versions{
                                           source  => {type    => BOOLEAN,
                                                       default => 0,
                                                      },
+                                          no_source_arch => {type => BOOLEAN,
+                                                             default => 0,
+                                                            },
+                                          return_archs => {type => BOOLEAN,
+                                                           default => 0,
+                                                          },
                                          },
                               );
      my $versions;
@@ -303,7 +317,9 @@ sub get_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}} :
@@ -312,19 +328,23 @@ sub get_versions{
                         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;
 }