Branch: refs/heads/master
  Home:   https://github.com/NixOS/nix
  Commit: 1d0bafb74d17f14778005a633ee332ad0ad9ba9e
      
https://github.com/NixOS/nix/commit/1d0bafb74d17f14778005a633ee332ad0ad9ba9e
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-14 (Sat, 14 Apr 2012)

  Changed paths:
    M scripts/nix-channel.in

  Log Message:
  -----------
  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.


diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 283071a..b325197 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


================================================================
  Commit: 0b5107c016080e70d30ccba3afa0f9aa7a90a891
      
https://github.com/NixOS/nix/commit/0b5107c016080e70d30ccba3afa0f9aa7a90a891
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-14 (Sat, 14 Apr 2012)

  Changed paths:
    M corepkgs/unpack-channel.nix
    M corepkgs/unpack-channel.sh
    M scripts/nix-channel.in

  Log Message:
  -----------
  If the (redirected) channel URL contains a version number, use it


diff --git a/corepkgs/unpack-channel.nix b/corepkgs/unpack-channel.nix
index eba957d..170f3ab 100644
--- a/corepkgs/unpack-channel.nix
+++ b/corepkgs/unpack-channel.nix
@@ -1,11 +1,11 @@
 with import <nix/config.nix>;
 
-{ name, src }:
+{ name, channelName, src }:
 
 derivation {
   system = builtins.currentSystem;
   builder = shell;
   args = [ "-e" ./unpack-channel.sh ];
-  inherit name src bzip2 tar tr;
+  inherit name channelName src bzip2 tar tr;
   PATH = "${nixBinDir}:${coreutils}";
 }
diff --git a/corepkgs/unpack-channel.sh b/corepkgs/unpack-channel.sh
index 0b7d89b..f42b087 100644
--- a/corepkgs/unpack-channel.sh
+++ b/corepkgs/unpack-channel.sh
@@ -1,4 +1,4 @@
 mkdir $out
 cd $out
 $bzip2 -d < $src | $tar xf -
-mv * $out/$name
+mv * $out/$channelName
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index b325197..64e5aa0 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -108,7 +108,13 @@ sub update {
         die "cannot fetch `$fullURL'" if $? != 0;
         chomp $path;
 
-        $exprs .= "'f: f { name = \"$name\"; src = builtins.storePath 
\"$path\"; }' ";
+        # If the URL contains a version number, append it to the name
+        # attribute (so that "nix-env -q" on the channels profile
+        # shows something useful).
+        my $cname = $name;
+        $cname .= $1 if basename($url) =~ /(-\d.*)$/;
+
+        $exprs .= "'f: f { name = \"$cname\"; channelName = \"$name\"; src = 
builtins.storePath \"$path\"; }' ";
     }
 
     # Unpack the channel tarballs into the Nix store and install them


================================================================
Compare: https://github.com/NixOS/nix/compare/ca3d9f8...0b5107c
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to