Re: Heads-up: %define vs %global in specs

2010-01-08 Thread Toshio Kuratomi
On Thu, Jan 07, 2010 at 11:54:14AM +0200, Panu Matilainen wrote:
> On Tue, 5 Jan 2010, Panu Matilainen wrote:
> 
> >
> >For the impatient:
> >
> >Starting with today's rawhide, the these kind of constructs in
> >specs no longer "work":
> > %{?!foo: %define foo bar}
> >For the generally desired effect, the above simply becomes:
> > %{?!foo: %global foo bar}
> >
> >This is already recommended by the Fedora guidelines, but packages
> >which haven't been updated to follow the guideline might need
> >revising:
> >https://fedoraproject.org/wiki/Packaging/Guidelines#.25global_preferred_over_.25define
> 
> FYI, this change broke font package macros.
> 
> I've reverted the macro scoping "fix" until I have a chance to
> properly investigate the breakage (possibly some quirk related to
> %{lua: ...} macros).
> 
I've updated the %global preferred over %define section to say that the bug
is fixed in F13 so people should definitely avoid %{?!foo: %define [..]}
type constructs.  If this doesn't make it back in in time for F13, let me
know and I'll update for when we do fix it.

-Toshio


pgpQ0BB97yeJS.pgp
Description: PGP signature
-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list

Re: Heads-up: %define vs %global in specs

2010-01-07 Thread Panu Matilainen

On Tue, 5 Jan 2010, Panu Matilainen wrote:



For the impatient:

Starting with today's rawhide, the these kind of constructs in specs no 
longer "work":

%{?!foo: %define foo bar}
For the generally desired effect, the above simply becomes:
%{?!foo: %global foo bar}

This is already recommended by the Fedora guidelines, but packages which 
haven't been updated to follow the guideline might need revising:

https://fedoraproject.org/wiki/Packaging/Guidelines#.25global_preferred_over_.25define


FYI, this change broke font package macros.

I've reverted the macro scoping "fix" until I have a chance to properly 
investigate the breakage (possibly some quirk related to %{lua: ...} 
macros).


- Panu -

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Heads-up: %define vs %global in specs

2010-01-05 Thread Ville Skyttä
On Tuesday 05 January 2010, Tom "spot" Callaway wrote:
> On 01/05/2010 11:50 AM, Daniel P. Berrange wrote:
> > What exactly do you mean 'no longer work' ? Can we expect to get a formal
> > RPM build error for this bogus construct, or will it silently build and
> > do the wrong thing ? From your long description, it sounds like the
> > latter, which means maintainers should audit their spec files to identify
> > these bogus macros
> 
> The easy way to be sure you're not hitting this is to not use %define.
> Sed will fix your packages up quickly. ;)

Smiley noted, but blindly doing that has potential to break stuff too.  Here's
one example that works as intended with %define but not with %global:

http://cvs.fedoraproject.org/viewvc/devel/bash-completion/bash-completion.spec?r1=1.46&r2=1.47

-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Heads-up: %define vs %global in specs

2010-01-05 Thread Panu Matilainen

On Tue, 5 Jan 2010, Daniel P. Berrange wrote:


On Tue, Jan 05, 2010 at 06:34:12PM +0200, Panu Matilainen wrote:


For the impatient:

Starting with today's rawhide, the these kind of constructs in specs
no longer "work":
%{?!foo: %define foo bar}
For the generally desired effect, the above simply becomes:
%{?!foo: %global foo bar}

This is already recommended by the Fedora guidelines, but packages which
haven't been updated to follow the guideline might need revising:
https://fedoraproject.org/wiki/Packaging/Guidelines#.25global_preferred_over_.25define



What exactly do you mean 'no longer work' ? Can we expect to get a formal
RPM build error for this bogus construct, or will it silently build and
do the wrong thing ? From your long description, it sounds like the latter,
which means maintainers should audit their spec files to identify these
bogus macros


It depends on the details but most likely you'll get a build error of some 
kind as you'll get unexpanded macros where you previously got expanded 
macros (if you were lucky). For example


