[Rpm-maint] [rpm-software-management/rpm] spec file preprocessing on rpm level (#1472)
Michal Novotný
notifications at github.com
Wed Feb 2 09:39:22 UTC 2022
Alright, thanks, makes sense.
Ye, I could make the tags configurable to be e.g. `%{{{`, `}}}` or just `%{{`, `}}`. I can also provide an option to specify an escape char as `%` so that preproc really leaves anything `%%{{ ... }}` untouched - that should still be in the realm of regexes that I am right now using to recognize the tags (i.e. preproc invocations).
But there wouldn't be a perfect syntactic consistency with rpm cause rpm cannot e.g. process ` %{lua:print('}')}` expression whereas preproc can because it ignores everything in double or single quotes.
One other problem is that rpm is happy to leave `%<something>` unexpanded as long as `<something>` doesn't exist (i.e. it is not a name of a variable or a bash/lua substitution) and there is no error raised that the expansion isn't available. So if a changelog generating tool was perhaps too smart, it could leave `%{{` unescaped with an assumption that `{{...` won't expand to anything. Likely no tool is doing this but it's a possibility.
So if you want a perfect syntactic consistency with rpm parser rules, the only way is to do this in rpm. If you decide to do this in rpm, it would be nice if you could do this not only for lua but also for bash, e.g. `%{bash(src): ...}`. That way I could port the macros from rpkg-util (https://docs.pagure.org/rpkg-util/v3/macro_reference.html) into some rpm-macros package and current users could switch to the new rpm syntax when they feel ready. The following features that preproc implements would also be great to have in rpm but perhaps I could find some (at least partial) workarounds during the port:
1) the possibility to maintain state across macro invocations by exporting a variable (e.g. `%{bash(src): export FOO=bar }` and I would be able to read `FOO` with `bar` value in the following `%{bash(src): ... }` invocations). Possibility to share state is important because preprocessing won't be a single atomic operation and if during parsing and evaluation someone e.g. switches a git branch, part of the spec file might be rendered inconsistently with the other (I am solving this in the preproc git macros by bootstrapping state with git information that I need afterwards).
2) loading a custom (user) macros through some `rpmbuild` switch (e.g. `--load-srcmacros <path>`). `preproc` enables this and some users of rpkg-util (where preprocessing right now resides) use it so it would be nice if there was a clear and full migration path for rpkg-util users.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1472#issuecomment-1027749632
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/1472/1027749632 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20220202/40fc14d7/attachment.html>
More information about the Rpm-maint
mailing list