From 1c07d6dd0840bba19d0fb12ae352bca3b21a3e48 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 5 Dec 2016 11:49:52 +0100 Subject: [PATCH] Lock the Git repo --- mirror-nixos-branch.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 8492303..5173e1f 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -80,10 +80,15 @@ if (defined $curReleaseDir) { die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1; } -# Update the nixpkgs-channels repo. FIXME: lock? +# Update the nixpkgs-channels repo. +open(my $lockfile, ">>", "$channelsDir/.htaccess.lock"); +flock($lockfile, LOCK_EX) or die "cannot acquire channels lock\n"; + system("git remote update origin >&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"; + if ($bucket->head_key("$releasePrefix")) { print STDERR "release already exists\n"; } else { @@ -205,7 +210,6 @@ if ($bucket->head_key("$releasePrefix")) { } # Prevent concurrent writes to the channels directory. -open(my $lockfile, ">>", "$channelsDir/.htaccess.lock"); flock($lockfile, LOCK_EX) or die "cannot acquire channels lock\n"; # Update the channel.