%{!?python_sitelib: %define python_sitelib %(python -c "from distutils.sysconfig 
import get_python_lib; print get_python_lib()")}
...

%files
%{python_sitelib}/mystuff.py

...would now error out at filelist processing stage as %{python_sitelib} 
is not defined in the global scope and literal 
"%{python_sitelib}/mystuff.py" is not a valid file name.


Or you can get downright parse errors etc. Sure there *are* cases where it 
could go unnoticed: if you're creating package content based on such a 
%define - using the python_sitelib again as a dumb example, rpm wouldn't 
complain about file created (and packaged) from this, you'd just get wrong 
contents (unexpanded macro name) in the file:


cat << EOF >> my.conf
%{python_sitelib}/mylib/
EOF

...but the potential for such silent errors has been there all the 
time: you just need to call a parametrized macro (knowingly or as a 
side-effect) somewhere in the spec and poof.


Oh and btw, technically there's nothing illegal or wrong with the 
construct "%{?!foo: %define foo bar}" itself. What's wrong is trying to 
*use* macro defined that way outside the %{} block where it was defined.


- Panu -

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Heads-up: %define vs %global in specs

2010-01-05 Thread Tom "spot" Callaway
On 01/05/2010 11:50 AM, Daniel P. Berrange wrote:
> What exactly do you mean 'no longer work' ? Can we expect to get a formal
> RPM build error for this bogus construct, or will it silently build and
> do the wrong thing ? From your long description, it sounds like the latter,
> which means maintainers should audit their spec files to identify these 
> bogus macros

The easy way to be sure you're not hitting this is to not use %define.
Sed will fix your packages up quickly. ;)

~spot

-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Heads-up: %define vs %global in specs

2010-01-05 Thread Daniel P. Berrange
On Tue, Jan 05, 2010 at 06:34:12PM +0200, Panu Matilainen wrote:
> 
> For the impatient:
> 
> Starting with today's rawhide, the these kind of constructs in specs 
> no longer "work":
>   %{?!foo: %define foo bar}
> For the generally desired effect, the above simply becomes:
>   %{?!foo: %global foo bar}
> 
> This is already recommended by the Fedora guidelines, but packages which 
> haven't been updated to follow the guideline might need revising:
> https://fedoraproject.org/wiki/Packaging/Guidelines#.25global_preferred_over_.25define


What exactly do you mean 'no longer work' ? Can we expect to get a formal
RPM build error for this bogus construct, or will it silently build and
do the wrong thing ? From your long description, it sounds like the latter,
which means maintainers should audit their spec files to identify these 
bogus macros

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Heads-up: %define vs %global in specs

2010-01-05 Thread Panu Matilainen


For the impatient:

Starting with today's rawhide, the these kind of constructs in specs 
no longer "work":

%{?!foo: %define foo bar}
For the generally desired effect, the above simply becomes:
%{?!foo: %global foo bar}

This is already recommended by the Fedora guidelines, but packages which 
haven't been updated to follow the guideline might need revising:

https://fedoraproject.org/wiki/Packaging/Guidelines#.25global_preferred_over_.25define

The longer version:

As explained in the guidelines, %define nested in %{ } block was never 
supposed to work, but due to a longstanding bug in rpm macro engine it has 
seemed to work in many cases... until you do something completely 
unrelated in the spec and it suddenly breaks in mysterious ways. Consider 
this example spec:


--- snip ---
%{!?foo: %define foo bar}
%define dofoo() true

Name: macroscope
Version:  1.0
Release:  1
License:  Testing
Summary:  Testing macro behavior

%description
%{summary}

%prep
echo 1: %{foo}

%dofoo

echo 2: %{foo}

%files
%defattr(-,root,root)
--- snip ---

You'd probably expect %{foo} to expand to "bar" in both 1 and 2, but due 
to this funny little macro buglet, you'd get this rather non-obvious 
result:

1: bar
2: %{foo}

What you start getting now is:
1: %{foo}
2: %{foo}

...in other words, the %define inside %{} block goes out of scope when the 
block ends, and you probably wanted to use %global there instead.


- Panu -

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list