]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgreport.cgi
allow specifying the dist in source_to_binary (for DB actions)
[debbugs.git] / cgi / pkgreport.cgi
index d27caa13dc39c58dd5dc0a7216d1086fd39c32a1..8f5231fb4a022c268f95cdbbc713cc772f489a8b 100755 (executable)
@@ -18,6 +18,29 @@ BEGIN{
     delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
 }
 
+# if we're running out of git, we want to use the git base directory as the
+# first INC directory. If you're not running out of git, don't do that.
+use File::Basename qw(dirname);
+use Cwd qw(abs_path);
+our $debbugs_dir;
+BEGIN {
+    $debbugs_dir =
+       abs_path(dirname(abs_path(__FILE__)) . '/../');
+    # clear the taint; we'll assume that the absolute path to __FILE__ is the
+    # right path if there's a .git directory there
+    ($debbugs_dir) = $debbugs_dir =~ /([[:print:]]+)/;
+    if (defined $debbugs_dir and
+       -d $debbugs_dir . '/.git/') {
+    } else {
+       undef $debbugs_dir;
+    }
+    # if the first directory in @INC is not an absolute directory, assume that
+    # someone has overridden us via -I.
+    if ($INC[0] !~ /^\//) {
+    }
+}
+use if defined $debbugs_dir, lib => $debbugs_dir;
+
 binmode(STDOUT,':encoding(UTF-8)');
 use POSIX qw(strftime nice);
 use List::AllUtils qw(uniq);
@@ -29,7 +52,7 @@ use Debbugs::User;
 use Debbugs::Common qw(getparsedaddrs make_list getmaintainers getpseudodesc);
 
 use Debbugs::Bugs qw(get_bugs bug_filter newest_bug);
-use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions);
+use Debbugs::Packages qw(source_to_binary binary_to_source get_versions);
 
 use Debbugs::Status qw(splitpackages);
 
@@ -42,9 +65,11 @@ use Debbugs::Text qw(:templates);
 use Debbugs::DB;
 
 my $s;
+my @schema_arg = ();
 if (defined $config{database}) {
     $s = Debbugs::DB->connect($config{database}) or
         die "Unable to connect to DB";
+    @schema_arg = ('schema',$s);
 }
 
 use CGI::Simple;
@@ -301,28 +326,39 @@ my %strings = ();
 my @bugs;
 
 # addusers for source and binary packages being searched for
-my $pkgsrc = getpkgsrc();
-my $srcpkg = getsrcpkgs();
-for my $package (# For binary packages, add the binary package
-                # and corresponding source package
-                make_list($param{package}||[]),
-                (map {defined $pkgsrc->{$_}?($pkgsrc->{$_}):()}
-                 make_list($param{package}||[]),
-                ),
-                # For source packages, add the source package
-                # and corresponding binary packages
-                make_list($param{src}||[]),
-                (map {defined $srcpkg->{$_}?($srcpkg->{$_}):()}
-                 make_list($param{src}||[]),
-                ),
-               ) {
-     next unless defined $package;
-     add_user($package.'@'.$config{usertag_package_domain},
-             \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden)
-         if defined $config{usertag_package_domain};
+if (defined $config{usertag_package_domain}) {
+    my @possible_packages;
+    if (exists $param{package} and
+       defined $param{package}
+       ) {
+       # For binary packages, add the binary package and corresponding source package
+       push @possible_packages,
+           make_list($param{package});
+       push @possible_packages,
+           binary_to_source(source_only => 1,
+                            binary=>$param{package},
+                            @schema_arg,
+                           );
+    }
+    if (exists $param{src} and
+       defined $param{src}
+       ) {
+       # For source packages, add the source package and corresponding binary packages
+       push @possible_packages,
+           make_list($param{src});
+       push @possible_packages,
+           source_to_binary(binary_only => 1,
+                            source => $param{src},
+                            @schema_arg,
+                           );
+    }
+    for my $package (@possible_packages) {
+       next unless defined $package and length $package;
+       add_user($package.'@'.$config{usertag_package_domain},
+                \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
+    }
 }
 
-
 # walk through the keys and make the right get_bugs query.
 
 my $form_option_variables = {};
@@ -387,7 +423,7 @@ my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
                  grep {$_ ne 'newest'}
                  keys %package_search_keys, 'archive'),
                 usertags => \%ut,
-                defined $s?(schema => $s):(),
+                @schema_arg,
                );
 
 # shove in bugs which affect this package if there is a package or a
@@ -401,7 +437,7 @@ if (not exists $param{affects} and not exists $param{noaffects} and
                          grep {$_ ne 'newest'}
                          keys %package_search_keys, 'archive'),
                         usertags => \%ut,
-                         defined $s?(schema => $s):(),
+                        @schema_arg,
                        );
 }
 
@@ -446,7 +482,7 @@ my $result = pkg_htmlizebugs(bugs => \@bugs,
                             exclude => $exclude,
                             this => $this,
                             options => \%param,
-                             defined $s?(schema => $s):(),
+                             @schema_arg,
                             (exists $param{dist})?(dist    => $param{dist}):(),
                            );
 
@@ -481,6 +517,7 @@ for my $package (make_list($param{package}||[])) {
                                 package => $package,
                                 options => \%param,
                                 bugs    => \@bugs,
+                                @schema_arg,
                                );
 }
 for my $package (make_list($param{src}||[])) {
@@ -488,6 +525,7 @@ for my $package (make_list($param{src}||[])) {
                                 package => $package,
                                 options => \%param,
                                 bugs    => \@bugs,
+                                @schema_arg,
                                );
 }