forked from lix-project/hydra
* Speed up manifest generation.
This commit is contained in:
parent
cf37152849
commit
b1501bc1cd
|
@ -7,7 +7,8 @@ use File::Basename;
|
|||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
isValidPath getHydraPath getHydraDBPath openHydraDB
|
||||
isValidPath queryPathInfo
|
||||
getHydraPath getHydraDBPath openHydraDB
|
||||
registerRoot getGCRootsDir
|
||||
getPrimaryBuildsForReleaseSet getRelease getLatestSuccessfulRelease );
|
||||
|
||||
|
@ -22,6 +23,39 @@ sub isValidPath {
|
|||
}
|
||||
|
||||
|
||||
sub queryPathInfo {
|
||||
my $path = shift;
|
||||
|
||||
# !!! like above, this breaks abstraction. What we really need is
|
||||
# Perl bindings for libstore :-)
|
||||
|
||||
open FH, "</nix/var/nix/db/info/" . basename $path
|
||||
or die "cannot open info file for $path";
|
||||
|
||||
my $hash;
|
||||
my $deriver;
|
||||
my @refs = ();
|
||||
|
||||
while (<FH>) {
|
||||
if (/^Hash: (\S+)$/) {
|
||||
$hash = $1;
|
||||
}
|
||||
elsif (/^Deriver: (\S+)$/) {
|
||||
$deriver = $1;
|
||||
}
|
||||
elsif (/^References: (.*)$/) {
|
||||
@refs = split / /, $1;
|
||||
}
|
||||
}
|
||||
|
||||
close FH;
|
||||
|
||||
die unless defined $hash;
|
||||
|
||||
return ($hash, $deriver, \@refs);
|
||||
}
|
||||
|
||||
|
||||
sub getHydraPath {
|
||||
my $dir = $ENV{"HYDRA_DATA"};
|
||||
die "The HYDRA_DATA environment variable is not set!\n" unless defined $dir;
|
||||
|
|
|
@ -2,8 +2,7 @@ package Hydra::View::NixManifest;
|
|||
|
||||
use strict;
|
||||
use base qw/Catalyst::View/;
|
||||
use IO::Pipe;
|
||||
use POSIX qw(dup2);
|
||||
use Hydra::Helper::Nix;
|
||||
|
||||
|
||||
sub process {
|
||||
|
@ -22,24 +21,15 @@ sub process {
|
|||
"}\n";
|
||||
|
||||
foreach my $path (@paths) {
|
||||
my @refs = split '\n', `nix-store --query --references $path`;
|
||||
die "cannot query references of `$path': $?" if $? != 0;
|
||||
|
||||
my $hash = `nix-store --query --hash $path`
|
||||
or die "cannot query hash of `$path': $?";
|
||||
chomp $hash;
|
||||
my ($hash, $deriver, $refs) = queryPathInfo $path;
|
||||
|
||||
my $url = $c->stash->{narBase} . $path;
|
||||
|
||||
my $deriver = `nix-store --query --deriver $path`
|
||||
or die "cannot query deriver of `$path': $?";
|
||||
chomp $deriver;
|
||||
|
||||
$manifest .=
|
||||
"{\n" .
|
||||
" StorePath: $path\n" .
|
||||
(scalar @refs > 0 ? " References: @refs\n" : "") .
|
||||
($deriver ne "unknown-deriver" ? " Deriver: $deriver\n" : "") .
|
||||
(scalar @{$refs} > 0 ? " References: @{$refs}\n" : "") .
|
||||
(defined $deriver ? " Deriver: $deriver\n" : "") .
|
||||
" NarURL: $url\n" .
|
||||
" NarHash: $hash\n" .
|
||||
"}\n";
|
||||
|
|
Loading…
Reference in a new issue