From a9b1a60dca9549f37ceb538557a61fe3faf28ade Mon Sep 17 00:00:00 2001 From: espie Date: Tue, 28 Jun 2022 08:15:43 +0000 Subject: [PATCH] parse pkgpath further, so that we know the subpackage component, if any, and flag multiple subpackages as an error --- usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 9ed19f15fe7..39cad4e0792 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.282 2022/06/08 14:57:12 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.283 2022/06/28 08:15:43 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -2156,9 +2156,19 @@ sub new { my ($class, $fullpkgpath) = @_; my ($dir, @mandatory) = split(/\,/, $fullpkgpath); - return bless {dir => $dir, + my $o = + bless {dir => $dir, mandatory => {map {($_, 1)} @mandatory}, - }, $class; + }, $class; + my @sub = grep {/^\-/} @mandatory; + if (@sub > 1) { + print STDERR "Invalid $fullpkgpath (multiple subpackages)\n"; + exit 1; + } + if (@sub == 1) { + $o->{subpackage} = shift @sub; + } + return $o; } sub fullpkgpath -- 2.20.1