2004-03-15 16:23:53 +01:00
|
|
|
#! @perl@ -w
|
2003-11-19 18:27:16 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Cwd;
|
2004-04-06 13:42:28 +02:00
|
|
|
use IO::Handle;
|
|
|
|
|
|
|
|
STDOUT->autoflush(1);
|
|
|
|
|
|
|
|
my $out = $ENV{"out"};
|
|
|
|
mkdir "$out", 0755 || die "error creating $out";
|
2003-11-19 18:27:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
# For each activated package, create symlinks.
|
|
|
|
|
|
|
|
sub createLinks {
|
2004-04-06 13:42:28 +02:00
|
|
|
my $srcDir = shift;
|
|
|
|
my $dstDir = shift;
|
|
|
|
|
|
|
|
my @srcFiles = glob("$srcDir/*");
|
|
|
|
|
|
|
|
foreach my $srcFile (@srcFiles) {
|
|
|
|
my $baseName = $srcFile;
|
|
|
|
$baseName =~ s/^.*\///g; # strip directory
|
|
|
|
my $dstFile = "$dstDir/$baseName";
|
|
|
|
|
|
|
|
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
2004-09-19 17:53:37 +02:00
|
|
|
$srcFile =~ /\/nix-support$/ ||
|
2005-03-07 14:27:56 +01:00
|
|
|
$srcFile =~ /\/perllocal.pod$/ ||
|
2005-07-22 22:37:39 +02:00
|
|
|
$srcFile =~ /\/info\/dir$/ ||
|
2004-09-19 17:53:37 +02:00
|
|
|
$srcFile =~ /\/log$/)
|
2004-04-06 13:42:28 +02:00
|
|
|
{
|
2004-10-25 18:54:56 +02:00
|
|
|
# Do nothing.
|
2004-04-06 13:42:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
elsif (-d $srcFile) {
|
|
|
|
|
|
|
|
lstat $dstFile;
|
|
|
|
|
|
|
|
if (-d _) {
|
|
|
|
createLinks($srcFile, $dstFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
elsif (-l _) {
|
|
|
|
my $target = readlink $dstFile or die;
|
|
|
|
if (!-d $target) {
|
|
|
|
die "collission between directory `$srcFile' and non-directory `$target'";
|
|
|
|
}
|
|
|
|
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
|
|
|
mkdir $dstFile, 0755 ||
|
|
|
|
die "error creating directory `$dstFile': $!";
|
|
|
|
createLinks($target, $dstFile);
|
|
|
|
createLinks($srcFile, $dstFile);
|
2003-11-19 18:27:16 +01:00
|
|
|
}
|
2004-04-06 13:42:28 +02:00
|
|
|
|
|
|
|
else {
|
|
|
|
symlink($srcFile, $dstFile) ||
|
|
|
|
die "error creating link `$dstFile': $!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elsif (-l $dstFile) {
|
|
|
|
my $target = readlink $dstFile;
|
|
|
|
die "collission between `$srcFile' and `$target'";
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
# print "linking $dstFile to $srcFile\n";
|
|
|
|
symlink($srcFile, $dstFile) ||
|
|
|
|
die "error creating link `$dstFile': $!";
|
2003-11-19 18:27:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-06 13:42:28 +02:00
|
|
|
|
2003-11-19 18:27:16 +01:00
|
|
|
my %done;
|
|
|
|
|
2005-03-07 14:27:56 +01:00
|
|
|
sub addPkg;
|
2003-11-19 18:27:16 +01:00
|
|
|
sub addPkg {
|
2004-04-06 13:42:28 +02:00
|
|
|
my $pkgDir = shift;
|
2003-11-19 18:27:16 +01:00
|
|
|
|
2004-04-06 13:42:28 +02:00
|
|
|
return if (defined $done{$pkgDir});
|
|
|
|
$done{$pkgDir} = 1;
|
2003-11-19 18:27:16 +01:00
|
|
|
|
2005-03-07 14:27:56 +01:00
|
|
|
print "adding $pkgDir\n";
|
2004-04-06 13:42:28 +02:00
|
|
|
createLinks("$pkgDir", "$out");
|
2005-03-07 14:27:56 +01:00
|
|
|
|
|
|
|
my $propagatedFN = "$pkgDir/nix-support/propagated-build-inputs";
|
|
|
|
if (-e $propagatedFN) {
|
|
|
|
open PROP, "<$propagatedFN" or die;
|
|
|
|
my $propagated = <PROP>;
|
|
|
|
close PROP;
|
|
|
|
my @propagated = split ' ', $propagated;
|
|
|
|
foreach my $p (@propagated) {
|
2006-08-16 12:32:30 +02:00
|
|
|
# addPkg $p;
|
2005-03-07 14:27:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 18:27:16 +01:00
|
|
|
}
|
|
|
|
|
2004-04-06 13:42:28 +02:00
|
|
|
|
2003-11-19 18:27:16 +01:00
|
|
|
my @args = split ' ', $ENV{"derivations"};
|
|
|
|
|
|
|
|
while (scalar @args > 0) {
|
2004-04-06 13:42:28 +02:00
|
|
|
my $drvPath = shift @args;
|
|
|
|
addPkg($drvPath);
|
2003-11-19 18:27:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-06 13:42:28 +02:00
|
|
|
symlink($ENV{"manifest"}, "$out/manifest") or die "cannot create manifest";
|