unify reporting of lib issues

This commit is contained in:
espie 2007-05-21 20:52:33 +00:00
parent 023cfd6b44
commit 3b31079021

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
# $OpenBSD: check-newlib-depends,v 1.31 2007/05/21 20:39:27 espie Exp $ # $OpenBSD: check-newlib-depends,v 1.32 2007/05/21 20:52:33 espie Exp $
# Copyright (c) 2004 Marc Espie <espie@openbsd.org> # Copyright (c) 2004 Marc Espie <espie@openbsd.org>
# #
# Permission to use, copy, modify, and distribute this software for any # Permission to use, copy, modify, and distribute this software for any
@ -119,6 +119,18 @@ sub origin
} }
} }
sub do_record_wantlib
{
my ($self, $h) = @_;
my $want = $self->{lib};
$want =~ s/\.\d+$//;
$h->{$want} = 1;
}
sub record_wantlib
{
}
package Issue::system_lib; package Issue::system_lib;
our @ISA=(qw(Issue)); our @ISA=(qw(Issue));
sub print sub print
@ -127,6 +139,10 @@ sub print
print "Missing system lib: $self->{lib} ($self->{binary})\n"; print "Missing system lib: $self->{lib} ($self->{binary})\n";
} }
sub record_wantlib
{
&Issue::do_record_wantlib;
}
package Issue::direct_dependency; package Issue::direct_dependency;
our @ISA=(qw(Issue)); our @ISA=(qw(Issue));
sub print sub print
@ -143,6 +159,11 @@ sub print
print "Missing $self->{lib}".$self->origin." ($self->{binary}) (reachable through dependencies: WANTLIB)\n"; print "Missing $self->{lib}".$self->origin." ($self->{binary}) (reachable through dependencies: WANTLIB)\n";
} }
sub record_wantlib
{
&Issue::do_record_wantlib;
}
package Issue::not_reachable; package Issue::not_reachable;
our @ISA=(qw(Issue)); our @ISA=(qw(Issue));
sub print sub print
@ -328,7 +349,7 @@ sub handle_dependency
sub report_lib_issue sub report_lib_issue
{ {
my ($plist, $lib, $binary, $r) = @_; my ($plist, $lib, $binary) = @_;
OpenBSD::SharedLibs::add_system_libs('/'); OpenBSD::SharedLibs::add_system_libs('/');
my $libspec = "$lib.0"; my $libspec = "$lib.0";
@ -337,11 +358,7 @@ sub report_lib_issue
for my $dir (qw(/usr /usr/X11R6)) { for my $dir (qw(/usr /usr/X11R6)) {
my @r = OpenBSD::SharedLibs::lookup_libspec($dir, $libspec); my @r = OpenBSD::SharedLibs::lookup_libspec($dir, $libspec);
if (grep { $_ eq 'system' } @r) { if (grep { $_ eq 'system' } @r) {
my $i = Issue::system_lib->new($lib, $binary); return Issue::system_lib->new($lib, $binary);
$i->print;
$errors++;
$r->{wantlib}->{$want} = 1;
return;
} }
} }
@ -354,10 +371,7 @@ sub report_lib_issue
if (@r > 0) { if (@r > 0) {
for my $p (@r) { for my $p (@r) {
if (defined $dependencies->{$plist->pkgname}->{$p}) { if (defined $dependencies->{$plist->pkgname}->{$p}) {
my $i = Issue::direct_dependency->new($lib, $binary, $p); return Issue::direct_dependency->new($lib, $binary, $p);
$i->print;
$errors++;
return;
} }
} }
} }
@ -376,16 +390,10 @@ sub report_lib_issue
@r = OpenBSD::SharedLibs::lookup_libspec('/usr/local', $libspec); @r = OpenBSD::SharedLibs::lookup_libspec('/usr/local', $libspec);
for my $p (@r) { for my $p (@r) {
if (defined $done->{$p}) { if (defined $done->{$p}) {
my $i = Issue::indirect_dependency->new($lib, $binary, $p); return Issue::indirect_dependency->new($lib, $binary, $p);
$i->print;
$r->{wantlib}->{$want} = 1;
$errors++;
return;
} }
} }
my $i = Issue->not_reachable($lib,, $binary, @r); return Issue->not_reachable($lib,, $binary, @r);
$i->print;
$errors++;
} }
sub print_list sub print_list
@ -423,7 +431,12 @@ sub analyze
my $fullname = $t->{needlib}->{$lib}; my $fullname = $t->{needlib}->{$lib};
$fullname = $fullname->[0] if $opt_f; $fullname = $fullname->[0] if $opt_f;
if (!defined $t->{haslib}->{$lib}) { if (!defined $t->{haslib}->{$lib}) {
report_lib_issue($plist, $lib, $fullname, $r); my $issue = report_lib_issue($plist, $lib, $fullname);
if (!$issue) {
$issue->print;
$errors++;
$issue->record_wantlib($r->{wantlib});
}
} }
$t->{haslib}->{$lib} = 2; $t->{haslib}->{$lib} = 2;
} }