From f0f5b095cc5f0b81c06b1d1156ae2162b5cfe949 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 27 Feb 2009 15:31:49 +0000 Subject: [PATCH] * 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. --- src/Hydra/lib/Hydra/Controller/Build.pm | 33 ++++++++++++++++++++++++- src/Hydra/lib/Hydra/View/NixDepGraph.pm | 24 ++++++++++++++++++ src/Hydra/root/build.tt | 14 +++++++++-- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/Hydra/lib/Hydra/View/NixDepGraph.pm diff --git a/src/Hydra/lib/Hydra/Controller/Build.pm b/src/Hydra/lib/Hydra/Controller/Build.pm index 41f5d52b..131ce229 100644 --- a/src/Hydra/lib/Hydra/Controller/Build.pm +++ b/src/Hydra/lib/Hydra/Controller/Build.pm @@ -34,6 +34,7 @@ sub view_build : Chained('build') PathPart('') Args(0) { $c->stash->{template} = 'build.tt'; $c->stash->{curTime} = time; $c->stash->{available} = isValidPath $build->outpath; + $c->stash->{drvAvailable} = isValidPath $build->drvpath; if (!$build->finished && $build->schedulingInfo->busy) { my $logfile = $build->schedulingInfo->logfile; @@ -88,7 +89,7 @@ sub download : Chained('build') PathPart('download') { my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr}); 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. 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) { my ($self, $c) = @_; diff --git a/src/Hydra/lib/Hydra/View/NixDepGraph.pm b/src/Hydra/lib/Hydra/View/NixDepGraph.pm new file mode 100644 index 00000000..03c9aa16 --- /dev/null +++ b/src/Hydra/lib/Hydra/View/NixDepGraph.pm @@ -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; diff --git a/src/Hydra/root/build.tt b/src/Hydra/root/build.tt index b62135cd..eefa0ff7 100644 --- a/src/Hydra/root/build.tt +++ b/src/Hydra/root/build.tt @@ -86,11 +86,21 @@ Derivation store path: - [% build.drvpath %] + + [% build.drvpath %] + [% IF drvAvailable %] + (build-time dependencies) + [% END %] + Output store path: - [% build.outpath %] + + [% build.outpath %] + [% IF available %] + (runtime dependencies) + [% END %] + [% IF build.finished %]