diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-04-14 21:04:22 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-04-14 21:04:22 +0200 |
commit | 1d0bafb74d17f14778005a633ee332ad0ad9ba9e (patch) | |
tree | 337ee28c9d49cc0a77436a2f8f030f17a8edb0e2 /scripts | |
parent | ca3d9f8b31378093ecfbce493aab979c97d5ba78 (diff) |
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')
-rwxr-xr-x | scripts/nix-channel.in | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 283071a9c..b3251975b 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 |