diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2003-05-26 14:03:24 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2003-05-26 14:03:24 +0000 |
commit | e501be70c62f75023603f0916a88bb3ac53455a6 (patch) | |
tree | e2ee23f3024c3a64cb111da4e8dd791f0e3a6dee /build/populate-linkdirs.pl | |
parent | 4066121043d721a1672bbe441699deedf2015328 (diff) |
* Moved `nix-populate' here.
svn path=/nixpkgs/trunk/; revision=61
Diffstat (limited to '')
-rwxr-xr-x | build/populate-linkdirs.pl | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/build/populate-linkdirs.pl b/build/populate-linkdirs.pl new file mode 100755 index 00000000000..d375caa7d3d --- /dev/null +++ b/build/populate-linkdirs.pl @@ -0,0 +1,58 @@ +#! /usr/bin/perl -w + +use strict; +use Cwd; + +my $selfdir = cwd; + +my @dirs = ("bin", "sbin", "lib", "include"); + +# Create the subdirectories. +mkdir $selfdir; +foreach my $dir (@dirs) { + mkdir "$selfdir/$dir"; +} + +# 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 (-d $srcfile) { + # !!! hack for resolving name clashes + if (!-e $dstfile) { + mkdir($dstfile) or + 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) or + die "error creating link $dstfile"; + } + } +} + +foreach my $name (keys %ENV) { + + next unless ($name =~ /^act.*$/); + + my $pkgdir = $ENV{$name}; + + print "merging $pkgdir\n"; + + foreach my $dir (@dirs) { + createLinks("$pkgdir/$dir", "$selfdir/$dir"); + } +} |