diff --git a/mirror-nixos-branch.sh b/mirror-nixos-branch.sh index 967220c..f7b6c92 100755 --- a/mirror-nixos-branch.sh +++ b/mirror-nixos-branch.sh @@ -98,6 +98,10 @@ else trap '' EXIT fi +# Prevent concurrent writes to the channels and the Git clone. +exec 10>$channelsDir/.htaccess.lock +flock 10 + # Copy over to nixos.org. cd "$releasesDir" rsync -avR . hydra-mirror@nixos.org:"$releasesDir" --exclude .htaccess --exclude ".tmp.*" --delete >&2 @@ -109,12 +113,12 @@ echo "Redirect /releases/nixos/channels/$channelName /releases/nixos/$branch/$re mv $htaccess.tmp $htaccess ln -sfn $releaseDir $channelsDir/$channelName # dummy symlink -flock -x $channelsDir/.htaccess.lock -c "cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess" +cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess cd "$channelsDir" rsync -avR . hydra-mirror@nixos.org:"$channelsDir" --delete >&2 -# Update the nixpkgs-channels repo. FIXME: protect against concurrent access +# Update the nixpkgs-channels repo. git remote update nixpkgs >&2 git push nixpkgs-channels "$rev:refs/heads/$channelName" >&2 diff --git a/mirror-nixpkgs.sh b/mirror-nixpkgs.sh index c8fb7db..e0c12c3 100755 --- a/mirror-nixpkgs.sh +++ b/mirror-nixpkgs.sh @@ -42,6 +42,10 @@ else mv $tmpDir $releaseDir fi +# Prevent concurrent writes to the channels and the Git clone. +exec 10>$channelsDir/.htaccess.lock +flock 10 + # Copy over to nixos.org. cd "$releasesDir" rsync -avR . hydra-mirror@nixos.org:"$releasesDir" --delete >&2 @@ -53,7 +57,7 @@ echo "Redirect /releases/nixpkgs/channels/$channelName /releases/nixpkgs/$releas mv $htaccess.tmp $htaccess ln -sfn $releaseDir $channelsDir/$channelName # dummy symlink -flock -x $channelsDir/.htaccess.lock -c "cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess" +cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess cd "$channelsDir" rsync -avR . hydra-mirror@nixos.org:"$channelsDir" --delete >&2