* hydra_update_gc_roots.pl registers build outputs that should be kept
[?]
Jan 13, 2009, 2:02 PM
WZ3AEJ67LOG5L335AAC2BDLIJPIU4VSCGBMATBHDZC26ECRS5A6ACDependencies
- [2]
AFTXA575* $HYDRA_DATA environment variable. - [3]
2GK5DOU7* Downloading closures. - [4]
GZAXDYBQ* Script for initialising the database. - [*]
J5UVLXOK* Start of a basic Catalyst web interface. - [*]
LQNBKF3D - [*]
US27ZTX5* HydraFrontend -> Hydra.
Change contents
- edit in src/Hydra/lib/Hydra/Controller/Root.pm at line 681
$c->stash->{available} = isValidPath $build->outpath; - edit in src/Hydra/lib/Hydra/Helper/Nix.pm at line 5
use File::Basename; - replacement in src/Hydra/lib/Hydra/Helper/Nix.pm at line 13
$SIG{CHLD} = 'DEFAULT'; # !!! work around system() failing if SIGCHLD is ignoredreturn system("nix-store --check-validity $path 2> /dev/null") == 0;#$SIG{CHLD} = 'DEFAULT'; # !!! work around system() failing if SIGCHLD is ignored#return system("nix-store --check-validity $path 2> /dev/null") == 0;# This is faster than calling nix-store, but it breaks abstraction...return -e ("/nix/var/nix/db/info/" . basename $path); - edit in src/Hydra/root/build.tt at line 243
[% IF !available %]<p class="error">Note: this build is no longer available.</p>[% END %] - file addition: hydra_update_gc_roots.pl[8.1560]
#! /var/run/current-system/sw/bin/perl -wuse strict;use File::Path;use File::Basename;use Hydra::Schema;use Hydra::Helper::Nix;my $db = openHydraDB;die unless defined $ENV{LOGNAME};my $gcRootsDir = "/nix/var/nix/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";my %roots;sub registerRoot {my ($path) = @_;print "$path\n";mkpath($gcRootsDir) if !-e $gcRootsDir;my $link = "$gcRootsDir/" . basename $path;if (!-e $link) {symlink($path, $link)or die "cannot creating symlink in $gcRootsDir to $path";}$roots{$path} = 1;}# Determine which builds to keep automatically.my %pathsToKeep;# TODO# For finished builds, we only keep the output path, not the derivation.foreach my $build ($db->resultset('Builds')->search({finished => 1, buildStatus => 0}, {join => 'resultInfo'})) {if ($build->resultInfo->keep || defined $pathsToKeep{$build->outpath}) {if (isValidPath($build->outpath)) {registerRoot $build->outpath;} else {print STDERR "warning: output ", $build->outpath, " has disappeared\n";}}}# For scheduled builds, we register the derivation as a GC root.foreach my $build ($db->resultset('Builds')->search({finished => 0}, {join => 'schedulingInfo'})) {if (isValidPath($build->drvpath)) {registerRoot $build->drvpath;} else {print STDERR "warning: derivation ", $build->drvpath, " has disappeared\n";}}# Remove existing roots that are no longer wanted. !!! racyopendir DIR, $gcRootsDir or die;foreach my $link (readdir DIR) {next if !-l "$gcRootsDir/$link";my $path = readlink "$gcRootsDir/$link" or die;if (!defined $roots{$path}) {print STDERR "removing root $path\n";unlink "$gcRootsDir/$link" or die "cannot remove $gcRootsDir/$link";}}closedir DIR;