Rsync channel redirects to nixos.org
This commit is contained in:
parent
7f650ec13e
commit
90fcc7be84
2 changed files with 11 additions and 6 deletions
|
@ -27,7 +27,7 @@ stdenv.mkDerivation {
|
||||||
-lsqlite3
|
-lsqlite3
|
||||||
|
|
||||||
cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch
|
cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch
|
||||||
wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${nix}/bin:${gnutar}/bin:${xz}/bin:$out/bin
|
wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:$out/bin
|
||||||
|
|
||||||
patchShebangs $out/bin
|
patchShebangs $out/bin
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -25,8 +25,9 @@ my $channelDirRel = $channelName eq "nixpkgs-unstable" ? "nixpkgs" : "$1/$2";
|
||||||
|
|
||||||
|
|
||||||
# Configuration.
|
# Configuration.
|
||||||
my $channelsDir = "/data/releases/channels";
|
my $TMPDIR = $ENV{'TMPDIR'} // "/tmp";
|
||||||
my $filesCache = "/data/releases/nixos-files.sqlite";
|
my $channelsDir = "/home/hydra-mirror/channels";
|
||||||
|
my $filesCache = "${TMPDIR}/nixos-files.sqlite";
|
||||||
my $bucketName = "nix-releases";
|
my $bucketName = "nix-releases";
|
||||||
|
|
||||||
$ENV{'GIT_DIR'} = "/home/hydra-mirror/nixpkgs-channels";
|
$ENV{'GIT_DIR'} = "/home/hydra-mirror/nixpkgs-channels";
|
||||||
|
@ -72,16 +73,17 @@ 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";
|
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.
|
# Guard against the channel going back in time.
|
||||||
my @releaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // "");
|
my @curReleaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // "");
|
||||||
my $curRelease = pop @releaseUrl;
|
my $curRelease = pop @curReleaseUrl;
|
||||||
my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`;
|
my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`;
|
||||||
chomp $d;
|
chomp $d;
|
||||||
die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1;
|
die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1;
|
||||||
|
exit if $d == 0;
|
||||||
|
|
||||||
if ($bucket->head_key("$releasePrefix")) {
|
if ($bucket->head_key("$releasePrefix")) {
|
||||||
print STDERR "release already exists\n";
|
print STDERR "release already exists\n";
|
||||||
} else {
|
} else {
|
||||||
my $tmpDir = "/data/releases/tmp/release-$channelName/$releaseName";
|
my $tmpDir = "$TMPDIR/release-$channelName/$releaseName";
|
||||||
File::Path::make_path($tmpDir);
|
File::Path::make_path($tmpDir);
|
||||||
|
|
||||||
write_file("$tmpDir/src-url", $evalUrl);
|
write_file("$tmpDir/src-url", $evalUrl);
|
||||||
|
@ -226,3 +228,6 @@ system("git remote update origin >&2") == 0 or die;
|
||||||
system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die;
|
system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die;
|
||||||
|
|
||||||
flock($lockfile, LOCK_UN) or die "cannot release channels lock\n";
|
flock($lockfile, LOCK_UN) or die "cannot release channels lock\n";
|
||||||
|
|
||||||
|
# Upload to nixos.org.
|
||||||
|
system("rsync -avx $channelsDir/ hydra-mirror\@nixos.org:/releases/channels/") == 0 or die;
|
||||||
|
|
Loading…
Reference in a new issue