From: Andrew Hewus Fresh Subject: Re: pkg_create: @lib without LIBname_VERSION To: George Koehler Cc: Marc Espie , Stuart Henderson , ports@openbsd.org Date: Tue, 18 Nov 2025 22:17:49 -0800 How does that work with @lib lib/libfoo${API_VERSION}.so.${LIBfoo${API_VERSION}_VERSION} Nov 18, 2025 21:00:25 George Koehler : > On Tue, 18 Nov 2025 20:59:14 -0500 > George Koehler wrote: > >> These ports have more than one '${LIB' and the regexp is matching the >> wrong one.  I guess that we need to count braces. > > Instead of counting braces, it is simpler to loop through the > '${LIB' locations. > > Index: OpenBSD/PkgCreate.pm > =================================================================== > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm,v > diff -u -p -r1.200 PkgCreate.pm > --- OpenBSD/PkgCreate.pm    15 Sep 2025 01:59:37 -0000  1.200 > +++ OpenBSD/PkgCreate.pm    19 Nov 2025 04:49:35 -0000 > @@ -769,17 +769,21 @@ sub id($self) > package OpenBSD::PackingElement::Lib; > sub check_version($self, $state, $unsubst) > { > -   my @l  = $self->parse($self->name); > +   $state->{has_libraries} = 1; > +   my @l = $self->parse($self->name); >     if (defined $l[0]) { > -       if (!$unsubst =~ m/\$\{LIB$l[0]_VERSION\}/) { > -           $state->error( > -               "Incorrectly versioned shared library: #1", > -               $unsubst); > +       while ($unsubst =~ m/\$\{LIB(.*?)\_VERSION\}$/g) { > +           my $name = $state->{subst}->do($1); > +           if ($name eq $l[0]) { > +               return; > +           } > +           pos($unsubst) = $-[1]; >         } > +       $state->error("Incorrectly versioned shared library: #1", > +           $unsubst); >     } else { >         $state->error("Invalid shared library #1", $unsubst); >     } > -   $state->{has_libraries} = 1; > } > > package OpenBSD::PackingElement::DigitalSignature; > @@ -1205,7 +1209,7 @@ sub read_fragments($self, $state, $plist >     # XXX some things, like @comment no checksum, don't produce an object >                 my $o = &$cont($s); >                 if (defined $o) { > -                   $o->check_version($state, $s); > +                   $o->check_version($state, $l); >                     $self->annotate($o, $l, $file); >                 } >             }