nixpkgs/build/populate-linkdirs.pl
Eelco Dolstra 93c7c89b1a * Descriptors for Berkeley DB and SWIG.
* Updated to Apache httpd 2.0.46.
* Build Subversion/Python bindings.

svn path=/nixpkgs/trunk/; revision=76
2003-05-30 20:57:34 +00:00

59 lines
1.4 KiB
Perl
Executable file

#! /usr/bin/perl -w
use strict;
use Cwd;
my $selfdir = cwd;
my @dirs = ("bin", "sbin", "lib", "include", "man");
# Create the subdirectories.
mkdir $selfdir, 0755;
foreach my $dir (@dirs) {
mkdir "$selfdir/$dir", 0755;
}
# 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, 0755 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");
}
}