From a3ce51d35cab58c9c9c5edead8f5fc7109f09ccb Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 16 Sep 2017 12:04:14 +0000 Subject: we already have a comparison function for libobjects, so move it up to the best class, and sort bad libraries in dependency solving accordingly --- usr.sbin/pkg_add/OpenBSD/LibSpec.pm | 28 +++++++++++++--------------- usr.sbin/pkg_add/OpenBSD/SharedLibs.pm | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_add/OpenBSD/LibSpec.pm b/usr.sbin/pkg_add/OpenBSD/LibSpec.pm index acc9ffbbee2..9fcfcd9f57c 100644 --- a/usr.sbin/pkg_add/OpenBSD/LibSpec.pm +++ b/usr.sbin/pkg_add/OpenBSD/LibSpec.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: LibSpec.pm,v 1.17 2017/02/10 02:10:22 espie Exp $ +# $OpenBSD: LibSpec.pm,v 1.18 2017/09/16 12:04:13 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -20,7 +20,6 @@ use warnings; package OpenBSD::LibObject; - sub key { my $self = shift; @@ -81,6 +80,18 @@ sub lookup return $r; } +sub compare +{ + my ($a, $b) = @_; + if ($a->key ne $b->key) { + return $a->key cmp $b->key; + } + if ($a->major != $b->major) { + return $a->major <=> $b->major; + } + return $a->minor <=> $b->minor; +} + package OpenBSD::BadLib; our @ISA=qw(OpenBSD::LibObject); @@ -305,17 +316,4 @@ sub match return !$spec->no_match($library, $base); } -sub compare -{ - my ($a, $b) = @_; - - if ($a->key ne $b->key) { - return undef; - } - if ($a->major != $b->major) { - return $a->major <=> $b->major; - } - return $a->minor <=> $b->minor; -} - 1; diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm index 68a9189432a..71b35fbcca0 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedLibs.pm,v 1.58 2017/02/10 02:10:22 espie Exp $ +# $OpenBSD: SharedLibs.pm,v 1.59 2017/09/16 12:04:13 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -131,7 +131,7 @@ sub report_problem } elsif (!defined $approx) { $r = "| not found anywhere\n"; } else { - for my $bad (@$approx) { + for my $bad (sort {$a->compare($b)} @$approx) { my $ouch = $spec->no_match($bad, $base); $ouch //= "not reachable"; $r .= "| ".$bad->to_string." (".$bad->origin."): ". -- cgit v1.2.3