Bug 1580

Summary: Using %filter_from_provides fails in the builds
Product: Infrastructure Reporter: Göran Uddeborg <goeran>
Component: Build SystemAssignee: Xavier Lamien <lxtnow>
Status: CLOSED FIXED    
Severity: normal CC: dwmw2, kwizart, matthias
Priority: P5    
Version: NA   
Hardware: All   
OS: GNU/Linux   
namespace:
Attachments: Definition of filtering macros from redhat-rpm-config

Description Göran Uddeborg 2010-12-30 21:09:09 CET
The way to filter out unwanted requirements nowdays is to use %filter_from_requires according to https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering  When I do my regular builds and mock builds this works fine.  But when I tried to do a plague build it fails:

    error: line 28: Unknown tag: %filter_from_requires /perl(m2vmp2cut)/d
    error: query of specfile m2vmp2cut.spec failed, can't parse

In my own environment, the macro is defined in /usr/lib/rpm/redhat/macros, part of
redhat-rpm-config-9.1.0-5.fc14.noarch.

I tried to build my new m2vmp2cut package when I encountered this.
Comment 1 Nicolas Chauvet 2011-02-16 10:33:01 CET
Can you grab the function that are used in perl filtering.
We might need to backport them into el5 redhat-rpm-config until the builder got updated to el6, if not done already.

Comment 2 Nicolas Chauvet 2011-03-21 14:59:55 CET
I don't know if this could be workarounded properly on the buildsys until moved for el5 to el6 to build the srpm.

But maybe it worth a try of using such condition for the filters:
%if 0%{fedora} >= 14 
Comment 3 dwmw2@infradead.org 2011-08-30 00:21:03 CEST
Checking %{fedora} doesn't work because it's actually defined on the command line when the SRPM is being built. 

http://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering gives the correct answer:
# we don't want to either provide or require anything from _docdir, per policy
%{?filter_setup:
%filter_from_requires /perl(m2vmp2cut)/d
%filter_setup
}
Comment 4 dwmw2@infradead.org 2011-08-30 00:21:35 CEST
*** Bug 1913 has been marked as a duplicate of this bug. ***
Comment 5 Göran Uddeborg 2011-08-30 11:36:01 CEST
Created attachment 703 [details]
Definition of filtering macros from redhat-rpm-config

I see now I was asked to provide some information here.  Sorry for missing that! I don't know why I failed to reply at the time.

I attach the definitions of the macros, in case you want to backport.  The code to test for them is as in comment 3.  But if one does that, I guess one also has to use something like

%if 0%{!?filter_setup:1}
...
%endif

around the old style code in the %prep section.  That is: if the filter macros are defined, use them, if not, use the old version.
Comment 6 Göran Uddeborg 2012-03-18 23:12:54 CET
I tried to update my package to use the current perl filtering method, but my build still fails.  It gives the same error as before.  (Except that the macro is on line 92 now.)

Here is a link to the build result: http://buildsys.rpmfusion.org/build-status/job.psp?uid=12449
Comment 7 Nicolas Chauvet 2012-03-19 22:53:08 CET
Please look at c#3 , you are meant to embrace your filter with:
%{?filter_setup:
...
}

So that it won't fail when the macro isn't defined (at make srpm step which remains an el5 host).
Comment 8 Göran Uddeborg 2012-03-20 13:16:44 CET
Aha, I see.  I thought this bugzilla being resolved meant that the guard wasn't needed anymore.  But I added it, and my new build succeeded.  And the requirement was still filtered out according to the log.

Thanks for clarifying.
Comment 9 Göran Uddeborg 2012-03-20 13:17:55 CET
Closing to confirm it works for me now.
Comment 10 Nicolas Chauvet 2012-03-20 13:21:19 CET
Thx, please verify to update in F-17 also if relevant.
Comment 11 Göran Uddeborg 2012-03-20 13:28:29 CET
I wasn't planning to do that.  This is more of a cosmetic fix in the spec file, and doesn't affect the resulting package.  The F-17 package does the filtering already, only in the old-fashoned way.  So I thought fixing devel for the future would be appropriate.