* Generate manifests on demand. Next step: generate NAR archives on

[?]
Feb 13, 2009, 5:35 PM
IWVA2P2Y2RMX3F6AQNJ5JMK6VTAAC2YCQT25GYN5TTEXUWCBDY2QC

Dependencies

  • [2] PKPWUHUX * Idem.
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] L5VIEXSC * Allow downloading of build products.
  • [*] BA46C5LN * Pretty-print the logs.

Change contents

  • edit in src/Hydra/lib/Hydra/Controller/Root.pm at line 708
    [5.500]
    [6.229]
    sub manifest :Local {
    my ($self, $c, $buildId) = @_;
  • edit in src/Hydra/lib/Hydra/Controller/Root.pm at line 713
    [6.230]
    [6.230]
    my $build = getBuild($c, $buildId);
    return error($c, "Build with ID $buildId doesn't exist.") if !defined $build;
  • edit in src/Hydra/lib/Hydra/Controller/Root.pm at line 716
    [6.231]
    [4.2597]
    $c->stash->{current_view} = 'Hydra::View::NixManifest';
    $c->stash->{storePath} = $build->outpath;
    }
  • file addition: NixManifest.pm (----------)
    [2.646]
    package Hydra::View::NixManifest;
    use strict;
    use base qw/Catalyst::View/;
    use IO::Pipe;
    use IPC::Run;
    use POSIX qw(dup2);
    sub captureStdoutStderr {
    my $stdin = ""; my $stdout; my $stderr;
    my $res = IPC::Run::run(\@_, \$stdin, \$stdout, \$stderr);
    return ($res, $stdout, $stderr);
    }
    sub process {
    my ($self, $c) = @_;
    my $storePath = $c->stash->{storePath};
    $c->response->content_type('text/x-nix-manifest');
    my @paths = split '\n', `nix-store --query --requisites $storePath`
    or die "cannot query dependencies of `$storePath': $?";
    my $manifest =
    "version {\n" .
    " ManifestVersion: 3\n" .
    "}\n";
    foreach my $path (@paths) {
    my ($res, $out, $err) = captureStdoutStderr(qw(nix-store --query --references), $path);
    die "cannot query references of `$path':\n$err" unless $res;
    my @refs = split '\n', $out;
    my $hash = `nix-store --query --hash $path`
    or die "cannot query hash of `$path': $?";
    chomp $hash;
    my $url = $c->uri_for('/nar' . $path);
    $manifest .=
    "{\n" .
    " StorePath: $path\n" .
    " NarURL: $url\n" .
    " References: @refs\n" .
    " Hash: $hash\n" .
    "}\n";
    }
    $c->response->body($manifest);
    return 1;
    }
    1;