X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fversion.cgi;h=36e3ee879a9a05d4719eb85ee994b2860e97932b;hb=4e825a8244209a9daec474381912df08470eae6f;hp=e3df1fc1cd2decd453e54c67681a91d07f6b61f2;hpb=6321024b3c612ef7626eef85499a34ee35f7372c;p=debbugs.git diff --git a/cgi/version.cgi b/cgi/version.cgi index e3df1fc..36e3ee8 100755 --- a/cgi/version.cgi +++ b/cgi/version.cgi @@ -11,6 +11,28 @@ BEGIN{ } } +# 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; use CGI::Simple; @@ -20,16 +42,22 @@ use CGI::Simple; use Debbugs::Config qw(:config); our $VERSION=1; - +use Debbugs::DB; use Debbugs::CGI qw(htmlize_packagelinks html_escape cgi_parameters munge_url :cache); use Debbugs::Versions; use Debbugs::Versions::Dpkg; -use Debbugs::Packages qw(get_versions makesourceversions); +use Debbugs::Packages qw(get_versions make_source_versions); use HTML::Entities qw(encode_entities); use File::Temp qw(tempdir); use IO::File; use IO::Handle; +my @schema_arg = (); +if (defined $config{database}) { + my $s = Debbugs::DB->connect($config{database}) or + die "Unable to connect to DB"; + @schema_arg = ('schema',$s); +} my %img_types = (svg => 'image/svg+xml', png => 'image/png', @@ -119,6 +147,7 @@ for my $dist (@{$config{distributions}}) { $versions{$dist} = [get_versions(package => [split /\s*,\s*/, $cgi_var{package}], dist => $dist, source => 1, + @schema_arg, )]; # make version_to_dist foreach my $version (@{$versions{$dist}}){ @@ -128,9 +157,18 @@ for my $dist (@{$config{distributions}}) { # then figure out which are affected. # turn found and fixed into full versions -@{$cgi_var{found}} = map {makesourceversions($_,undef,@{$cgi_var{found}})} split/\s*,\s*/, $cgi_var{package}; -@{$cgi_var{fixed}} = map {makesourceversions($_,undef,@{$cgi_var{fixed}})} split/\s*,\s*/, $cgi_var{package}; -my @interesting_versions = map {makesourceversions($_,undef,keys %version_to_dist)} split/\s*,\s*/, $cgi_var{package}; +@{$cgi_var{found}} = + map {make_source_versions(package => $_, + versions => $cgi_var{found})} + split/\s*,\s*/, $cgi_var{package}; +@{$cgi_var{fixed}} = + map {make_source_versions(package =>$_, + versions => $cgi_var{fixed})} + split/\s*,\s*/, $cgi_var{package}; +my @interesting_versions = + map {make_source_versions(package => $_, + versions => [keys %version_to_dist])} + split/\s*,\s*/, $cgi_var{package}; # We need to be able to rip out leaves which the versions that do not affect the current versions of unstable/testing my %sources; @@ -141,7 +179,7 @@ my %sources; # at this point, we know enough to calculate the etag. my @versions_files; -foreach my $source (keys %sources) { +foreach my $source (sort keys %sources) { my $srchash = substr $source, 0, 1; next unless -e "$config{version_packages_dir}/$srchash/$source"; push @versions_files, "$config{version_packages_dir}/$srchash/$source"; @@ -232,7 +270,6 @@ if ($cgi_var{collapse}) { # nodes that can be collapsed are those that have one child # are in the same state as their parent, and are not in a suite foreach my $key (keys %reversed_nodes) { - my ($short_version) = $key =~ m{/(.+)$}; if (not exists $version_to_dist{$key} and @{$reversed_nodes{$key}} <= 1 and defined $version->{parent}{$key} @@ -282,7 +319,6 @@ if ($cgi_var{collapse}) { } foreach my $key (keys %all_states) { - my ($short_version) = $key =~ m{/(.+)$}; next if exists $collapsed_nodes{$key}; next if $cgi_var{ignore_boring} and (not defined $all_states{$key} or $all_states{$key} eq 'absent');