[libvirt] [PATCH] rpm: fix incorrect expansion of %systemd_preun macro

Daniel P. Berrangé berrange at redhat.com
Wed Mar 21 08:49:51 UTC 2018


On Tue, Mar 20, 2018 at 01:57:16PM -0400, Laine Stump wrote:
> On 03/20/2018 01:00 PM, Daniel P. Berrangé wrote:
> > Macros in RPMs are expanded before line continuations, so when we write
> >
> >    %systemd_preun foo \
> >                   bar
> >
> > What happens is that it expands to
> >
> >    if [ $1 -eq 0 ] ; then
> >         # Package removal, not upgrade
> >         systemctl --no-reload disable --now foo \ > /dev/null 2>&1 || :
> >    fi
> >                  bar
> >
> > which is obviously complete garbage and not what we expected. It is
> > simply not safe to ever use line continuations in combination with
> > macros.
> 
> I forgot to ask this in the previous message - would it be reasonable to
> have a syntax-check rule that forbid any line in libvirt.spec.in that
> started with "<whitespace>%" and ended with \ ? (Personally I had no
> idea of this rule, and I'm sure most others didn't either).

Unfortunately it is hard to distinguish from a %macro that is accepting
arguments, vs a %macro that is just expanding to a plain variable, so
something like  grep '%.*\\' has too many false positives.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list