forked from lix-project/lix
buildenv.pl: Create symlinks in priority order
This reduces unnecessary symlink/unlink steps.
This commit is contained in:
parent
2d5e8e267b
commit
56d29dcd62
|
@ -78,10 +78,10 @@ sub createLinks {
|
||||||
if (-l $dstFile) {
|
if (-l $dstFile) {
|
||||||
my $target = readlink $dstFile;
|
my $target = readlink $dstFile;
|
||||||
my $prevPriority = $priorities{$dstFile};
|
my $prevPriority = $priorities{$dstFile};
|
||||||
die ( "Collission between `$srcFile' and `$target'. "
|
die ( "collission between `$srcFile' and `$target'; "
|
||||||
. "Suggested solution: use `nix-env --set-flag "
|
. "use `nix-env --set-flag "
|
||||||
. "priority NUMBER PKGNAME' to change the priority of "
|
. "priority NUMBER PKGNAME' to change the priority of "
|
||||||
. "one of the conflicting packages.\n" )
|
. "one of the conflicting packages\n" )
|
||||||
if $prevPriority == $priority;
|
if $prevPriority == $priority;
|
||||||
next if $prevPriority < $priority;
|
next if $prevPriority < $priority;
|
||||||
unlink $dstFile or die;
|
unlink $dstFile or die;
|
||||||
|
@ -125,7 +125,7 @@ sub addPkg {
|
||||||
|
|
||||||
# Convert the stuff we get from the environment back into a coherent
|
# Convert the stuff we get from the environment back into a coherent
|
||||||
# data type.
|
# data type.
|
||||||
my %pkgs;
|
my @pkgs;
|
||||||
my @derivations = split ' ', $ENV{"derivations"};
|
my @derivations = split ' ', $ENV{"derivations"};
|
||||||
while (scalar @derivations) {
|
while (scalar @derivations) {
|
||||||
my $active = shift @derivations;
|
my $active = shift @derivations;
|
||||||
|
@ -133,18 +133,21 @@ while (scalar @derivations) {
|
||||||
my $outputs = shift @derivations;
|
my $outputs = shift @derivations;
|
||||||
for (my $n = 0; $n < $outputs; $n++) {
|
for (my $n = 0; $n < $outputs; $n++) {
|
||||||
my $path = shift @derivations;
|
my $path = shift @derivations;
|
||||||
$pkgs{$path} =
|
push @pkgs,
|
||||||
{ active => $active ne "false"
|
{ path => $path
|
||||||
|
, active => $active ne "false"
|
||||||
, priority => int($priority) };
|
, priority => int($priority) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Symlink to the packages that have been installed explicitly by the
|
# Symlink to the packages that have been installed explicitly by the
|
||||||
# user.
|
# user. Process in priority order to reduce unnecessary
|
||||||
foreach my $pkg (sort (keys %pkgs)) {
|
# symlink/unlink steps.
|
||||||
|
@pkgs = sort { $a->{priority} <=> $b->{priority} || $a->{path} cmp $b->{path} } @pkgs;
|
||||||
|
foreach my $pkg (@pkgs) {
|
||||||
#print $pkg, " ", $pkgs{$pkg}->{priority}, "\n";
|
#print $pkg, " ", $pkgs{$pkg}->{priority}, "\n";
|
||||||
addPkg($pkg, $pkgs{$pkg}->{priority}) if $pkgs{$pkg}->{active};
|
addPkg($pkg->{path}, $pkg->{priority}) if $pkg->{active};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue