diff --git a/mirror-channel.pl b/mirror-channel.pl index 4bb1b35..e36d3d5 100644 --- a/mirror-channel.pl +++ b/mirror-channel.pl @@ -3,6 +3,7 @@ use readmanifest; use File::Basename; use File::stat; use File::Temp qw/tempfile/; +use Fcntl ':flock'; if (scalar @ARGV != 3 && scalar @ARGV != 4) { print STDERR "Syntax: perl mirror-channel.pl []\n"; @@ -18,6 +19,9 @@ my $nixexprsURL = $ARGV[3] || "$srcChannelURL/nixexprs.tar.bz2"; die "$dstChannelPath doesn't exist\n" unless -d $dstChannelPath; +open LOCK, ">$dstChannelPath/.lock" or die; +flock LOCK, LOCK_EX; + my ($fh, $tmpManifest) = tempfile(UNLINK => 1); system("$curl '$srcChannelURL/MANIFEST' > $tmpManifest") == 0 or die;