From e501be70c62f75023603f0916a88bb3ac53455a6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 26 May 2003 14:03:24 +0000 Subject: [PATCH] * Moved `nix-populate' here. svn path=/nixpkgs/trunk/; revision=61 --- build/populate-linkdirs.pl | 58 ++++++++++++++++++++++++++++++++++++++ descriptors/system.fix | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 build/populate-linkdirs.pl 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"); + } +} diff --git a/descriptors/system.fix b/descriptors/system.fix index 7ca8c8797c4..000e2aaabb5 100644 --- a/descriptors/system.fix +++ b/descriptors/system.fix @@ -14,6 +14,6 @@ Descr( , Bind("actPan", Fix("./pan-0.14.0.fix")) , Bind("actSubversion", Fix("./subversion-0.21.0.fix")) - , Bind("build", Local("../../scripts/nix-populate")) + , Bind("build", Local("../build/populate-linkdirs.pl")) ] )