Re: plist-check not reporting orphaned files present in a @comment

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Thu, 17 Aug 2023 08:14:03 UTC
Felix Palmen wrote on 2023/08/17 15:03:
> * Tatsuki Makino <tatsuki_makino@hotmail.com> [20230817 07:57]:
>> Switching @comment by ${ARCH} is also in print/epson-inkjet-printer-escpr2.
>> This is not a problem with check-orphans.
> 
> It is, when some file doesn't exist for all architectures, but for more
> than one of them.
> 
> You first test the port on ARCH=foo. Then you test on ARCH=bar and find
> that it builds/installs an additional tmp/something, so you prefix it
> with %%BAR%% which expands to "@comment " unless building on ARCH=bar.
> 
> Then you test on ARCH=baz which happens to build/install the same
> tmp/something. plist-check will still be happy because the file is there
> in pkg-plist (ignoring the @comment). Still, the file will be missing
> from the package.
> 
> I might try another workaround, e.g. expand to "@comment dummy/"
> instead, so the name won't match and plist-check will complain ...

epson-inkjet-printer-escpr2 is easy because it is restricted to 2 architectures, but in general it seems difficult.
How about also making a combined PLIST_SUB in Makefile?

.if ${ARCH} == foo
PLIST_SUB+=     FOO="" \
                BAR="@comment " \
                FOO_and_BAR=""
.elif ${ARCH} == bar
PLIST_SUB+=     FOO="@comment " \
                BAR="" \
                FOO_and_BAR=""
.else
PLIST_SUB+=     FOO_and_BAR="@comment "
.endif

And on pkg-plist side...

%%FOO_and_BAR%%tmp/something

There is one more thing that seems to be possible with pkg-plist.

%%FOO%%%%BAR%%tmp/something

If this means FOO && BAR,

%%FOO%%tmp/something
%%BAR%%tmp/something

this would mean FOO || BAR.
However, I do not know if it is allowed to write the same file name more than once, so it is time for an explanation by a great person :)
According to Mk/Scripts/check-stagedir.sh, it only deletes lines with @comment at the beginning of the line, so there seems to be no problem...

Regards.