cat-in-136 / cargo-generate-rpm

Cargo helper command to generate a binary RPM package
MIT License
92 stars 19 forks source link

using RPM macro scriptlets / BuildRequires #117

Open bryanlarsen opened 4 months ago

bryanlarsen commented 4 months ago

I'm trying and failing to follow the instructions on https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#Systemd .

Here's what I have:

post_install_script_flags = 0b011 # enable macros
post_install_script = "%systemd_post foo.service"

which results in:

/var/tmp/rpm-tmp.G9cgiK: line 3: syntax error near unexpected token `&&'
/var/tmp/rpm-tmp.G9cgiK: line 3: `if  && ; then '

Perhaps the problem is that I'm missing BuildRequires: systemd-rpm-macros, but there doesn't appear to be a way to add this with cargo-generate-rpm?

korbel commented 2 months ago

You get the error because you enabled both the macro expansion and the queryformat expansion. Use only the 0b001 flag instead.

When you expand the macro (try rpm --eval '%systemd_post foo.service' in terminal to see the expanded value) you get square brackets in it which then get expanded as a queryformat.

cat-in-136 commented 2 months ago

@bryanlarsen I believe that korbel's answer resolved the issue. Could you please try it?