openbsd-ports/infrastructure/package/check-dependencies
1999-10-26 15:37:42 +00:00

48 lines
908 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 zxqf $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;
}
}