openbsd-ports/infrastructure/package/check-dependencies
1999-05-18 16:39:02 +00:00

48 lines
907 B
Perl
Executable File

#!/usr/bin/perl
$cache=1;
print "Dependency list\n";
print "---------------\n";
for $file (<*.tgz>)
{
$name = $file;
$name =~ s/\.tgz$//;
unless ($cache && -f "t/CONTENTS.$name")
{
system("tar zxf $file +CONTENTS");
rename("+CONTENTS", "t/CONTENTS.$name");
}
open(FILE, "t/CONTENTS.$name") or die "No contents";
$deps{$name}=[];
while (<FILE>)
{
chomp;
if (m/^\@pkgdep\s+/)
{
push(@{$deps{$name}}, $');
}
}
close(FILE);
print $name, ": ", join(',', @{$deps{$name}}), "\n";
}
print "Checking topological order\n";
print "--------------------------\n";
# check recursive brokeness
while (($key, $value) = each %deps)
{
%pulled=();
for $np (@$value)
{
for $rec (@{$deps{$np}})
{
unless (defined $pulled{$rec})
{
print "Error: $key depends on $np which depends on $rec\n";
print "(", join(",", @$value), ")\n";
}
}
$pulled{$np} = 1;
}
}