2004-03-15 17:23:53 +02:00
|
|
|
#! @perl@ -w
|
2003-11-19 19:27:16 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Cwd;
|
2004-04-06 14:42:28 +03:00
|
|
|
use IO::Handle;
|
|
|
|
|
|
|
|
STDOUT->autoflush(1);
|
|
|
|
|
|
|
|
my $out = $ENV{"out"};
|
|
|
|
mkdir "$out", 0755 || die "error creating $out";
|
2003-11-19 19:27:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
# For each activated package, create symlinks.
|
|
|
|
|
|
|
|
sub createLinks {
|
2004-04-06 14:42:28 +03: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 18:53:37 +03:00
|
|
|
$srcFile =~ /\/nix-support$/ ||
|
2005-03-07 15:27:56 +02:00
|
|
|
$srcFile =~ /\/perllocal.pod$/ ||
|
2005-07-22 23:37:39 +03:00
|
|
|
$srcFile =~ /\/info\/dir$/ ||
|
2004-09-19 18:53:37 +03:00
|
|
|
$srcFile =~ /\/log$/)
|
2004-04-06 14:42:28 +03:00
|
|
|
{
|
2004-10-25 19:54:56 +03:00
|
|
|
# Do nothing.
|
2004-04-06 14:42:28 +03: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 19:27:16 +02:00
|
|
|
}
|
2004-04-06 14:42:28 +03: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 19:27:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-06 14:42:28 +03:00
|
|
|
|
2003-11-19 19:27:16 +02:00
|
|
|
my %done;
|
|
|
|
|
2005-03-07 15:27:56 +02:00
|
|
|
sub addPkg;
|
2003-11-19 19:27:16 +02:00
|
|
|
sub addPkg {
|
2004-04-06 14:42:28 +03:00
|
|
|
my $pkgDir = shift;
|
2003-11-19 19:27:16 +02:00
|
|
|
|
2004-04-06 14:42:28 +03:00
|
|
|
return if (defined $done{$pkgDir});
|
|
|
|
$done{$pkgDir} = 1;
|
2003-11-19 19:27:16 +02:00
|
|
|
|
2005-03-07 15:27:56 +02:00
|
|
|
print "adding $pkgDir\n";
|
2004-04-06 14:42:28 +03:00
|
|
|
createLinks("$pkgDir", "$out");
|
2005-03-07 15:27:56 +02: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) {
|
|
|
|
addPkg $p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 19:27:16 +02:00
|
|
|
}
|
|
|
|
|
2004-04-06 14:42:28 +03:00
|
|
|
|
2003-11-19 19:27:16 +02:00
|
|
|
my @args = split ' ', $ENV{"derivations"};
|
|
|
|
|
|
|
|
while (scalar @args > 0) {
|
2004-04-06 14:42:28 +03:00
|
|
|
my $drvPath = shift @args;
|
|
|
|
addPkg($drvPath);
|
2003-11-19 19:27:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-06 14:42:28 +03:00
|
|
|
symlink($ENV{"manifest"}, "$out/manifest") or die "cannot create manifest";
|