python-rpm-spec icon indicating copy to clipboard operation
python-rpm-spec copied to clipboard

Handle %() command expansion

Open willmurnane opened this issue 1 year ago • 3 comments

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.

willmurnane avatar Jun 14 '23 12:06 willmurnane

Hey ho. Sorry for letting this unanswered for so long.

Two things

  1. 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?
  2. I like the white space changes. Do you think you can split them out into a separate PR?

bkircher avatar Sep 21 '23 17:09 bkircher

  1. 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.
  2. Do you mean the regexes matching until end of line? Sure, I can split those out.
  3. 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.

willmurnane avatar Sep 21 '23 18:09 willmurnane

  • 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!

bkircher avatar Sep 24 '23 17:09 bkircher