From 0bcaa0f8610d110445cafde63e08275fd17e7574 Mon Sep 17 00:00:00 2001 From: sturm Date: Sun, 10 Dec 2006 17:34:41 +0000 Subject: [PATCH] reduce the amount of direct dependencies by pointing out those which are pulled in as indirect dependencies ok espie@ --- .../package/check-indirect-dependencies | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 infrastructure/package/check-indirect-dependencies diff --git a/infrastructure/package/check-indirect-dependencies b/infrastructure/package/check-indirect-dependencies new file mode 100755 index 00000000000..e6d49b9a576 --- /dev/null +++ b/infrastructure/package/check-indirect-dependencies @@ -0,0 +1,85 @@ +#!/usr/bin/perl + +# $OpenBSD: check-indirect-dependencies,v 1.1 2006/12/10 17:34:41 sturm Exp $ +# Copyright (c) 2006 Nikolay Sturm . +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD +# PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# reduce the amount of direct dependencies by pointing out those which +# are pulled in as indirect dependencies + +use strict; +use warnings; + +my $mainport; +my $make = $ENV{MAKE} || "make"; + +sub check_deps($) +{ + my $kind = shift; + my %directdeps; + my %indirectdeps; + my @dirstack; + + print "checking $kind dependencies\n"; + + open(my $dirdepends, "-|", "$make $kind-dir-depends") or + die "Cannot execute '$make $kind-dir-depends': $!\n"; + while (<$dirdepends>) { + chomp; + my ($port, $dep) = split; + $mainport = $port if not defined $mainport; + + if (not @dirstack) { + push @dirstack, $port; + push @dirstack, $dep; + } elsif ($dirstack[-1] eq $port) { + push @dirstack, $dep; + } else { + while ($dirstack[-1] ne $port) { + pop @dirstack; + } + push @dirstack, $dep; + } + + if ($port eq $mainport) { + if (exists $indirectdeps{$dep}) { + print "\nprobably unneeded dependency: $dep\n"; + print "@{$indirectdeps{$dep}}\n"; + next; + } + $directdeps{$dep} = 1; + } else { + if (exists $directdeps{$dep}) { + print "\nprobably unneeded dependency: $dep\n"; + print "@dirstack\n"; + } + $indirectdeps{$dep} = [ @dirstack ]; + } + } + close $dirdepends; +} + +for my $kind ("build", "run") { + check_deps($kind); +} +