Policies/Perl
From Mandriva Community Wiki
Contents |
[edit] Tools
There are several tools that may be used for generating rpm's directly from CPAN modules, such as cpan2rpm, or ovid, but none is sufficient to produce a Mandriva-compliant package out of the box. You may as well start with any other existing perl package as a template. A longstanding project would be to add a suitable backend for CPANPLUS.
[edit] Rules
[edit] Dependencies
No explicit dependency should be needed. rpm automatically adds a versioned dependency on perl-base, and scans files for additional perl module dependencies (both required and provided).
If this research fails to find some dependencies, you have to provide it explicitly:
requires: perl(Foo) provides: perl(Bar)
If this research produces wrong dependencies, you have to filter them:
%define _provides_exceptions perl(Foo) %define _requires_exceptions perl(Bar)
Considering the relatively large number of bugs, a correct dependency computing algorithm is still to be integrated. The perl module Module::ScanDeps is known to make a good job of this.
[edit] Build Dependencies
The minimum build dependencies are:
- perl(Module::Build) if using Module::Build
- perl-devel unconditionaly for native packages, and only before Mandrake 10.0 for pure perl packages if using ExtUtils::MakeMaker
In order to be independant of exact module location (either in its own package or part of a standard perl library), build dependencies on additional perl modules should be expressed on perl modules, with automatic dependency syntax:
BuildRequires: perl(Foo::Bar)
And not on the perl package itself:
BuildRequires: perl-Foo-Bar
[edit] Naming
All modules should be called perl-Foo-Bar, with Foo-Bar standing for the name of the CPAN distribution used. (These names are often, but not always, related to the main Perl module of the distribution, e.g. Foo::Bar.)
rpmlint check: perl prefix checking done, namespace checking to do.
[edit] Versioning
Perl modules use numerical version numbers, whereas rpm uses alphanumerical version numbers, causing repeated ordering troubles. For instance DateTime 0.2901 is supposed to be an earlier release than 0.31... Instead of abusing epoch for imposing correct ordering, it is recommended instead to transform the version number into a two dots version number: 0.2901 -> 0.29.01.
[edit] Sources URL
Maintainer-based sources URL, such as http://search.cpan.org/CPAN/authors/id/F/FO/FOO/%{module}-%{version}.tar.bz2, are not stable enough, as distribution maintainer may change without notice. Better use distribution-based URL: http://www.cpan.org/modules/by-module/FOO/%{module}-%{version}.tar.bz2.
Also, FTP download behind a firewall is a pain, hence the preference for HTTP URLs.
[edit] URL
All modules coming from CPAN should have the proper unversioned URL tag defined to http://search.cpan.org/dist/%{module} (except a few special cases where they have their own project site, see for example perl-DBI).
rpmlint check: to do
[edit] Man pages
Man pages should be generated from POD. Some modules define INSTALLMAN3DIR => 'none' in Makefile.PL, just delete this entry to revert to default behaviour.
rpmlint check: to do
[edit] Installation directory
Perl modules should be installed under vendor_perl hierarchy, not under default site_perl hierarchy. Just add the option INSTALLDIRSvendor= when generating the Makefile:
%{__perl} Makefile.PL INSTALLDIRS=vendor
or, if the module uses the Module::Build framework instead of ExtUtils::MakeMaker,
%{__perl} Build.PL installdirs=vendor
rpmlint check: done
[edit] Directory ownership
Perl packages should own all directories containing files that are located under the vendor_perl hierarchy top-directory. This is required by the fact that perl namespace organisation is not related to inheritance, meaning there is no warranty that package perl-Foo-Bar will depend on package perl-Foo. As a consequence, perl-Foo-Bar needs to own the Foo directory, otherwise it's installation and desinstallation is likely to leave an unowned directory Foo on the system.
The usual way to achieve this in %file section is:
%{perl_vendorlib}/Foo
or, for native packages:
%{perl_vendorarch}/Foo
%{perl_vendorarch}/auto/Foo
rpmlint check: to do
[edit] Various links
- Fedora policy : http://gsd.di.uminho.pt/jpo/perl/specfiles/

