* In `nix-channel --update', skip manifests that assume a Nix store at

a different location than the user's.  This makes channels usable as
  a source deployment mechanism for people who install Nix under
  non-standard prefixes.  (NIX-57)
This commit is contained in:
Eelco Dolstra 2006-09-25 11:11:16 +00:00
parent 68ae953d8a
commit d43565c3e8
2 changed files with 21 additions and 2 deletions

View file

@ -23,6 +23,7 @@ sub readChannels {
open CHANNELS, "<$channelsList" or die "cannot open `$channelsList': $!"; open CHANNELS, "<$channelsList" or die "cannot open `$channelsList': $!";
while (<CHANNELS>) { while (<CHANNELS>) {
chomp; chomp;
next if /^\s*\#/;
push @channels, $_; push @channels, $_;
} }
close CHANNELS; close CHANNELS;
@ -81,7 +82,7 @@ sub update {
# Pull cache manifests. # Pull cache manifests.
foreach my $url (@channels) { foreach my $url (@channels) {
print "pulling cache manifest from `$url'\n"; print "pulling cache manifest from `$url'\n";
system("@bindir@/nix-pull", "$url/MANIFEST") == 0 system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
or die "cannot pull cache manifest from `$url'"; or die "cannot pull cache manifest from `$url'";
} }

View file

@ -21,6 +21,9 @@ $libexecDir = "@libexecdir@" unless defined $libexecDir;
my $stateDir = $ENV{"NIX_STATE_DIR"}; my $stateDir = $ENV{"NIX_STATE_DIR"};
$stateDir = "@localstatedir@/nix" unless defined $stateDir; $stateDir = "@localstatedir@/nix" unless defined $stateDir;
my $storeDir = $ENV{"NIX_STORE_DIR"};
$storeDir = "@storedir@" unless defined $storeDir;
# Prevent access problems in shared-stored installations. # Prevent access problems in shared-stored installations.
umask 0022; umask 0022;
@ -31,6 +34,8 @@ my %narFiles;
my %patches; my %patches;
my %successors; my %successors;
my $skipWrongStore = 0;
sub processURL { sub processURL {
my $url = shift; my $url = shift;
@ -45,6 +50,15 @@ sub processURL {
die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n"; die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n";
} }
if ($skipWrongStore) {
foreach my $path (keys %narFiles) {
if (substr($path, 0, length($storeDir) + 1) ne "$storeDir/") {
print STDERR "warning: manifest `$url' assumes a Nix store at a different location than $storeDir, skipping...\n";
exit 0;
}
}
}
my $baseName = "unnamed"; my $baseName = "unnamed";
if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
$baseName = $1; $baseName = $1;
@ -62,7 +76,11 @@ sub processURL {
while (@ARGV) { while (@ARGV) {
my $url = shift @ARGV; my $url = shift @ARGV;
if ($url eq "--skip-wrong-store") {
$skipWrongStore = 1;
} else {
processURL $url; processURL $url;
}
} }