summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2017-09-16 12:04:13 +0000
committerespie <espie@openbsd.org>2017-09-16 12:04:13 +0000
commit605f450f6be4711dccf85c953afcbd8c114777a8 (patch)
treed2cec20e61a400c50103e91ed1c83515b515b8ab
parentrecognize @version, to be used for a system-wide version marker (diff)
downloadwireguard-openbsd-605f450f6be4711dccf85c953afcbd8c114777a8.tar.xz
wireguard-openbsd-605f450f6be4711dccf85c953afcbd8c114777a8.zip
we already have a comparison function for libobjects, so move it up to
the best class, and sort bad libraries in dependency solving accordingly
-rw-r--r--usr.sbin/pkg_add/OpenBSD/LibSpec.pm28
-rw-r--r--usr.sbin/pkg_add/OpenBSD/SharedLibs.pm4
2 files changed, 15 insertions, 17 deletions
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 <espie@openbsd.org>
#
@@ -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 <espie@openbsd.org>
#
@@ -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."): ".