This Perl script is intended for automatic detection of modules the given Perl
code depends on. It looks for common "use", "require" and "do" statements
and extracts module and version requirements for RPM "Requires:" clause.
Unlike earlier versions, this script uses B::Deparse (Perl compiler backend,
see "perldoc B::Deparse") to re-format Perl code. This makes dependency
extraction more accurate and simple, but this also has some tremendous
implication: all Perl code should pass "perl -c" syntax check, since the
compile stage (see "perldoc perlcompile") happens for all the code that gets
deparsed. This is a very strong requirement, but as we talk about packaging
quality, this is considered good.
Invocation
Dependencies
For old-style perl libraries and "*.ph" files, depndencies look like this:
perl(library.pl)
perl(header.ph)
And for Perl5 modules like this:
perl(Some/Module.pm)
The latter differs from the original RedHat RPM style, in which module
dependencies look like "perl(Some::Module)". The style was changed long ago,
and I don't know the exact reason why. :)
Versioning
For old-style floating point versioning, versions look like this:
0:5.005003
And for new v-string style versioning:
1:5.8.1
Please note that RPM does not understand ``decimal dot'' in versions, so
sometimes you may need to adjust the percision to fit the version in
"Provides:" clause.
Methods
The following three modes or ``methods'' are supported by this script:
strict
In this mode, "perl.req" goes straight and tries to extract all the
dependencies that happen to be in the given perl code, including
platform-specific dependencies, conditional ones, etc. This mode is useful for
debugging, but in some cases it can produce too strong/overkill requirements of
your package.
normal
This mode is recommended for default use. It tries to skip the dependencies
that are too strong by the following criteria:
file list
There's a simple file list in this script by which certain files are
ignored. E.g., it will not look in files that match */demos/* or
*/examples/* shell path.
package list
There's a list of modules to ignore in ``normal'' mode. They are mostly
OS-specific modules like "Win32::*" or "VMS::*". Modules that are used very
often (like "strict.pm") are also ignored in order not to bloat RPM database.
$^O
Here we also ignore conditional blocks with $^O variable involved (see
"perldoc perlvar"). This kind of code always does some OS-specific trickery
(well, most of the times).
Not implemented yet.
eval
Statements in "eval" blocks are also ignored, since this is known to be a
common technique to check the module availability safely.
relaxed
This mode makes "perl.req" fail-tolerant and even more relaxed:
conditional dependencies
In ``relaxed'' mode, conditional dependencies (i.e. "require" and "do"
statements enclosed in conditional block and this having indentation) are
ignored --- B::Deparse makes it easy!
fail tolerance
When "perl.req" cannot deparse the given perl code, it should usually fail.
In turn, RPM should abort the package build process. Unfortunatelly it does
not, which may result in packages with boroken dependencies. Only the latest
releases (starting with rpm-4.0.4-alt21) of ALT RPM aborts the build process
in such cases.
In ``relaxed'' mode, "perl.req" will not fail if the deparse fails. But please
note that some dependencies will be probably missed.
Since there's no default method, you have to specify the one with "--method"
command line argument. Alternatively, RPM_PERL_REQ_METHOD environement
variable can be used to set the method. ALT RPM sets this variable to ``normal''
by default.
This program is intended to be an optional/alternative part of RPM package
manager. You can redistribute it and/or modify it under the same terms as RPM
itself. As of version 4.x, RPM code base is covered with GPL and
(alternatively) LGPL licenses. Any questions regarding the licensing of RPM
should be addressed to Erik Troan <ewt@redhat.com> and Jeff Johnson <jbj@redhat.com>.