I want to define a macro that will replace some placeholders in makefiles and systemd unit files with the results of RPM variables (macros). However, I don't know if the way expansion works will make the following behave correctly:
%define repl_vars() (sed -e "s:\${LIBEXECDIR}:%{_libexecdir}:g" -e "s:\${LOCALSTATEDIR}:%{_localstatedir}:g" -e "s:\${SYSCONFIGDIR}:%{_sysconfdir}:g" %{1} > %{1}.new && mv %{1}.new %{1})
Where the capitalized ${...}
are the placeholders to be replaced with the actual paths held by the standard RPM variables (macros).
Also, escaping the $
of the placeholders with \
works in Bash and stuff I put in the %install
section of the SPEC file, but is that still valid in a macro? And is the %{1}
valid, as I've never seen an example -- and if not, how do I concatenate .new
to %1
?
If this is wrong, how do I do it?