Re: how to prevent rpmbuild from incorrectly discovering a Perl module (non)dependency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



rpm-list-bounces@xxxxxxxxxxxxx wrote on 05/13/2011 03:12:46 PM:

> On Fri, May 13, 2011 at 2:40 PM, Tim Mooney <Tim.Mooney@xxxxxxxx> wrote:
> In regard to: how to prevent rpmbuild from incorrectly discovering a
Perl...:
>

> What I have in one of my Perl programs something like:
>
> print <<EOF;
>   use Net::SNMP::AgentX qw(:types :pdus :errors :options);
> EOF
>
> So my code 'emits' a line of text that contains a 'use' statement,
> but it does not actually ever execute that 'use' statement,
> therefore _my_ package is NOT dependent on that module.
>
> Perl is incredibly challenging to parse correctly, which is why the
> dependency generator sometimes gets it wrong.
>
> The easiest thing to try would be to break your very small here-doc into
> pieces that the dependency detector won't notice.  Something like
>
>        print 'use ';
>        print 'Net::SNMP::AgentX ';
>        print 'qw(:types :pdus :errors :options);';
>        print "\n";
>
> or
>
>        print join(' ', 'use', 'Net::SNMP::AgentX',
>                'qw(:types :pdus :errors :options);'), "\n";
>
> Thanks, I didn't think of that... I'll try it.
>
> In the mean time, I added the following statement to my spec file:
>
>           Provides: perl(Net::SNMP::AgentX)
>
> I know I'm lying, but it got around my issue.
>
> As long as we're talking about the 'challenging to parse correctly issue:
>
> I also have a case like:
>
>       return "" unless (eval "use GraphViz; 1");
>
> And it _doesn't_ detect the 'use' inside of 'evals' so I have manually
> added Requires: directives for those cases.

So... instead of making your RPM lie, or editing you code, you could do
this:

%define __find_requires        %{_tmppath}/%{name}-requires.sh

%install
# Run the requirement generator, but strip out the requirements we are
ignoring.
# This is the script referenced in the __find_requires macro above.
echo "#!/bin/sh" > %{_tmppath}/%{name}-requires.sh
echo '/usr/lib/rpm/rpmdeps --requires | egrep -v "^(perl\(Net::SNMP::AgentX
\))$"' >> %{_tmppath}/%{name}-requires.sh
chmod 0700 %{_tmppath}/%{name}-requires.sh


%clean
rm -fr %{_tmppath}/%{name}-requires.sh




The egrep is there because what we used this got was actually a long list
separated by pipe characters.  Since ours was checking for libraries not
perl modules, you might have to play with the actual expression.

-greg

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list



[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux