From 69e3aa043893ca6abede95263d2da288b006e61a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 1 Aug 2014 17:24:55 +0200 Subject: [PATCH] Write Hydra roots as regular files instead of symlinks Note that this requires at least NixOS/Nix@1c208f2b7ef8ffb5e6d435d703dad83223a67bd6. --- src/lib/Hydra/Helper/Nix.pm | 8 ++------ src/script/hydra-s3-backup-collect-garbage | 2 +- src/script/hydra-update-gc-roots | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index cf41087b..9705fb9d 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -78,13 +78,9 @@ sub gcRootFor { sub registerRoot { my ($path) = @_; - my $link = gcRootFor $path; - - if (!-l $link) { - symlink($path, $link) - or die "cannot create GC root `$link' to `$path'"; - } + open ROOT, ">$link" or die "cannot create GC root `$link' to `$path'"; + close ROOT; } diff --git a/src/script/hydra-s3-backup-collect-garbage b/src/script/hydra-s3-backup-collect-garbage index 9de97be8..990fa535 100755 --- a/src/script/hydra-s3-backup-collect-garbage +++ b/src/script/hydra-s3-backup-collect-garbage @@ -32,7 +32,7 @@ closedir DIR; my @actual_roots = (); foreach my $link (@roots) { 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 diff --git a/src/script/hydra-update-gc-roots b/src/script/hydra-update-gc-roots index 021e1f6d..baf8c4ef 100755 --- a/src/script/hydra-update-gc-roots +++ b/src/script/hydra-update-gc-roots @@ -130,10 +130,10 @@ foreach my $link (@roots) { # Don't delete roots that are less than a day old, to prevent # a race where hydra-eval-jobs has added a root but # hydra-evaluator hasn't added them to the database yet. - my $st = lstat("$gcRootsDir/$link"); - if (!defined $st) { + my $st = lstat("$gcRootsDir/$link"); + if (!defined $st) { 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"; $rootsDeleted++; unlink "$gcRootsDir/$link" or warn "cannot remove $gcRootsDir/$link";