diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-03-15 15:23:53 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-03-15 15:23:53 +0000 |
commit | beda10f5a2a69ac32ad91c8a80477fde19be6a83 (patch) | |
tree | 34fa924bcdf01683e8d6050e19ac868c1a8b84ba /corepkgs/buildenv/builder.pl.in | |
parent | a5619f1dffbf3600dd16b51e84ae3c999edc439c (diff) |
* Make perl a dependency of Nix.
Diffstat (limited to 'corepkgs/buildenv/builder.pl.in')
-rwxr-xr-x | corepkgs/buildenv/builder.pl.in | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/corepkgs/buildenv/builder.pl.in b/corepkgs/buildenv/builder.pl.in new file mode 100755 index 000000000..d9ff73e17 --- /dev/null +++ b/corepkgs/buildenv/builder.pl.in @@ -0,0 +1,72 @@ +#! @perl@ -w + +use strict; +use Cwd; + +my $selfdir = $ENV{"out"}; +mkdir "$selfdir", 0755 || die "error creating $selfdir"; + +# For each activated package, create symlinks. + +sub createLinks { + 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$/) { + } elsif (-d $srcfile) { + # !!! hack for resolving name clashes + if (!-e $dstfile) { + mkdir $dstfile, 0755 || + die "error creating directory $dstfile"; + } + -d $dstfile or die "$dstfile is not a directory"; + createLinks($srcfile, $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"; + } + } +} + +my %done; + +sub addPkg { + my $pkgdir = shift; + + return if (defined $done{$pkgdir}); + $done{$pkgdir} = 1; + +# print "merging $pkgdir\n"; + + createLinks("$pkgdir", "$selfdir"); + +# if (-f "$pkgdir/envpkgs") { +# my $envpkgs = `cat $pkgdir/envpkgs`; +# chomp $envpkgs; +# my @envpkgs = split / +/, $envpkgs; +# foreach my $envpkg (@envpkgs) { +# addPkg($envpkg); +# } +# } +} + +my @args = split ' ', $ENV{"derivations"}; + +while (scalar @args > 0) { + my $drvpath = shift @args; + print "adding $drvpath\n"; + addPkg($drvpath); +} + +symlink($ENV{"manifest"}, "$selfdir/manifest") or die "cannot create manifest"; + |