forked from lix-project/hydra
* Quick hack to allow viewing of dependency graphs (via nix-store -q
--graph). Maybe I should use SVG, since the generated PNGs tend to be huge.
This commit is contained in:
parent
c8ad58a774
commit
f0f5b095cc
|
@ -34,6 +34,7 @@ sub view_build : Chained('build') PathPart('') Args(0) {
|
||||||
$c->stash->{template} = 'build.tt';
|
$c->stash->{template} = 'build.tt';
|
||||||
$c->stash->{curTime} = time;
|
$c->stash->{curTime} = time;
|
||||||
$c->stash->{available} = isValidPath $build->outpath;
|
$c->stash->{available} = isValidPath $build->outpath;
|
||||||
|
$c->stash->{drvAvailable} = isValidPath $build->drvpath;
|
||||||
|
|
||||||
if (!$build->finished && $build->schedulingInfo->busy) {
|
if (!$build->finished && $build->schedulingInfo->busy) {
|
||||||
my $logfile = $build->schedulingInfo->logfile;
|
my $logfile = $build->schedulingInfo->logfile;
|
||||||
|
@ -88,7 +89,7 @@ sub download : Chained('build') PathPart('download') {
|
||||||
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
|
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
|
||||||
notFound($c, "Build doesn't have a product $productnr.") if !defined $product;
|
notFound($c, "Build doesn't have a product $productnr.") if !defined $product;
|
||||||
|
|
||||||
error($c, "Product " . $product->path . " has disappeared.") unless -e $product->path;
|
notFound($c, "Product " . $product->path . " has disappeared.") unless -e $product->path;
|
||||||
|
|
||||||
# Security paranoia.
|
# Security paranoia.
|
||||||
foreach my $elem (@path) {
|
foreach my $elem (@path) {
|
||||||
|
@ -111,6 +112,36 @@ sub download : Chained('build') PathPart('download') {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub runtimedeps : Chained('build') PathPart('runtime-deps') {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
my $build = $c->stash->{build};
|
||||||
|
|
||||||
|
notFound($c, "Path " . $build->outpath . " is no longer available.")
|
||||||
|
unless isValidPath($build->outpath);
|
||||||
|
|
||||||
|
$c->stash->{current_view} = 'Hydra::View::NixDepGraph';
|
||||||
|
$c->stash->{storePaths} = [$build->outpath];
|
||||||
|
|
||||||
|
$c->response->content_type('image/png'); # !!!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub buildtimedeps : Chained('build') PathPart('buildtime-deps') {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
my $build = $c->stash->{build};
|
||||||
|
|
||||||
|
notFound($c, "Path " . $build->drvpath . " is no longer available.")
|
||||||
|
unless isValidPath($build->drvpath);
|
||||||
|
|
||||||
|
$c->stash->{current_view} = 'Hydra::View::NixDepGraph';
|
||||||
|
$c->stash->{storePaths} = [$build->drvpath];
|
||||||
|
|
||||||
|
$c->response->content_type('image/png'); # !!!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub nix : Chained('build') PathPart('nix') CaptureArgs(0) {
|
sub nix : Chained('build') PathPart('nix') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
|
24
src/Hydra/lib/Hydra/View/NixDepGraph.pm
Normal file
24
src/Hydra/lib/Hydra/View/NixDepGraph.pm
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package Hydra::View::NixDepGraph;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use base qw/Catalyst::View/;
|
||||||
|
use IO::Pipe;
|
||||||
|
|
||||||
|
sub process {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
$c->response->content_type('image/png');
|
||||||
|
|
||||||
|
my @storePaths = @{$c->stash->{storePaths}};
|
||||||
|
|
||||||
|
open(OUTPUT, "nix-store --query --graph @storePaths | dot -Tpng -Gbgcolor=transparent |");
|
||||||
|
|
||||||
|
my $fh = new IO::Handle;
|
||||||
|
$fh->fdopen(fileno(OUTPUT), "r") or die;
|
||||||
|
|
||||||
|
$c->response->body($fh);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -86,11 +86,21 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Derivation store path:</th>
|
<th>Derivation store path:</th>
|
||||||
<td><tt>[% build.drvpath %]</tt></td>
|
<td>
|
||||||
|
<tt>[% build.drvpath %]</tt>
|
||||||
|
[% IF drvAvailable %]
|
||||||
|
(<a href="[% c.uri_for('/build' build.id 'buildtime-deps') %]">build-time dependencies</a>)
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Output store path:</th>
|
<th>Output store path:</th>
|
||||||
<td><tt>[% build.outpath %]</tt></td>
|
<td>
|
||||||
|
<tt>[% build.outpath %]</tt>
|
||||||
|
[% IF available %]
|
||||||
|
(<a href="[% c.uri_for('/build' build.id 'runtime-deps') %]">runtime dependencies</a>)
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% IF build.finished %]
|
[% IF build.finished %]
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue