From: Marc Espie Subject: Re: pkg_create: @lib without LIBname_VERSION To: George Koehler Cc: Andrew Hewus Fresh , Stuart Henderson , ports@openbsd.org Date: Thu, 20 Nov 2025 15:16:54 +0100 This does tweak Subst.pm slightly to allow it NOT to substitute a given variable. That way, we parse the finished product, subst EVERYTHING but the variable we nee, AND ensure it matches precisely what we want. Index: OpenBSD/PkgCreate.pm =================================================================== RCS file: /vide/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 20 Nov 2025 14:15:55 -0000 @@ -771,11 +771,13 @@ sub check_version($self, $state, $unsubs { 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); + my $k = "LIB$l[0]_VERSION"; + my $r = $state->{subst}->do($unsubst, $k); + if ($r =~ m/\blib\Q$l[0]\E\.so\.\$\{$k\}$/) { + return; } + $state->error("Incorrectly versioned shared library: #1", + $unsubst); } else { $state->error("Invalid shared library #1", $unsubst); } @@ -1205,7 +1207,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); } } Index: OpenBSD/Subst.pm =================================================================== RCS file: /vide/cvs/src/usr.sbin/pkg_add/OpenBSD/Subst.pm,v diff -u -p -r1.27 Subst.pm --- OpenBSD/Subst.pm 27 May 2025 03:42:59 -0000 1.27 +++ OpenBSD/Subst.pm 20 Nov 2025 14:09:10 -0000 @@ -63,11 +63,14 @@ sub parse_option($self, $opt) } } -sub do($self, $s) +sub do($self, $s, $without = undef) { return $s unless $s =~ m/\$/o; # no need to subst if no $ while ( my $k = ($s =~ m/\$\{([A-Za-z_][^\}]*)\}/o)[0] ) { my $v = $self->{$k}; + if (defined $without && $without eq $k) { + $v = undef; + } unless ( defined $v ) { $v = "\$\\\{$k\}"; } $s =~ s/\$\{\Q$k\E\}/$v/g; }