]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgreport.cgi
pass schema_arg everywhere if it exists
[debbugs.git] / cgi / pkgreport.cgi
index a0d7685d73f28ba72220d68254b98b657d094ed5..17203a8c61790386e2c1c883b14cd8260a159505 100755 (executable)
@@ -18,9 +18,32 @@ 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::Util qw(uniq);
+use List::AllUtils qw(uniq);
 
 use Debbugs::Config qw(:globals :text :config);
 
@@ -39,6 +62,16 @@ use Debbugs::CGI::Pkgreport qw(:all);
 
 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;
 my $q = new CGI::Simple;
 
@@ -379,6 +412,7 @@ my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
                  grep {$_ ne 'newest'}
                  keys %package_search_keys, 'archive'),
                 usertags => \%ut,
+                @schema_arg,
                );
 
 # shove in bugs which affect this package if there is a package or a
@@ -392,6 +426,7 @@ if (not exists $param{affects} and not exists $param{noaffects} and
                          grep {$_ ne 'newest'}
                          keys %package_search_keys, 'archive'),
                         usertags => \%ut,
+                        @schema_arg,
                        );
 }
 
@@ -436,6 +471,7 @@ my $result = pkg_htmlizebugs(bugs => \@bugs,
                             exclude => $exclude,
                             this => $this,
                             options => \%param,
+                             @schema_arg,
                             (exists $param{dist})?(dist    => $param{dist}):(),
                            );
 
@@ -470,6 +506,7 @@ for my $package (make_list($param{package}||[])) {
                                 package => $package,
                                 options => \%param,
                                 bugs    => \@bugs,
+                                @schema_arg,
                                );
 }
 for my $package (make_list($param{src}||[])) {
@@ -477,6 +514,7 @@ for my $package (make_list($param{src}||[])) {
                                 package => $package,
                                 options => \%param,
                                 bugs    => \@bugs,
+                                @schema_arg,
                                );
 }