Replies: 18 comments
-
A spec will no longer be a spec if such a feature was added. I can see how templating can be useful, but I think this would need to be thought of as a different file type - say, Also just noting that #1241 is related, there's an increasing amount of dynamically generated content in specs. |
Beta Was this translation helpful? Give feedback.
-
I think it's mostly matter of preference and compatibility. Additional options (except differentiating file type) that come to mind:
Having filetype separated seems quite clean to me although it depends on whether rpm would be able to process such templates/files by default and the extension would trigger preprocessing or if an extra switch would be needed (likely cumbersome). |
Beta Was this translation helpful? Give feedback.
-
I checked quickly Also I think Also, what does it bring compared to (btw, |
Beta Was this translation helpful? Give feedback.
-
I agree it's limited but so far it was enough to provide dynamically generated specs based on git metadata.
I think this case might be quite hypothetical, i.e. that you would want to work with dynamically named rpm variable? You could do
%{lua:...} scriplets are evaluated during rpm spec evaluation, here we are talking about an earlier step. If the question is why not use lua language rather than bash for evaluation code inside
It is supposed to be a generic text-preprocessing tool, hence preproc. Usage generally is |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
ack
hmm, ok
Could you explain a little bit the difference between the preproc time and the (If there was template control flow it would make sense, because then you would have delimited blocks that you would want to process first, I think). (my point about calling bash script from lua remains)
Fair enough. I was actually surprised there was no such tool in the coreutils/bash tool belt. |
Beta Was this translation helpful? Give feedback.
-
I mean this is a good question. One reason for having a preprocessing stage is existence of source rpms. Basically both lua scriplets and shell expansions are evaluated once srpm is built and then later when rpm is built from that srpm. The thing is that contexts (i.e. what information is available to the build process) is different each time. For srpm build, there are e.g. git metadata and raw source files, whereas for rpm build, there is no longer any git metadata and sources are packed in exported (e.g. by There are some other differences, e.g. that you can keep variable values across separate |
Beta Was this translation helpful? Give feedback.
-
What code generators are there currently if I may ask. |
Beta Was this translation helpful? Give feedback.
-
It doesn't look like However, if we added some srpm time expansion, that would fit your requirement, no?
Common code for generating changelog from git could be added the the lua rpm extension, so packagers could call: I just found out there is an %autochangelog now: https://fedoraproject.org/wiki/Changes/rpmautospec, did you know?! |
Beta Was this translation helpful? Give feedback.
-
Try to make spec file with e.g.:
and call
which means they are evaluated/expanded.
If
Yes, that solution solution relies on build system modifying the spec file based on some regexp parsing of the spec file (i.e. whether it contains %autochangelog) - it's not very clean. |
Beta Was this translation helpful? Give feedback.
-
Well...they are evaluated/expanded but the resulting value is not kept in the spec file that goes into srpm. I guess that's what you meant :). |
Beta Was this translation helpful? Give feedback.
-
There are several tools that automatically generate changelogs. These tools should not need to be altered for the preprocessor. |
Beta Was this translation helpful? Give feedback.
-
Also, the output of the external command needs to be escaped for RPM. |
Beta Was this translation helpful? Give feedback.
-
I was able to fix this particular case in the parser so now
I think semantics should be quite clear - everything inside As for escaping, that I think depends on particular spec-file context. E.g. Something |
Beta Was this translation helpful? Give feedback.
-
Consider a tool that generates changelogs from user-provided input. Changelogs are not executable in any way, so even if they come from untrusted sources, it should be sufficient to ensure they are properly escaped, well-formed, and only contain printable ASCII. A preprocessor like you mentioned breaks this assumption. |
Beta Was this translation helpful? Give feedback.
-
I don't really understand what assumption is broken, by what way and by which tool. Can you be more specific, please or show an example? |
Beta Was this translation helpful? Give feedback.
-
Suppose a I have the following (hypothetical) commit message:
The tool then generates the following entry in the spec file changelog
And when the preprocessor runs, the command One way to prevent this is to instead use
it would be converted into
which the preprocessor leaves untouched. The previous nasty message
is also left untouched.
would run |
Beta Was this translation helpful? Give feedback.
-
Alright, thanks, makes sense. Ye, I could make the tags configurable to be e.g. But there wouldn't be a perfect syntactic consistency with rpm cause rpm cannot e.g. process One other problem is that rpm is happy to leave 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.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
since this change https://pagure.io/fesco/issue/2532 will not likely be accepted, I would like to ask if you were willing to accept a pull request to enable spec file preprocessing directly on rpm level. It would add a third type of macro (except
%{}
and%()
), which would work similarly to%()
except that the values (after expansion) would be put verbatim into the spec file that goes into an srpm generated by rpmbuild.Basically, spec files would be always passed through
preproc
utility first before they would be handed over for further rpm processing. Enabling/disabling of this feature would be only system-wide, not spec-wide as you need to preprocess a template first before parsing it.This is a way to bring innovation to rpm ecosystem mainly by:
The only added dependency would the
preproc
utility, which I would just rewrite from python to C, it is less than 100 lines of code currently so it won't be a problem.People basically didn't like that
rpmbuild -bs
would no longer always work on a spec file within Fedora DistGit after accepting the aforementioned change. Having the preprocessor directly in rpm would solve that problem.Beta Was this translation helpful? Give feedback.
All reactions