]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Packages.pm
allow specifying the dist in source_to_binary (for DB actions)
[debbugs.git] / Debbugs / Packages.pm
index 77d40f396c96fbc061631e6b0214851460af88e3..936bd76688b867ae9d9d3f6c660687d651746c80 100644 (file)
@@ -229,18 +229,21 @@ sub binary_to_source{
        if ($param{source_only}) {
            @source = map {$_->[0]} @source;
            my $src_rs = $param{schema}->resultset('SrcPkg')->
-               search_rs({'binpkg.pkg' => [@binaries],
+               search_rs({'bin_pkg.pkg' => [@binaries],
                           @versions?('bin_vers.ver'    => [@versions]):(),
                           @archs?('arch.arch' => [@archs]):(),
                          },
                         {join => {'src_vers'=>
                                  {'bin_vers'=> ['arch','bin_pkg']}
                                  },
+                         columns => [qw(pkg)],
+                         order_by => [qw(pkg)],
+                         result_class => 'DBIx::Class::ResultClass::HashRefInflator',
                          distinct => 1,
                         },
                         );
            push @source,
-               map {$_->pkg} $src_rs->all;
+               map {$_->{pkg}} $src_rs->all;
            if ($param{scalar_only}) {
                return join(',',@source);
            }
@@ -255,21 +258,28 @@ sub binary_to_source{
                     {join => ['src_pkg',
                              {'bin_vers' => ['arch','binpkg']},
                              ],
+                     columns => ['src_pkg.pkg','src_ver.ver'],
+                     result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+                     order_by => ['src_pkg.pkg','src_ver.ver'],
                      distinct => 1,
                     },
                     );
        push @source,
-           map {[$_->get_column('src_pkg.pkg'),
-                 $_->get_column('src_ver.ver'),
+           map {[$_->{src_pkg}{pkg},
+                 $_->{src_ver}{ver},
                 ]} $src_rs->all;
        if (not @source and not @versions and not @archs) {
            $src_rs = $param{schema}->resultset('SrcPkg')->
                search_rs({pkg => [@binaries]},
-                        {distinct => 1},
+                        {join => ['src_vers'],
+                         columns => ['src_pkg.pkg','src_vers.ver'],
+                         distinct => 1,
+                        },
                         );
            push @source,
-               map {[$_->pkg,
-                    ]} $src_rs->all;
+           map {[$_->{src_pkg}{pkg},
+                 $_->{src_vers}{ver},
+                ]} $src_rs->all;
        }
        return @source;
     }
@@ -394,8 +404,8 @@ empty list in list context.
 =item version -- binary package version(s) as a SCALAR or ARRAYREF;
 optional, defaults to all versions.
 
-=item arch -- binary package architecture(s) as a SCALAR or ARRAYREF;
-optional, defaults to all architectures.
+=item dist -- list of distributions to return corresponding binary packages for
+as a SCALAR or ARRAYREF.
 
 =item binary_only -- return only the source name (forced on if in SCALAR
 context), defaults to false. [If in LIST context, returns a list of binary
@@ -420,6 +430,9 @@ sub source_to_binary{
                                         version => {type => SCALAR|ARRAYREF,
                                                     optional => 1,
                                                    },
+                                        dist => {type => SCALAR|ARRAYREF,
+                                                 optional => 1,
+                                                },
                                         binary_only => {default => 0,
                                                        },
                                         scalar_only => {default => 0,
@@ -467,6 +480,18 @@ sub source_to_binary{
                          distinct => 1,
                         },
                         );
+           if (exists $param{dist}) {
+               $bin_rs = $bin_rs->
+                   search({-or =>
+                          {'suite.codename' => [make_list($param{dist})],
+                           'suite.suite_name' => [make_list($param{dist})],
+                          }},
+                          {join => {'bin_vers' =>
+                                   {'bin_associations' =>
+                                    'suite'
+                                   }},
+                           });
+           }
            push @binaries,
                map {$_->{pkg}} $bin_rs->all;
            if ($param{scalar_only}) {