Bug 462360 - Mistaken by %if: W: configure-without-libdir-spec
Mistaken by %if: W: configure-without-libdir-spec
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: rpmlint (Show other bugs)
rawhide
All Linux
low Severity low
: ---
: ---
Assigned To: Tom "spot" Callaway
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-15 13:14 EDT by Jan Kratochvil
Modified: 2011-04-25 11:26 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-04-25 10:26:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Testcase .spec (352 bytes, text/plain)
2008-09-15 13:14 EDT, Jan Kratochvil
no flags Details

  None (edit)
Description Jan Kratochvil 2008-09-15 13:14:43 EDT
Created attachment 316763 [details]
Testcase .spec

Description of problem:
A valid configure call produces false warning:
W: configure-without-libdir-spec

Version-Release number of selected component (if applicable):
rpmlint-0.84-2.fc10.noarch

How reproducible:
Always.

Steps to Reproduce:
1. rpmlint segv.spec 
2. rpmbuild -bb segv.spec

Actual results:
W: configure-without-libdir-spec
...
+ ./configure --libdir=/
/var/tmp/rpm-tmp.1DdIT4: line 30: ./configure: No such file or directory

Expected results:
(no warning)
...
+ ./configure --libdir=/
/var/tmp/rpm-tmp.1DdIT4: line 30: ./configure: No such file or directory

Additional info:
The relevant block:
./configure \
%if 1
%endif
        --libdir=/
Comment 1 Bug Zapper 2008-11-25 22:05:35 EST
This bug appears to have been reported against 'rawhide' during the Fedora 10 development cycle.
Changing version to '10'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 2 Bug Zapper 2009-11-18 07:38:35 EST
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Bug Zapper 2010-03-15 08:05:41 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 13 development cycle.
Changing version to '13'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 4 Fedora Admin XMLRPC Client 2010-12-07 16:19:15 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 5 Tom "spot" Callaway 2011-04-24 21:00:55 EDT
So, I inherited this bug, but basically, the problem is this:

The %{_libdir} argument to configure is below a conditionalized %if statement. While we could expand away all forced true (%if 1) or forced false (%if 0) macros and check for it to be defined there in the larger evaluated string, in the real world, this is incredibly unlikely. Far more likely is something like this:

%if %{foo}
--libdir=/bar
%endif

Since we're running this against a spec, we have no way of sanely evaluating %{foo} (as it could be different when the srpm is generated). Hence, we have no way of sanely evaluating a common conditional (as opposed to a forced true or forced false one) here to expand out the configure statement properly and be sure that this check is absolutely correct.

In conclusion, yes, this call causes a false warning, but a packager should be smart enough to know it is a false warning, and resolving conditionals in the spec before checking the validity of a configure call is not practical/possible.

Closing as WONTFIX.

(Please note: if you still think that forced true/forced false conditionals should be evaluated before checking the string, I would encourage you to send a patch to the rpmlint upstream.)
Comment 6 Jan Kratochvil 2011-04-25 03:54:20 EDT
It is not about %if 0 and %if 1, it happens for valid real world conditionals:

./configure \
%if 0%{?_with_foo:1}
        --foo \
%endif
        --libdir=/

rpmlint-1.1-3.fc16.noarch
segv.spec:15: W: configure-without-libdir-spec

rpmbuild -bb --without foo segv.spec
+ ./configure --libdir=/
rpmbuild -bb --with foo segv.spec
+ ./configure --foo --libdir=/

It is about some wrong evaluation of end-of-line lexical syntax.
Comment 7 Tom "spot" Callaway 2011-04-25 10:26:42 EDT
What if the --libdir option is in the conditional? How should we evaluate that _from the spec_ ?

The problem is that right now the behavior is consistent, conditionals are not evaluated when calculating the ./configure invocation. If we can't evaluate all conditionals (which we can't), I posit that there is no reason to evaluate some and create a confusing middle-of-the-road behavior.
Comment 8 Jan Kratochvil 2011-04-25 10:37:42 EDT
(In reply to comment #7)
> What if the --libdir option is in the conditional? How should we evaluate that
> _from the spec_ ?

You should evaluate recursively all the cases.


> The problem is that right now the behavior is consistent, conditionals are not
> evaluated when calculating the ./configure invocation.

You could either evaluate %if-true code path or %if-false code path.  Currently rpmlint evaluates neither of it, it just aborts parsing the line.


> If we can't evaluate all
> conditionals (which we can't), I posit that there is no reason to evaluate some
> and create a confusing middle-of-the-road behavior.

Another possibility is to give:
W: Line contains %if content, skipping evaluation.
Comment 9 Tom "spot" Callaway 2011-04-25 10:51:29 EDT
(In reply to comment #8)
> (In reply to comment #7)
> > What if the --libdir option is in the conditional? How should we evaluate that
> > _from the spec_ ?
> 
> You should evaluate recursively all the cases.

Please, show me how to evaluate recursively all of the cases for:

%if %{foo} >= %{bar}

> > The problem is that right now the behavior is consistent, conditionals are not
> > evaluated when calculating the ./configure invocation.
> 
> You could either evaluate %if-true code path or %if-false code path.  Currently
> rpmlint evaluates neither of it, it just aborts parsing the line.

No, rpmlint says it doesn't find a --libdir, which it doesn't, because it makes no attempt to go deeper in the spec.

The way this check works is stupidly simple. It looks for this string "./configure" and then looks for this string on the same line "--libdir". The code would gets disgustingly more complex if we were to attempt to parse past that point, but when it triggers in a case like what you've illustrated, it is simple for you (the human) to look at your spec, say "no, that is a false positive" and move on.

We can argue about this all day long, but I have no plans to implement any sort of Fedora specific changes to this check. If you want to submit a patch to upstream, then I will inherit it when they merge it.
Comment 10 Jan Kratochvil 2011-04-25 10:59:22 EDT
(In reply to comment #9)
> Please, show me how to evaluate recursively all of the cases for:
> 
> %if %{foo} >= %{bar}

%if %{foo} >= %{bar}
a
%if %{x} == %{y}
b
%endif
%endif

will be evaluated as four files:
-nothing-
b
a
a \n b


> We can argue about this all day long, but I have no plans to implement any sort
> of Fedora specific changes to this check. If you want to submit a patch to
> upstream, then I will inherit it when they merge it.

OK, I probably won't find time for it either.
Comment 11 Tom "spot" Callaway 2011-04-25 11:19:52 EDT
(In reply to comment #10)
> (In reply to comment #9)
> > Please, show me how to evaluate recursively all of the cases for:
> > 
> > %if %{foo} >= %{bar}
> 
> %if %{foo} >= %{bar}
> a
> %if %{x} == %{y}
> b
> %endif
> %endif
> 
> will be evaluated as four files:
> -nothing-
> b
> a
> a \n b

And if --libdir is set in one case, but not the other?
Comment 12 Jan Kratochvil 2011-04-25 11:26:35 EDT
(In reply to comment #11)
> And if --libdir is set in one case, but not the other?

Then it should print a warning.  In my sample code --libdir was set in all the cases.

Note You need to log in before you can comment on or make changes to this bug.