forked from lix-project/hydra
* $HYDRA_DATA environment variable.
This commit is contained in:
parent
82bbce9e4e
commit
cbcfdf9c54
|
@ -2,6 +2,7 @@ package Hydra;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
use Catalyst::Runtime '5.70';
|
use Catalyst::Runtime '5.70';
|
||||||
|
|
||||||
|
@ -20,8 +21,11 @@ our $VERSION = '0.01';
|
||||||
|
|
||||||
__PACKAGE__->config(
|
__PACKAGE__->config(
|
||||||
name => 'Hydra',
|
name => 'Hydra',
|
||||||
default_view => "TT"
|
default_view => "TT",
|
||||||
);
|
session => {
|
||||||
|
storage => getHydraPath . "/session_data"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
__PACKAGE__->setup();
|
__PACKAGE__->setup();
|
||||||
|
|
||||||
|
|
|
@ -751,7 +751,7 @@ sub closure :Local {
|
||||||
|
|
||||||
return error($c, "Product is not a Nix build.") if $product->type ne "nix-build";
|
return error($c, "Product is not a Nix build.") if $product->type ne "nix-build";
|
||||||
|
|
||||||
return error($c, "Path " . $product->path . " is no longer available.") unless Hydra::Helper::Nix::isValidPath($product->path);
|
return error($c, "Path " . $product->path . " is no longer available.") unless isValidPath($product->path);
|
||||||
|
|
||||||
$c->stash->{current_view} = 'Hydra::View::NixClosure';
|
$c->stash->{current_view} = 'Hydra::View::NixClosure';
|
||||||
$c->stash->{storePath} = $product->path;
|
$c->stash->{storePath} = $product->path;
|
||||||
|
|
|
@ -1,14 +1,39 @@
|
||||||
package Hydra::Helper::Nix;
|
package Hydra::Helper::Nix;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Exporter;
|
||||||
|
|
||||||
|
our @ISA = qw(Exporter);
|
||||||
|
our @EXPORT = qw(isValidPath getHydraPath getHydraDBPath openHydraDB);
|
||||||
|
|
||||||
|
|
||||||
sub isValidPath {
|
sub isValidPath {
|
||||||
my $path = shift;
|
my $path = shift;
|
||||||
$SIG{CHLD} = 'DEFAULT'; # !!! work around system() failing if SIGCHLD is ignored
|
$SIG{CHLD} = 'DEFAULT'; # !!! work around system() failing if SIGCHLD is ignored
|
||||||
return system("nix-store --check-validity $path") == 0;
|
return system("nix-store --check-validity $path 2> /dev/null") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub getHydraPath {
|
||||||
|
my $dir = $ENV{HYDRA_DATA};
|
||||||
|
die "The HYDRA_DATA environment variable is not set!\n" unless defined $dir;
|
||||||
|
die "The HYDRA_DATA directory does not exist!\n" unless -d $dir;
|
||||||
|
return $dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub getHydraDBPath {
|
||||||
|
my $path = getHydraPath . '/hydra.sqlite';
|
||||||
|
die "The Hydra database ($path) not exist!\n" unless -f $path;
|
||||||
|
return "dbi:SQLite:$path";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub openHydraDB {
|
||||||
|
my $db = Hydra::Schema->connect(getHydraDBPath, "", "", {});
|
||||||
|
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
||||||
|
return $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,11 @@ package Hydra::Model::DB;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use base 'Catalyst::Model::DBIC::Schema';
|
use base 'Catalyst::Model::DBIC::Schema';
|
||||||
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
__PACKAGE__->config(
|
__PACKAGE__->config(
|
||||||
schema_class => 'Hydra::Schema',
|
schema_class => 'Hydra::Schema',
|
||||||
connect_info => [
|
connect_info => [getHydraDBPath],
|
||||||
'dbi:SQLite:../hydra.sqlite',
|
|
||||||
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
|
@ -4,17 +4,10 @@ use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use Hydra::Schema;
|
use Hydra::Schema;
|
||||||
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
|
|
||||||
my $db = Hydra::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {});
|
my $db = openHydraDB;
|
||||||
|
|
||||||
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
|
||||||
|
|
||||||
|
|
||||||
sub isValidPath {
|
|
||||||
my $path = shift;
|
|
||||||
return system("nix-store --check-validity $path 2> /dev/null") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub doBuild {
|
sub doBuild {
|
||||||
|
|
|
@ -2,13 +2,17 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
|
use File::Basename;
|
||||||
use POSIX qw(dup2);
|
use POSIX qw(dup2);
|
||||||
use Hydra::Schema;
|
use Hydra::Schema;
|
||||||
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
|
|
||||||
my $db = Hydra::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {});
|
chdir getHydraPath or die;
|
||||||
|
my $db = openHydraDB;
|
||||||
|
|
||||||
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
my $hydraHome = $ENV{"HYDRA_HOME"};
|
||||||
|
die "The HYDRA_HOME environment variable is not set!\n" unless defined $hydraHome;
|
||||||
|
|
||||||
|
|
||||||
sub unlockDeadBuilds {
|
sub unlockDeadBuilds {
|
||||||
|
@ -69,6 +73,7 @@ sub checkBuilds {
|
||||||
|
|
||||||
foreach my $build (@builds) {
|
foreach my $build (@builds) {
|
||||||
my $logfile = getcwd . "/logs/" . $build->id;
|
my $logfile = getcwd . "/logs/" . $build->id;
|
||||||
|
mkdir(dirname $logfile);
|
||||||
unlink($logfile);
|
unlink($logfile);
|
||||||
$build->schedulingInfo->busy(1);
|
$build->schedulingInfo->busy(1);
|
||||||
$build->schedulingInfo->locker($$);
|
$build->schedulingInfo->locker($$);
|
||||||
|
@ -91,12 +96,13 @@ sub checkBuilds {
|
||||||
my $child = fork();
|
my $child = fork();
|
||||||
die unless defined $child;
|
die unless defined $child;
|
||||||
if ($child == 0) {
|
if ($child == 0) {
|
||||||
open LOG, ">$logfile" or die;
|
eval {
|
||||||
|
open LOG, ">$logfile" or die "cannot create logfile $logfile";
|
||||||
POSIX::dup2(fileno(LOG), 1) or die;
|
POSIX::dup2(fileno(LOG), 1) or die;
|
||||||
POSIX::dup2(fileno(LOG), 2) or die;
|
POSIX::dup2(fileno(LOG), 2) or die;
|
||||||
exec("perl", "-IHydra/lib", "-w",
|
exec("perl", "-I$hydraHome/lib", "-w", "$ENV{'HYDRA_HOME'}/programs/Build.pl", $id);
|
||||||
"./Hydra/programs/Build.pl", $id);
|
};
|
||||||
warn "cannot start build " . $id;
|
warn "cannot start build $id: $@";
|
||||||
POSIX::_exit(1);
|
POSIX::_exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,19 +3,12 @@
|
||||||
use strict;
|
use strict;
|
||||||
use XML::Simple;
|
use XML::Simple;
|
||||||
use Hydra::Schema;
|
use Hydra::Schema;
|
||||||
|
use Hydra::Helper::Nix;
|
||||||
use IPC::Run;
|
use IPC::Run;
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
|
|
||||||
my $db = Hydra::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {});
|
my $db = openHydraDB;
|
||||||
|
|
||||||
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
|
||||||
|
|
||||||
|
|
||||||
sub isValidPath {
|
|
||||||
my $path = shift;
|
|
||||||
return system("nix-store --check-validity $path 2> /dev/null") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub captureStdoutStderr {
|
sub captureStdoutStderr {
|
||||||
|
|
|
@ -26,7 +26,13 @@
|
||||||
<pre>$ curl [% c.uri_for('/closure' build.id product.productnr) %] | gunzip | nix-store --import</pre>
|
<pre>$ curl [% c.uri_for('/closure' build.id product.productnr) %] | gunzip | nix-store --import</pre>
|
||||||
|
|
||||||
<p>The package can then be found in the path <tt>[%
|
<p>The package can then be found in the path <tt>[%
|
||||||
product.path %]</tt>. If you get the error message “imported
|
product.path %]</tt>. You’ll probably also want to do
|
||||||
|
|
||||||
|
<pre>nix-env -i [% product.path %]</pre>
|
||||||
|
|
||||||
|
to actually install the package in your Nix user environment.</p>
|
||||||
|
|
||||||
|
<p>If you get the error message “imported
|
||||||
archive lacks a signature”, you should make sure that you have
|
archive lacks a signature”, you should make sure that you have
|
||||||
sufficient access rights to the Nix store, e.g., run the
|
sufficient access rights to the Nix store, e.g., run the
|
||||||
command as <tt>root</tt>.</p>
|
command as <tt>root</tt>.</p>
|
||||||
|
|
Loading…
Reference in a new issue