* Propagated packages now have lower priority; they are symlinked
*after* the packages that have been explicitly installed, and collisions are ignored.
This commit is contained in:
parent
3632019b73
commit
02f2335712
|
@ -10,11 +10,15 @@ my $out = $ENV{"out"};
|
||||||
mkdir "$out", 0755 || die "error creating $out";
|
mkdir "$out", 0755 || die "error creating $out";
|
||||||
|
|
||||||
|
|
||||||
|
my $symlinks = 0;
|
||||||
|
|
||||||
|
|
||||||
# For each activated package, create symlinks.
|
# For each activated package, create symlinks.
|
||||||
|
|
||||||
sub createLinks {
|
sub createLinks {
|
||||||
my $srcDir = shift;
|
my $srcDir = shift;
|
||||||
my $dstDir = shift;
|
my $dstDir = shift;
|
||||||
|
my $ignoreCollisions = shift;
|
||||||
|
|
||||||
my @srcFiles = glob("$srcDir/*");
|
my @srcFiles = glob("$srcDir/*");
|
||||||
|
|
||||||
|
@ -22,7 +26,8 @@ sub createLinks {
|
||||||
my $baseName = $srcFile;
|
my $baseName = $srcFile;
|
||||||
$baseName =~ s/^.*\///g; # strip directory
|
$baseName =~ s/^.*\///g; # strip directory
|
||||||
my $dstFile = "$dstDir/$baseName";
|
my $dstFile = "$dstDir/$baseName";
|
||||||
|
|
||||||
|
# Urgh, hacky...
|
||||||
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
||||||
$srcFile =~ /\/nix-support$/ ||
|
$srcFile =~ /\/nix-support$/ ||
|
||||||
$srcFile =~ /\/perllocal.pod$/ ||
|
$srcFile =~ /\/perllocal.pod$/ ||
|
||||||
|
@ -37,7 +42,7 @@ sub createLinks {
|
||||||
lstat $dstFile;
|
lstat $dstFile;
|
||||||
|
|
||||||
if (-d _) {
|
if (-d _) {
|
||||||
createLinks($srcFile, $dstFile);
|
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif (-l _) {
|
elsif (-l _) {
|
||||||
|
@ -48,41 +53,46 @@ sub createLinks {
|
||||||
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
||||||
mkdir $dstFile, 0755 ||
|
mkdir $dstFile, 0755 ||
|
||||||
die "error creating directory `$dstFile': $!";
|
die "error creating directory `$dstFile': $!";
|
||||||
createLinks($target, $dstFile);
|
createLinks($target, $dstFile, $ignoreCollisions);
|
||||||
createLinks($srcFile, $dstFile);
|
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
symlink($srcFile, $dstFile) ||
|
symlink($srcFile, $dstFile) ||
|
||||||
die "error creating link `$dstFile': $!";
|
die "error creating link `$dstFile': $!";
|
||||||
|
$symlinks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif (-l $dstFile) {
|
elsif (-l $dstFile) {
|
||||||
my $target = readlink $dstFile;
|
if (!$ignoreCollisions) {
|
||||||
die "collission between `$srcFile' and `$target'";
|
my $target = readlink $dstFile;
|
||||||
|
die "collission between `$srcFile' and `$target'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
# print "linking $dstFile to $srcFile\n";
|
|
||||||
symlink($srcFile, $dstFile) ||
|
symlink($srcFile, $dstFile) ||
|
||||||
die "error creating link `$dstFile': $!";
|
die "error creating link `$dstFile': $!";
|
||||||
|
$symlinks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my %done;
|
my %done;
|
||||||
|
my %postponed;
|
||||||
|
|
||||||
sub addPkg;
|
sub addPkg;
|
||||||
sub addPkg {
|
sub addPkg {
|
||||||
my $pkgDir = shift;
|
my $pkgDir = shift;
|
||||||
|
my $ignoreCollisions = shift;
|
||||||
|
|
||||||
return if (defined $done{$pkgDir});
|
return if (defined $done{$pkgDir});
|
||||||
$done{$pkgDir} = 1;
|
$done{$pkgDir} = 1;
|
||||||
|
|
||||||
print "adding $pkgDir\n";
|
# print "symlinking $pkgDir\n";
|
||||||
createLinks("$pkgDir", "$out");
|
createLinks("$pkgDir", "$out", $ignoreCollisions);
|
||||||
|
|
||||||
my $propagatedFN = "$pkgDir/nix-support/propagated-build-inputs";
|
my $propagatedFN = "$pkgDir/nix-support/propagated-build-inputs";
|
||||||
if (-e $propagatedFN) {
|
if (-e $propagatedFN) {
|
||||||
|
@ -91,19 +101,34 @@ sub addPkg {
|
||||||
close PROP;
|
close PROP;
|
||||||
my @propagated = split ' ', $propagated;
|
my @propagated = split ' ', $propagated;
|
||||||
foreach my $p (@propagated) {
|
foreach my $p (@propagated) {
|
||||||
addPkg $p;
|
$postponed{$p} = 1 unless defined $done{$p};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Symlink to the packages that have been installed explicitly by the user.
|
||||||
my @args = split ' ', $ENV{"derivations"};
|
my @args = split ' ', $ENV{"derivations"};
|
||||||
|
|
||||||
while (scalar @args > 0) {
|
foreach my $pkgDir (sort @args) {
|
||||||
my $drvPath = shift @args;
|
addPkg($pkgDir, 0);
|
||||||
addPkg($drvPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Symlink to the packages that have been "propagated" by packages
|
||||||
|
# installed by the user (i.e., package X declares that it want Y
|
||||||
|
# installed as well). We do these later because they have a lower
|
||||||
|
# priority in case of collisions.
|
||||||
|
while (scalar(keys %postponed) > 0) {
|
||||||
|
my @pkgDirs = keys %postponed;
|
||||||
|
%postponed = ();
|
||||||
|
foreach my $pkgDir (sort @pkgDirs) {
|
||||||
|
addPkg($pkgDir, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print STDERR "created $symlinks symlinks in user environment\n";
|
||||||
|
|
||||||
|
|
||||||
symlink($ENV{"manifest"}, "$out/manifest") or die "cannot create manifest";
|
symlink($ENV{"manifest"}, "$out/manifest") or die "cannot create manifest";
|
||||||
|
|
Loading…
Reference in a new issue