From d313d2bd51ee9754c3b719a9664c085ec24905ae Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 25 Aug 2018 23:18:47 -0400 Subject: [PATCH] Fixes channel going back in time due to incomplete change. The change in d3d33d5b2518e4e6516b6f31270b406937c48ca2 changed how the locally saved channel information was saved on the local machine. * https://github.com/NixOS/nixos-channel-scripts/commit/d3d33d5b2518e4e6516b6f31270b406937c48ca2#diff-682bf482f6dd273f1c3c49afd99b4660R192 The changeset did *not* change the guard clause, which now made it act like this: 1. Try readlink on the file 2. (bail as it's undefined) The new behaviour is as more or less expected: 1. Reads the file if available 2. Split the URL components 3. Keep the last bit This can give us an empty string, which will compare to `-1` thus fulfilling the need. --- mirror-nixos-branch.pl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 9dc88b2..9c37fc6 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -72,13 +72,11 @@ my $rev = $evalInfo->{jobsetevalinputs}->{nixpkgs}->{revision} or die; print STDERR "release is ‘$releaseName’ (build $releaseId), eval is $evalId, prefix is $releasePrefix, Git commit is $rev\n"; # Guard against the channel going back in time. -my $curReleaseDir = readlink "$channelsDir/$channelName"; -if (defined $curReleaseDir) { - my $curRelease = basename($curReleaseDir); - my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`; - chomp $d; - die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1; -} +my @releaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // ""); +my $curRelease = pop @releaseUrl; +my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`; +chomp $d; +die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1; if ($bucket->head_key("$releasePrefix")) { print STDERR "release already exists\n";