Support revision control systems via plugins

This commit is contained in:
Eelco Dolstra
2013-05-25 15:36:58 -04:00
parent 5e0542d3af
commit 1f1615e80b
15 changed files with 588 additions and 513 deletions

View File

@ -11,6 +11,7 @@ use Hydra::Model::DB;
our @ISA = qw(Exporter);
our @EXPORT = qw(
getHydraHome getHydraConfig txn_do
getSCMCacheDir
registerRoot getGCRootsDir gcRootFor
getPrimaryBuildsForView
getPrimaryBuildTotal
@ -18,7 +19,8 @@ our @EXPORT = qw(
jobsetOverview removeAsciiEscapes getDrvLogPath logContents
getMainOutput
getEvals getMachines
pathIsInsidePrefix);
pathIsInsidePrefix
captureStdoutStderr);
sub getHydraHome {
@ -50,6 +52,11 @@ sub txn_do {
}
sub getSCMCacheDir {
return Hydra::Model::DB::getHydraPath . "/scm" ;
}
sub getGCRootsDir {
die unless defined $ENV{LOGNAME};
my $dir = ($ENV{NIX_STATE_DIR} || "/nix/var/nix" ) . "/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";
@ -443,4 +450,26 @@ sub pathIsInsidePrefix {
}
sub captureStdoutStderr {
my ($timeout, @cmd) = @_;
my $stdin = "";
my $stdout;
my $stderr;
eval {
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
alarm $timeout;
IPC::Run::run(\@cmd, \$stdin, \$stdout, \$stderr);
alarm 0;
};
if ($@) {
die unless $@ eq "timeout\n"; # propagate unexpected errors
return (-1, "", "timeout\n");
} else {
return ($?, $stdout, $stderr);
}
}
1;