From d803f986c6917c8dc232e542e7a63acca2b05410 Mon Sep 17 00:00:00 2001 From: espie Date: Sun, 8 Oct 2023 12:45:31 +0000 Subject: [PATCH] subclass system libraries so we can give better diagnostic eventually --- usr.sbin/pkg_add/OpenBSD/LibSpec.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/usr.sbin/pkg_add/OpenBSD/LibSpec.pm b/usr.sbin/pkg_add/OpenBSD/LibSpec.pm index d3f78d4fedb..7a46e7333df 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.20 2023/06/13 09:07:17 espie Exp $ +# $OpenBSD: LibSpec.pm,v 1.21 2023/10/08 12:45:31 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -19,6 +19,11 @@ use v5.36; package OpenBSD::LibObject; +sub systemlibraryclass($self) +{ + return ref($self); +} + sub key($self) { if (defined $self->{dir}) { @@ -142,6 +147,11 @@ sub find_best($repo, $stem) package OpenBSD::Library; our @ISA = qw(OpenBSD::LibObject); +sub systemlibraryclass($) +{ + "OpenBSD::Library::System"; +} + sub from_string($class, $filename) { if (my ($dir, $stem, $major, $minor) = $filename =~ m/^(.*)\/lib([^\/]+)\.so\.(\d+)\.(\d+)$/o) { @@ -160,6 +170,9 @@ sub to_string($self) sub set_origin($self, $origin) { $self->{origin} = $origin; + if ($origin eq 'system') { + bless $self, $self->systemlibraryclass; + } return $self; } @@ -187,6 +200,11 @@ sub is_better($self, $other) return 0; } +# could be used for better reporting +# is used for regression testing +package OpenBSD::Library::System; +our @ISA = qw(OpenBSD::Library); + package OpenBSD::LibSpec; our @ISA = qw(OpenBSD::LibObject); -- 2.20.1