Perl policy

Материал из Rosalab Wiki
Перейти к: навигация, поиск
This page document conventions used in packaging perl libraries in ROSA Linux. Perl applications, by contrast, are out of concerns. Unfortunately, it is sometimes difficult to decide if some piece of software is a library or an application (perltidy, for instance).


Rules

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 __noautoprov 'perl(Foo)'
%define __noautoreq '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.


Build Dependencies

The minimum build dependencies are:

  • perl(Module::Build) if using Module::Build
  • perl-devel unconditionally for native packages, and only before Mandrake 10.0 for pure perl packages if using ExtUtils::MakeMaker

In order to be independent 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


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


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...

In ROSA Linux, we normalize all perl modules version through %perl_convert_version macro:

%define upstream_name       Config-Model
%define upstream_version    0.636

Name:       perl-%{upstream_name}
Version:    %perl_convert_version %{upstream_version}
Release:    1


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.


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


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.


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


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 organization 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 deinstallation 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

Tools

The official tool to generate a rpm directly from CPAN modules is cpan2dist, with the Mandriva backend CPANPLUS-Dist-Mdv.

   # urpmi perl-CPANPLUS-Dist-Mdv 
   [... later on ...]
   $ cpan2dist --format CPANPLUS::Dist::Mdv Module::To::Transform::In::Rpm

In order not have to specify the format parameter each time, you can update the dist_type line in ~/.cpanplus/lib/CPANPLUS/Config/User.pm to read:

   $conf->set_conf( dist_type => 'CPANPLUS::Dist::Mdv' );


External links


Idea.png
Примечание
This Policy is based on the Mandriva Perl Packaging Policy.