openbsd-ports/infrastructure/build/extract-dependencies
espie 43ed8edb9c tweak the way library dependencies are resolved to speed them up.
Now, resolve-lib can take a big list of libraries with full paths,
and it can solve a big list of spec at once.
Basically, we move most of the parsing of spec paths into resolve-lib.

Since print-package-signature does build a full list of libs, let's solve
it all at once, instead of invoking a costly perl script repeatedly.

Add some caching possibilities for out-of-date. Specifically:
- store libraries for each package under the directory _PORT_LIBS_CACHE
- use the dependency cache _DEPENDS_FILE to avoid recreating dependency
chains, add a new file _DEPENDS_CACHE that will accumulate all dependencies,
and extract these with a simple script extract-dependencies.

Use echo to build libraries lists instead of ls, that's a bit simpler...

Some more clean-up will happen: it's probably simpler to parse libspecs
at once, extract the libraries needed and go fetch the corresponding libraries
just once.
2005-10-09 12:01:22 +00:00

57 lines
1.6 KiB
Perl

#! /usr/bin/perl
# $OpenBSD: extract-dependencies,v 1.1 2005/10/09 12:01:22 espie Exp $
#
# Copyright (c) 2005 Marc Espie <espie@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# Usage: extract-dependencies < 'tsort-pairs' seed
# extracts all the dependencies for seed from a list that contains more
# than that.
use strict;
use warnings;
# build dependency graph
my $dep = {};
while(<STDIN>) {
chomp;
my($a, $b) = split(/\s+/, $_);
$dep->{$a} = {} unless defined $dep->{$a};
$dep->{$a}->{$b} = 1;
}
# get the starting point
my $pkgpath = shift;
my @todo = ();
my $done = {};
# walk the graph repeatedly starting from it
push(@todo, $pkgpath);
while (my $x = shift @todo) {
next if $done->{$x};
$done->{$x} = 1;
next unless defined $dep->{$x};
push(@todo, keys %{$dep->{$x}});
}
# display all nodes, except for the seed
for my $d (keys %$done) {
next if $d eq $pkgpath;
print "$d\n";
}