Lock the Git repo

This commit is contained in:
Eelco Dolstra 2016-12-05 11:49:52 +01:00
parent 2fd4d6beea
commit 1c07d6dd08
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -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.