2003-05-26 16:03:24 +02:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Cwd;
|
|
|
|
|
2003-06-18 19:17:33 +02:00
|
|
|
my $selfdir = $ENV{"out"};
|
|
|
|
mkdir "$selfdir", 0755 || die "error creating $selfdir";
|
2003-05-26 16:03:24 +02:00
|
|
|
|
|
|
|
# For each activated package, create symlinks.
|
|
|
|
|
|
|
|
sub createLinks {
|
|
|
|
my $srcdir = shift;
|
|
|
|
my $dstdir = shift;
|
|
|
|
|
|
|
|
my @srcfiles = glob("$srcdir/*");
|
|
|
|
|
|
|
|
foreach my $srcfile (@srcfiles) {
|
2003-05-30 13:49:43 +02:00
|
|
|
my $basename = $srcfile;
|
|
|
|
$basename =~ s/^.*\///g; # strip directory
|
|
|
|
my $dstfile = "$dstdir/$basename";
|
2003-07-12 21:18:49 +02:00
|
|
|
if ($srcfile =~ /\/envpkgs$/) {
|
|
|
|
} elsif (-d $srcfile) {
|
2003-05-30 13:49:43 +02:00
|
|
|
# !!! hack for resolving name clashes
|
|
|
|
if (!-e $dstfile) {
|
2003-06-18 19:17:33 +02:00
|
|
|
mkdir $dstfile, 0755 ||
|
2003-05-30 13:49:43 +02:00
|
|
|
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 {
|
2003-07-11 23:08:53 +02:00
|
|
|
# print "linking $dstfile to $srcfile\n";
|
2003-06-18 19:17:33 +02:00
|
|
|
symlink($srcfile, $dstfile) ||
|
2003-05-30 13:49:43 +02:00
|
|
|
die "error creating link $dstfile";
|
|
|
|
}
|
2003-05-26 16:03:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-12 21:18:49 +02:00
|
|
|
my %done;
|
2003-05-26 16:03:24 +02:00
|
|
|
|
2003-07-12 21:18:49 +02:00
|
|
|
sub addPkg {
|
|
|
|
my $pkgdir = shift;
|
2003-05-26 16:03:24 +02:00
|
|
|
|
2003-07-12 21:18:49 +02:00
|
|
|
return if (defined $done{$pkgdir});
|
|
|
|
$done{$pkgdir} = 1;
|
2003-05-26 16:03:24 +02:00
|
|
|
|
|
|
|
print "merging $pkgdir\n";
|
|
|
|
|
2003-06-03 15:03:06 +02:00
|
|
|
createLinks("$pkgdir", "$selfdir");
|
2003-07-12 21:18:49 +02:00
|
|
|
|
|
|
|
if (-f "$pkgdir/envpkgs") {
|
|
|
|
my $envpkgs = `cat $pkgdir/envpkgs`;
|
|
|
|
chomp $envpkgs;
|
|
|
|
my @envpkgs = split / +/, $envpkgs;
|
|
|
|
foreach my $envpkg (@envpkgs) {
|
|
|
|
addPkg($envpkg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach my $name (keys %ENV) {
|
|
|
|
|
|
|
|
next unless ($name =~ /^act.*$/);
|
|
|
|
|
|
|
|
my $pkgdir = $ENV{$name};
|
|
|
|
|
|
|
|
addPkg($pkgdir);
|
2003-05-26 16:03:24 +02:00
|
|
|
}
|