summary refs log tree commit diff
path: root/scripts/nix-channel.in
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-04-14 21:04:22 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-04-14 21:04:22 +0200
commit1d0bafb74d17f14778005a633ee332ad0ad9ba9e (patch)
tree337ee28c9d49cc0a77436a2f8f030f17a8edb0e2 /scripts/nix-channel.in
parentca3d9f8b31378093ecfbce493aab979c97d5ba78 (diff)
downloadguix-1d0bafb74d17f14778005a633ee332ad0ad9ba9e.tar.gz
Follow redirects early to ensure consistency between the manifest and the tarball
Without this change, if the URL is a redirect that changes in between,
we can get a manifest that doesn't match the tarball.
Diffstat (limited to 'scripts/nix-channel.in')
-rwxr-xr-xscripts/nix-channel.in8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 283071a9c8..b3251975b5 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -88,6 +88,14 @@ sub update {
     my $exprs = "";
     foreach my $name (keys %channels) {
         my $url = $channels{$name};
+
+        # Check if $url is a redirect.  If so, follow it now to ensure
+        # consistency if the redirection is changed between
+        # downloading the manifest and the tarball.
+        my $headers = `$Nix::Config::curl --silent --head '$url'`;
+        die "$0: unable to check `$url'\n" if $? != 0;
+        $headers =~ s/\r//g;
+        $url = $1 if $headers =~ /^Location:\s*(.*)\s*$/m;
         
         # Pull the channel manifest.
         system("$Nix::Config::binDir/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0