Discussion:
Extending AutoRequires for mod_perl, etc.
Richard Siddall
2007-11-19 18:08:11 UTC
Permalink
Hello,

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.

I've found some stuff on the Fedora Project's web site on overriding the
PerlRequires mechanism to filter out unwanted results
(http://fedoraproject.org/wiki/Packaging/Perl), and assume I can
override the whole of AutoRequires similarly. Before I start
reverse-engineering how AutoRequires works, I thought I would check to
see if anyone has done this before and documented how to do it. (A
google search came up empty.)

I'm not happy with hand-maintaining as large a set of dependencies as
this application's HTML::Mason handler has.

Regards,

Richard Siddall
diego bowen
2007-11-19 19:04:54 UTC
Permalink
Using the "--nodeps" at install time allows you to bypass deependencies for perl libs that you may already have via bundled rpms....so for example:
/bin/rpm --nodeps -Uv foo.rpm

Richard Siddall <***@elirion.net> wrote:
Hello,

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.

I've found some stuff on the Fedora Project's web site on overriding the
PerlRequires mechanism to filter out unwanted results
(http://fedoraproject.org/wiki/Packaging/Perl), and assume I can
override the whole of AutoRequires similarly. Before I start
reverse-engineering how AutoRequires works, I thought I would check to
see if anyone has done this before and documented how to do it. (A
google search came up empty.)

I'm not happy with hand-maintaining as large a set of dependencies as
this application's HTML::Mason handler has.

Regards,

Richard Siddall

_______________________________________________
Rpm-list mailing list
Rpm-***@redhat.com
https://www.redhat.com/mailman/listinfo/rpm-list



---------------------------------
Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.
Richard Siddall
2008-02-28 20:18:49 UTC
Permalink
Post by Richard Siddall
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.

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?)

I hope this helps should anyone have to expand dependency checking in
the future.

Regards,

Richard Siddall
Jeff Johnson
2008-02-28 23:27:04 UTC
Permalink
Post by Richard Siddall
Post by Richard Siddall
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
%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
- 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.
Post by Richard Siddall
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

Loading...