python-rpm-spec
python-rpm-spec copied to clipboard
Handle %() command expansion
Spec files can include shell commands inline in macros, so that something like:
Release: %(echo foo)
translates to the same thing as:
Release: foo
This commit also includes changes to the way tags are defined, so that things that rpmbuild
doesn't treat as space-delimited are also not treated as space-delimited. Without this change, e.g. the Release
tag defined above is treated as Release: $(echo
which obviously doesn't evaluate correctly.
Hey ho. Sorry for letting this unanswered for so long.
Two things
- I feel a bit uneasy of adding subprocess.run to this library. I wouldn't want a parser execute stuff on my machine based on a spec file or string I pass to it. What do you think?
- I like the white space changes. Do you think you can split them out into a separate PR?
- Yeah, I can at least see the value in making a flag to turn this on or off. Rpmbuild does execute subshells, though, and to accurately mimic its behavior one must follow suit.
- Do you mean the regexes matching until end of line? Sure, I can split those out.
- This version doesn’t work in some edge cases. I should be able to push up the fixed version pretty soon, which works on the whole corpus of spec files that I have to deal with.
- Yeah, I can at least see the value in making a flag to turn this on or off. Rpmbuild does execute subshells, though, and to accurately mimic its behavior one must follow suit.
OK for me as long as the default is off.
- Do you mean the regexes matching until end of line? Sure, I can split those out.
Yes. That would be nice.
- This version doesn’t work in some edge cases. I should be able to push up the fixed version pretty soon, which works on the whole corpus of spec files that I have to deal with.
👍 Many thanks!