[Rpm-maint] [rpm-software-management/rpm] spec file preprocessing on rpm level (#1472)
Michal Novotný
notifications at github.com
Fri Jan 28 16:41:33 UTC 2022
> Also I think {{{ }}} is not the best choice, as it conflicts with variables, something like %{{{{ to expand}}}} wouldn't work as expected.
I was able to fix this particular case in the parser so now `%{{{{ echo foo}}}}` outputs `%{foo}` as it should. But probably more testing is needed regarding possible interactions with default rpm constructs.
> If this is to be integrated into RPM, it needs to have clear semantics and escaping rules, and those rules need to be compatible with those of RPM. Code generators targeting RPM already know to escape % wherever it appears. It should also be opt-in.
I think semantics should be quite clear - everything inside `{{{ <x> }}}` is passed to bash interpreter and stdout of the executed command(s) replaces the `{{{ <x> }}}`. preproc allows you to specify libraries of functions (macros) that should be available inside `{{{ }}}` tags through `-s` param. You can pass everything that is to be find in a certain dir (so basically when user installs certain package with preproc macros - they would become immediately available to rpm). You can make a certain variable shared across all subsequent `{{{ }}}` tags by exporting it (e.g. `{{{ export FOO=bar }}}` - this can be used to maintain state between the tags)
As for escaping, that I think depends on particular spec-file context. E.g. `%` in changelog should be escaped but if we were to render some rpm code block dynamically (i.e. something to be executed like `%if`, `%else`), then `%` there shouldn't be quoted. But basically the code executed from within `{{{ }}}` needs to take care of it. I e.g. also made a (preproc) macro to render changelog from git metadata https://docs.pagure.org/rpkg-util/v3/macro_reference.html#git-changelog-v3 - and this macro does the escaping.
Something `%{lua(source):...}` is cool too though. It's a smaller syntactic change. There might be some other pros/cons of each approach (bash vs. lua and similar).
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1472#issuecomment-1024399237
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/1472/1024399237 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20220128/a0d79b79/attachment.html>
More information about the Rpm-maint
mailing list