Write Hydra roots as regular files instead of symlinks

Note that this requires at least NixOS/Nix@1c208f2b7e.
This commit is contained in:
Eelco Dolstra 2014-08-01 17:24:55 +02:00
parent 7351752066
commit 69e3aa0438
3 changed files with 6 additions and 10 deletions

View file

@ -78,13 +78,9 @@ sub gcRootFor {
sub registerRoot { sub registerRoot {
my ($path) = @_; my ($path) = @_;
my $link = gcRootFor $path; my $link = gcRootFor $path;
open ROOT, ">$link" or die "cannot create GC root `$link' to `$path'";
if (!-l $link) { close ROOT;
symlink($path, $link)
or die "cannot create GC root `$link' to `$path'";
}
} }

View file

@ -32,7 +32,7 @@ closedir DIR;
my @actual_roots = (); my @actual_roots = ();
foreach my $link (@roots) { foreach my $link (@roots) {
next if $link eq "." || $link eq ".."; next if $link eq "." || $link eq "..";
push @actual_roots, readlink "$gcRootsDir/$link"; push @actual_roots, $Nix::Config::storeDir . "/" . $link;
} }
# Don't delete a nix-cache-info file, if present # Don't delete a nix-cache-info file, if present

View file

@ -130,10 +130,10 @@ foreach my $link (@roots) {
# Don't delete roots that are less than a day old, to prevent # Don't delete roots that are less than a day old, to prevent
# a race where hydra-eval-jobs has added a root but # a race where hydra-eval-jobs has added a root but
# hydra-evaluator hasn't added them to the database yet. # hydra-evaluator hasn't added them to the database yet.
my $st = lstat("$gcRootsDir/$link"); my $st = lstat("$gcRootsDir/$link");
if (!defined $st) { if (!defined $st) {
print STDERR "skipping link $link: $!\n"; print STDERR "skipping link $link: $!\n";
} elsif ($st->ctime < $now - 24 * 60 * 60) { } elsif ($st->ctime < $now - 24 * 60 * 60) {
print STDERR "removing root $path\n"; print STDERR "removing root $path\n";
$rootsDeleted++; $rootsDeleted++;
unlink "$gcRootsDir/$link" or warn "cannot remove $gcRootsDir/$link"; unlink "$gcRootsDir/$link" or warn "cannot remove $gcRootsDir/$link";