-
-
Save samueldr/f34d8684d68252df95667df60ccd7b7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Basename; | |
use File::Path; | |
use File::Slurp; | |
my $channelName = "nixos-unstable"; | |
# configuration | |
my $channelsDir = "/Users/samuel/tmp/tmp/data/releases/channels"; | |
my $releasePrefix = "FOO"; # unimportant! | |
my $target = "https://releases.nixos.org/$releasePrefix"; | |
# THIS IS OUT OF ORDER FROM REALITY! | |
# This test file tests the behaviour of re-reading the file. | |
# https://github.com/NixOS/nixos-channel-scripts/blob/e9587f93887292a5d7252bc60bae09ed7c3e3f27/mirror-nixos-branch.pl#L217-L221 | |
my $channelLink = "$channelsDir/$channelName"; | |
if ((read_file($channelLink, err_mode => 'quiet') // "") ne $target) { | |
write_file("$channelLink.tmp", "$target"); | |
rename("$channelLink.tmp", $channelLink) or die; | |
} | |
# https://github.com/NixOS/nixos-channel-scripts/blob/e9587f93887292a5d7252bc60bae09ed7c3e3f27/mirror-nixos-branch.pl#L74-L81 | |
my $curReleaseDir = readlink "$channelsDir/$channelName"; | |
if (defined $curReleaseDir) { | |
my $curRelease = basename($curReleaseDir); | |
print "Wanted: $releasePrefix Got: $curRelease\n"; | |
} | |
else { | |
print "!! curReleaseDir unset!\n" | |
} | |
my @releaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // ""); | |
my $curRelease = pop @releaseUrl; | |
print "Wanted: $releasePrefix Got: $curRelease\n"; | |
if ($curRelease eq $releasePrefix) { | |
print "🎉"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment