Re: Extending AutoRequires for mod_perl, etc.

Jeff Johnson <[email protected]> Thu, 28 Feb 2008 18:27:04 -0500
Newsgroups gmane.linux.redhat.rpm.general
Message-ID <[email protected]>
On Feb 28, 2008, at 3:18 PM, Richard Siddall wrote:

> Richard Siddall wrote:
>> I'm packaging up a Perl application that uses mod_perl and  
>> HTML::Mason and was wondering if anyone could point me at some  
>> information on extending rpm's AutoRequires as I'd like to  
>> automatically pull Perl dependencies from at least the HTML::Mason  
>> handler file.  RPM's standard AutoRequires ignores that file as it  
>> has a .pl extension.
>
> This is what I wound up doing as a first pass (sorry about the line
> wrapping):
>
> %prep
> # Override find-requires/find-provides to supplement Perl requires for
> # HTML::Mason file handler.pl
> cat << \EOF > %{name}-req
> #!/bin/sh
> tee %{_tmppath}/filelist | %{_rpmlibdir}/rpmdeps --requires | sort -u
> grep handler.pl %{_tmppath}/filelist \
> | xargs %{_rpmlibdir}/perldeps.pl --requires \
> | grep -v -E '^perl\((lib|strict|vars)\)$' \
> | sort -u
> EOF
>
> %define __find_provides %{_rpmlibdir}/rpmdeps --provides
> %define __find_requires %{_builddir}/%{name}-%{version}/%{name}-req
> %{__chmod} +x %{__find_requires}
> %define _use_internal_dependency_generator 0
>
> To summarize:
> - You have to define _use_internal_dependency_generator to 0 to turn  
> off
> the internal dependency generator.  I couldn't find any information on
> expanding the internal dependency generator.
> - I found a heated discussion between Jeff and people on the RH dev  
> list
> in which he pointed out that you shouldn't use this method for  
> filtering
> dependencies.
> - From that discussion I learned that rpmdeps gives similar results to
> the internal dependency generator, so I used that instead of the old
> find_provides and find_requires.
> - The replacement requires script saves the list of files being
> processed into a temporary file, then searches it for the HTML::Mason
> handler file (by file name, yuck) and runs that through a dependency
> checker.
> - I'm assuming that there are no significant Provides to be found in  
> the
> HTML::Mason handler file.
>

Um, there are easier means to the same goal:

If you override these macros instead of %__find_provides/ 
%__find_requires:

# Path to scripts to autogenerate perl package dependencies,
#
# Note: Used iff _use_internal_dependency_generator is non-zero. The
# helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}.
%__perl_provides        %{_rpmhome}/perl.prov
%__perl_requires        %{_rpmhome}/perl.req

then you do _NOT_ have to go through all the other issues disabling
the internal dependency generator, then re-enabling by using rpmdeps
etc etc.

> While this works well enough for now, I may go back and revisit it.   
> The
> elegant way to do it is to find the Apache conf files and parse out  
> the
> PerlModule, PerlRequires, and PerlHandler lines (possibly using
> Apache::ConfFile?).  The conf files may not be in /etc/httpd/conf.d as
> the RPM might symlink to them.  Files referenced in PerlRequires lines
> need to be run through a Perl dependency checker.  PerlHandler lines
> tell you which module-specific parser has to be run on the files
> referenced in the enclosing Directory and/or Files directive.
> PerlModule lines are simple dependencies.  (The presence of any  
> mod_perl
> directives in the Apache conf files indicates that mod_perl is  
> required,
> but that gets to be a chicken and egg situation: if you didn't know
> mod_perl was required, why would you run the conf file through a
> mod_perl dependency checker?)
>

And if all you want to do is _DISABLE_ extraction from a single file,
there is easier yet.

Dependencies are extracted from executable files. Stop the extraction
by simply doing
    chmod -x %{buildroot}/path/to/file
in %install.

Re-add the desired install permissions by adding a %attr for the path
in the %files manifest.

And if you want to _ENABLE_ extraction from a single file, then add  
the execution
bit, and subtract using %attr, the opposite of disabling.

73 de Jeff