pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Incorrect logic in mk/pkgformat/pkg/metadata.mk



Am 02.08.2019 um 14:42 schrieb Aleksej Lebedev:
> However, if there happen to be a system library with the same name it
> does get picked up by ldd and put to +BUILD_INFO as a result.

Nice catch, and indeed difficult to find.

> I know how to fix the problem conceptually, but didn't quite figure
> out all the subtleties of writing awk code in-lined in shell executed
> from bmake.

Reality is even worse: it's AWK code, embedded in backticks, in a shell
program, preprocessed by bmake.

In most situations, pkglint can detect typical mistakes even if the code
is this deeply nested, but in this particular file, pkglint is confused
by the following construction, which is difficult for humans as well:

    case "$$i" in ${VAR:@p@${p}) continue ;;@} *);; esac

Since this appears in several places in pkgsrc, it's on my TODO list to
make pkglint properly parse this.

> I will probably try to factor out the awk code from bmake. I see that
> this was already done in some cases.

Sounds like a good plan. That code would become much clearer without
distinguishing between $$VAR and $VAR, and without the backslashes at
the end of each line, and with an empty line here and there.

When moving the AWK programs outside of bmake, I usually use the
following pattern, which works as long as the strings don't contain
backslashes or quotes:

    $awk '/condition/ { print "'"$destdir$prefix"'" $0 }'

The "'" looks a bit funny at first but serves its purpose well to pass a
shell variable into the AWK program. And if that should ever fail
because of special characters, it's still possible to pass these
variables via the environment, which I have done in mk/help/help.awk,
just as an example.

Roland


Home | Main Index | Thread Index | Old Index