From Fedora Project Wiki

m (Add page title, move perl sig section down to the bottom.)
m (The license tag guidelines might have been new a decade ago....)
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Fedora Packaging Guidelines for Perl}}
{{DISPLAYTITLE:Fedora Packaging Guidelines for Perl}}
<div style="float: right;" class="toclimit-2">__TOC__</div>
<div style="float: right; margin-left: 0.5em" class="toclimit-2">__TOC__</div>


== License tag ==
== License tag ==


Perl itself is dual licensed, under both the GPL and Artistic licenses.  Many perl modules follow this practice; when they do, the license tag should be filled out as "GPL+ or Artistic", not the other way around.
Perl itself is dual licensed, under both the GPL and Artistic licenses.  Many Perl modules follow this practice; when they do, the license tag should be filled out as "GPL+ or Artistic", not the other way around.


Note also that under the new [[Licensing| license tag guidelines]], it's important to specify "GPL+" not just "GPL" for those packages "licensed under the same terms as perl itself."
Note also that under the [[Licensing|license tag guidelines]], it's important to specify "GPL+" not just "GPL" for those packages "licensed under the same terms as Perl itself."


<pre>
<pre>
License: GPL+ or Artistic
License: GPL+ or Artistic
</pre>
</pre>


== Directory Ownership ==
== Directory Ownership ==


As specified in the [[Packaging:Guidelines#File_and_Directory_Ownership | general Packaging Guidelines]], perl packages are expected to share ownership of certain directories.
As specified in the [[Packaging:Guidelines#File_and_Directory_Ownership | general Packaging Guidelines]], Perl packages are expected to share ownership of certain directories.


In general, a noarch Perl package must own:
In general, a noarch Perl package must own:
Line 33: Line 33:
== Build Dependencies ==
== Build Dependencies ==


As stated in [[Packaging:Guidelines#BuildRequires_2]], a package must explicitly indicate its build dependencies (using <code>BuildRequires:</code>).  This includes any dependency on Perl.  While Perl may have been in the default buildroot at one time, this is not guaranteed.
As stated in [[Packaging:Guidelines#BuildRequires_2]], a package must explicitly indicate its build dependencies (using <code>BuildRequires:</code>) outside of the minimal set required for RPM to build packages.  This includes any dependency on Perl.  While Perl may have been in the default buildroot at one time, this is not currently the case.


Below is a list of Perl-related build dependencies you may need.
Below is a list of Perl-related build dependencies you may need.


* perl-generators – Automatically generates run-time Requires and Provides for installed Perl files. Whenever you install a Perl script or a Perl module, you must include a build dependency on this package.
* <code>perl-generators</code> – Automatically generates run-time Requires and Provides for installed Perl files. Whenever you install a Perl script or a Perl module, you must include a build dependency on this package.


* perl – The Perl interpreter must be listed as a build dependency if it is called in any way, either explicitly via <code>perl</code> or <code>%__perl</code>, or as part of your package's build system.
* <code>perl</code> – The Perl interpreter must be listed as a build dependency if it is called in any way, either explicitly via <code>perl</code> or <code>%__perl</code>, or as part of your package's build system.


* perl-devel - Provides Perl header files. If building architecture-specific code which links to libperl.so library (e.g. an XS Perl module), you must include <code>BuildRequires: perl-devel</code>.
* <code>perl-devel</code> - Provides Perl header files. If building architecture-specific code which links to <code>libperl.so</code> library (e.g. an XS Perl module), you must include <code>BuildRequires: perl-devel</code>.


If a specific Perl module is required at build time, use <code>perl(''MODULE'')</code> syntax as documented above. This applies to so called ''core'' modules as well, since they may move in and out of the base Perl package over time.
If a specific Perl module is required at build time, use <code>perl(''MODULE'')</code> syntax as documented above. This applies to so called ''core'' modules as well, since they may move in and out of the base Perl package over time.
Line 49: Line 49:
== Perl Requires and Provides ==
== Perl Requires and Provides ==


Perl packages use the virtual <code>perl(Foo)</code> naming to indicate a given perl module.  Packages should use this methodology, and not require the package name directly.  For example, a package requiring the perl module Readonly should not explicitly require <code>perl-Readonly</code>, but rather <code>perl(Readonly)</code>, which the <code>perl-Readonly</code> package provides.
Perl packages use the virtual <code>perl(Foo)</code> naming to indicate a given Perl module.  Packages should use this methodology, and not require the package name directly.  For example, a package requiring the Perl module Readonly should not explicitly require <code>perl-Readonly</code>, but rather <code>perl(Readonly)</code>, which the <code>perl-Readonly</code> package provides.


It is recommended to include explicit dependencies for core modules, because they can move between sub-packages or disappear from core perl.
It is recommended to include explicit dependencies for core modules, because they can move between sub-packages or disappear from core Perl.


=== Versioned MODULE_COMPAT_ Requires ===
=== Versioned MODULE_COMPAT_ Requires ===


All perl modules must include the versioned MODULE_COMPAT Requires:
All Perl modules must include the versioned MODULE_COMPAT Requires:


<pre>
<pre>
Line 61: Line 61:
</pre>
</pre>


This is to ensure that perl packages have a dependency on the particular version of Perl it was built against, or on a newer version of Perl that provides backward compatibility with it.
This is to ensure that Perl packages have a dependency on the particular version of Perl it was built against, or on a newer version of Perl that provides backward compatibility with it.


For example, perl-5.8.8 provided not only perl(:MODULE_COMPAT_5.8.8), but also perl(:MODULE_COMPAT_5.8.7), etc., because backward compatibility was guaranteed for Fedora Perl 5.8.x.
For example, <code>perl-5.8.8</code> provided not only <code>perl(:MODULE_COMPAT_5.8.8)</code>, but also <code>perl(:MODULE_COMPAT_5.8.7)</code>, etc., because backward compatibility was guaranteed for Fedora Perl 5.8.x.


On the other hand, perl-5.10.1 implements some incompatible changes to module tree layout and libperl.so build options.  Once the compatibility aids are removed, perl-5.10.1 and above will no longer provide perl(:MODULE_COMPAT_5.10.0).
On the other hand, <code>perl-5.10.1</code> implements some incompatible changes to module tree layout and <code>libperl.so</code> build options.  Once the compatibility aids are removed, <code>perl-5.10.1</code> and above will no longer provide <code>perl(:MODULE_COMPAT_5.10.0)</code>.


In the future, it is possible that perl-5.12.2 will provide not only perl(:MODULE_COMPAT_5.12.[012]), but also perl(:MODULE_COMPAT_5.10.[123]), if the backward compatibility with all versions >= 5.10.1 is maintained.
In the future, it is possible that <code>perl-5.12.2</code> will provide not only <code>perl(:MODULE_COMPAT_5.12.[012])</code>, but also <code>perl(:MODULE_COMPAT_5.10.[123])</code>, if the backward compatibility with all versions >= 5.10.1 is maintained.


==== Packages that link to libperl ====
==== Packages that link to <code>libperl</code> ====
Some packages link to libperl.so, usually to provide embedded perl functionality. All of these packages must also use the versioned MODULE_COMPAT Requires, because the automaticaly generated dependency on libperl.so does not include any interface version number.
Some packages link to <code>libperl.so</code>, usually to provide embedded Perl functionality. All of these packages must also use the versioned <code>MODULE_COMPAT</code> dependency, because the automatically generated dependency on <code>libperl.so</code> does not include any interface version number.


=== Filtering Requires and Provides ===
=== Filtering Requires and Provides ===
Line 87: Line 87:
use base 'Class::Accessor';</pre>
use base 'Class::Accessor';</pre>
A tell-tale sign of this particular construct is that the package contains a dependency on <code>perl(base)</code>, but this is not the only situation in which dependencies can be missed. This package needed additional dependencies as follows:
A tell-tale sign of this particular construct is that the package contains a dependency on <code>perl(base)</code>, but this is not the only situation in which dependencies can be missed. This package needed additional dependencies as follows:
<pre>
<pre>
Requires: perl(Class::Accessor), perl(Class::Accessor::Fast)</pre>
Requires: perl(Class::Accessor), perl(Class::Accessor::Fast)
</pre>
 
In general, it's a good idea to look at the upstream package's documentation for details of other dependencies.
In general, it's a good idea to look at the upstream package's documentation for details of other dependencies.


Another similar example of missing requirements can be seen in <code>perl-Spreadsheet-WriteExcel</code>:
Another similar example of missing requirements can be seen in <code>perl-Spreadsheet-WriteExcel</code>:
<pre>
<pre>
package Spreadsheet::WriteExcel::Utility;
package Spreadsheet::WriteExcel::Utility;
Line 100: Line 104:


Similarly, it possible to miss Provides:, as was the case in [http://bugzilla.redhat.com/167797 Bug #167797] , where the <code>perl-DBD-Pg</code> package failed to Provide: <code>perl(DBD::Pg)</code> due to the following construct in <code>DBD::Pg</code> version 1.43:
Similarly, it possible to miss Provides:, as was the case in [http://bugzilla.redhat.com/167797 Bug #167797] , where the <code>perl-DBD-Pg</code> package failed to Provide: <code>perl(DBD::Pg)</code> due to the following construct in <code>DBD::Pg</code> version 1.43:
<pre>
<pre>
{ package DBD::Pg;
{ package DBD::Pg;
</pre>
</pre>
The usual way of writing this, and what's expected by RPM, is:
The usual way of writing this, and what's expected by RPM, is:
<pre>
<pre>
{
{
Line 114: Line 121:
== URL tag ==
== URL tag ==


For CPAN-based packages the URL tag should use a non-versioned search.cpan.org URL.  E.g., if one were packaging the module Net::XMPP, the URL would be:
For CPAN-based packages the URL tag should use a non-versioned search.cpan.org URL.  E.g., if one were packaging the module <code>Net::XMPP</code>, the URL would be:


<pre>
<pre>
URL:           http://search.cpan.org/dist/Net-XMPP/
URL: http://search.cpan.org/dist/Net-XMPP/
</pre>
</pre>


Line 134: Line 141:
* Optional tests do not need to be enabled if they will cause circular build deps
* Optional tests do not need to be enabled if they will cause circular build deps
* Tests which require network or display access should be disabled for the buildsystem, but with a method provided for local builds
* Tests which require network or display access should be disabled for the buildsystem, but with a method provided for local builds
* Tests which do not test package functionality should still be invoked, but their exclusion not be considered a blocker (e.g. Test::Pod::Coverage, Test::Kwalitee and the like)
* Tests which do not test package functionality should still be invoked, but their exclusion not be considered a blocker (e.g. <code>Test::Pod::Coverage</code>, <code>Test::Kwalitee</code> and the like)
* Author, "release candidate", or smoke tests do not need to be enabled e.g. tests using Perl::Critic
* Author, "release candidate", or smoke tests do not need to be enabled e.g. tests using <code>Perl::Critic</code>.


Additionally, for "meta" packages that provide a common interface to a number of similar modules, it is not necessary to package all of the modules that the package supports so long as at least one module exists to allow the meta package to provide functionality.  For instance, the package perl-JSON-Any (JSON::Any) provides a common interface to JSON, JSON::XS, JSON::PC, JSON::Syck and JSON::DWIM; JSON::PC and JSON::DWIM are not currently in Fedora and do not need to be packaged as, e.g. JSON::XS enables JSON::Any.
Additionally, for "meta" packages that provide a common interface to a number of similar modules, it is not necessary to package all of the modules that the package supports so long as at least one module exists to allow the meta package to provide functionality.  For instance, the package <code>perl-JSON-Any</code> (<code>JSON::Any</code>) provides a common interface to <code>JSON</code>, <code>JSON::XS</code>, <code>JSON::PC</code>, <code>JSON::Syck</code> and <code>JSON::DWIM</code>; <code>JSON::PC</code> and <code>JSON::DWIM</code> are not currently in Fedora and do not need to be packaged as, e.g. <code>JSON::XS</code> enables <code>JSON::Any</code>.


== Conditionally enabling/disabling tests ==
== Conditionally enabling/disabling tests ==
Line 149: Line 156:
</pre>
</pre>


With this construct, an offending test will be removed and not executed, unless "--with network_tests" is passed to <code>rpmbuild</code> or %_with_network_tests is defined somewhere, e.g. in a user's <code>$HOME/.rpmmacros</code>.  This approach preserves the test suite for local builds while working within the technical limitations of the buildsystem.
With this construct, an offending test will be removed and not executed, unless <code>--with network_tests</code> is passed to <code>rpmbuild</code> or %_with_network_tests is defined somewhere, e.g. in a user's <code>$HOME/.rpmmacros</code>.  This approach preserves the test suite for local builds while working within the technical limitations of the buildsystem.
 


== Makefile.PL vs Build.PL ==
== Makefile.PL vs Build.PL ==
Line 155: Line 163:
Perl modules typically utilize one of two different buildsystems:
Perl modules typically utilize one of two different buildsystems:


* Ext<code></code>Utils::Make<code></code>Maker
* <code>ExtUtils::MakeMaker</code>
* Module::Build
* <code>Module::Build</code>


The two different styles are easily recognizable:  Ext<code></code>Utils::Make<code></code>Maker employs the Makefile.PL build file, and is the "classical" approach; Module::Build is a newer approach, with support for things Make<code></code>Maker cannot do.  While the ultimate choice of which system to employ is clearly in the hands of upstream, if Build.PL is present in a distribution the packager should employ that build framework unless there is a good reason otherwise.
The two different styles are easily recognizable:  <code>ExtUtils::MakeMaker</code> employs the <code>Makefile.PL</code> build file, and is the "classical" approach; <code>Module::Build</code> is a newer approach, with support for things MakeMaker cannot do.  While the ultimate choice of which system to employ is clearly in the hands of upstream, if <code>Build.PL</code> is present in a distribution the packager should employ that build framework unless there is a good reason to do otherwise.


See also [[PackagingTips/Perl#Makefile.PL_vs_Build.PL]] .
See also [[PackagingTips/Perl#Makefile.PL_vs_Build.PL]] .
Line 165: Line 173:


It is not uncommon for binary module packages to include .h files, see e.g. <code>perl-DBI</code>, <code>perl-Glib</code>, <code>perl-Gtk2</code>.  For a variety of reasons these should not be split off into a -devel package.
It is not uncommon for binary module packages to include .h files, see e.g. <code>perl-DBI</code>, <code>perl-Glib</code>, <code>perl-Gtk2</code>.  For a variety of reasons these should not be split off into a -devel package.
== cpanspec ==
<code>cpanspec</code> is an excellent little tool to assist in creating Fedora-compliant packages from CPAN-based modules.  Its use as a starting point is recommended (but certainly not mandated).
For more information, see: [[Perl/cpanspec]]


== Updates of packages ==
== Updates of packages ==
Line 180: Line 182:


== Perl SIG ==
== Perl SIG ==
People around Perl, who are packaging, maintaining & reviewing packages. If you are interested in Perl, join [https://lists.fedoraproject.org/mailman/listinfo/Perl-devel mailing list], where are discussed latest issues.
People around Perl, who are packaging, maintaining & reviewing packages. If you are interested in Perl, join [https://lists.fedoraproject.org/mailman/listinfo/Perl-devel the mailing list], where are discussed latest issues.


New Perl packages should set the [https://lists.fedoraproject.org/mailman/listinfo/Perl-devel Fedora perl SIG mailing list]  as a member of the initial-cc list for bugzilla.  This can be done by adding the user <code>perl-sig</code> to the initial CC list when creating the [[Package_SCM_admin_requests#New_Packages|New Package SCM Request]].
New Perl packages should set the [https://lists.fedoraproject.org/mailman/listinfo/Perl-devel Fedora Perl SIG mailing list]  as a member of the initial-cc list for bugzilla.  This can be done by adding the user <code>perl-sig</code> to the initial CC list when creating the [[Package_SCM_admin_requests#New_Packages|New Package SCM Request]].


<pre>
<pre>

Revision as of 00:58, 10 November 2016

License tag

Perl itself is dual licensed, under both the GPL and Artistic licenses. Many Perl modules follow this practice; when they do, the license tag should be filled out as "GPL+ or Artistic", not the other way around.

Note also that under the license tag guidelines, it's important to specify "GPL+" not just "GPL" for those packages "licensed under the same terms as Perl itself."

License: GPL+ or Artistic

Directory Ownership

As specified in the general Packaging Guidelines, Perl packages are expected to share ownership of certain directories.

In general, a noarch Perl package must own:

# For noarch packages: vendorlib
%{perl_vendorlib}/*

...and a arch-specific Perl package must own:

# For arch-specific packages: vendorarch
%{perl_vendorarch}/*
%exclude %dir %{perl_vendorarch}/auto/

Build Dependencies

As stated in Packaging:Guidelines#BuildRequires_2, a package must explicitly indicate its build dependencies (using BuildRequires:) outside of the minimal set required for RPM to build packages. This includes any dependency on Perl. While Perl may have been in the default buildroot at one time, this is not currently the case.

Below is a list of Perl-related build dependencies you may need.

  • perl-generators – Automatically generates run-time Requires and Provides for installed Perl files. Whenever you install a Perl script or a Perl module, you must include a build dependency on this package.
  • perl – The Perl interpreter must be listed as a build dependency if it is called in any way, either explicitly via perl or %__perl, or as part of your package's build system.
  • perl-devel - Provides Perl header files. If building architecture-specific code which links to libperl.so library (e.g. an XS Perl module), you must include BuildRequires: perl-devel.

If a specific Perl module is required at build time, use perl(MODULE) syntax as documented above. This applies to so called core modules as well, since they may move in and out of the base Perl package over time.

If you need to limit your package to a specific Perl version, use perl(:VERSION) dependency with desired version constraint (e.g. perl(:VERSION) >= 5.22). Do not use a comparison against the version of the perl package because it includes an epoch number, which makes version comparisons tricky.

Perl Requires and Provides

Perl packages use the virtual perl(Foo) naming to indicate a given Perl module. Packages should use this methodology, and not require the package name directly. For example, a package requiring the Perl module Readonly should not explicitly require perl-Readonly, but rather perl(Readonly), which the perl-Readonly package provides.

It is recommended to include explicit dependencies for core modules, because they can move between sub-packages or disappear from core Perl.

Versioned MODULE_COMPAT_ Requires

All Perl modules must include the versioned MODULE_COMPAT Requires:

Requires:  perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))

This is to ensure that Perl packages have a dependency on the particular version of Perl it was built against, or on a newer version of Perl that provides backward compatibility with it.

For example, perl-5.8.8 provided not only perl(:MODULE_COMPAT_5.8.8), but also perl(:MODULE_COMPAT_5.8.7), etc., because backward compatibility was guaranteed for Fedora Perl 5.8.x.

On the other hand, perl-5.10.1 implements some incompatible changes to module tree layout and libperl.so build options. Once the compatibility aids are removed, perl-5.10.1 and above will no longer provide perl(:MODULE_COMPAT_5.10.0).

In the future, it is possible that perl-5.12.2 will provide not only perl(:MODULE_COMPAT_5.12.[012]), but also perl(:MODULE_COMPAT_5.10.[123]), if the backward compatibility with all versions >= 5.10.1 is maintained.

Packages that link to libperl

Some packages link to libperl.so, usually to provide embedded Perl functionality. All of these packages must also use the versioned MODULE_COMPAT dependency, because the automatically generated dependency on libperl.so does not include any interface version number.

Filtering Requires and Provides

RPM's dependency generator can often throw in additional dependencies and will often think packages provide functionality contrary to reality. To fix this, the dependency generator needs to be overriden so that the additional dependencies can be filtered out. Please see [[1]] for information.

Note.png
Updating deprecated methods
In the past, several other methods were given for doing this filtering. Those should be considered deprecated and packages should be updated to use the macros on [[2]] as time and the natural rebuild cycle permits.

Manual Requires and Provides

Under some circumstances, RPM's automatic dependency generator can miss dependencies that should be added. This is usually as a result of using language constructs that the dependency script wasn't expecting. An example of this is in the perl-Class-Accessor-Chained package, where the following can be found:

use base 'Class::Accessor::Fast';
...
use base 'Class::Accessor';

A tell-tale sign of this particular construct is that the package contains a dependency on perl(base), but this is not the only situation in which dependencies can be missed. This package needed additional dependencies as follows:

Requires: perl(Class::Accessor), perl(Class::Accessor::Fast)

In general, it's a good idea to look at the upstream package's documentation for details of other dependencies.

Another similar example of missing requirements can be seen in perl-Spreadsheet-WriteExcel:

package Spreadsheet::WriteExcel::Utility;
...
use autouse 'Date::Calc'  => qw(Delta_DHMS Decode_Date_EU Decode_Date_US);
use autouse 'Date::Manip' => qw(ParseDate Date_Init);

Similarly, it possible to miss Provides:, as was the case in Bug #167797 , where the perl-DBD-Pg package failed to Provide: perl(DBD::Pg) due to the following construct in DBD::Pg version 1.43:

{ package DBD::Pg;

The usual way of writing this, and what's expected by RPM, is:

{
package DBD::Pg;

So it's wise to examine the Provides: of your packages to check that they are sane and complete. If something is missing, it can be fixed either by using manual Provides: entries, or by patching the source to use a format that RPM can parse correctly.

URL tag

For CPAN-based packages the URL tag should use a non-versioned search.cpan.org URL. E.g., if one were packaging the module Net::XMPP, the URL would be:

URL: http://search.cpan.org/dist/Net-XMPP/

Testing and Test Suites

Perl packages typically have a large, healthy test suite. It is policy to run as much of the test suite as possible, subject to the technical limitations of the buildsystem. This means, at the least:

  • All modules required for tests should be listed as a buildrequires
  • Any "optional" tests should be enabled
  • Any modules needed for the tests but not yet in Fedora that could be included in Fedora should also be submitted for review

When to *not* test

There are a couple caveats here:

  • Optional tests do not need to be enabled if they will cause circular build deps
  • Tests which require network or display access should be disabled for the buildsystem, but with a method provided for local builds
  • Tests which do not test package functionality should still be invoked, but their exclusion not be considered a blocker (e.g. Test::Pod::Coverage, Test::Kwalitee and the like)
  • Author, "release candidate", or smoke tests do not need to be enabled e.g. tests using Perl::Critic.

Additionally, for "meta" packages that provide a common interface to a number of similar modules, it is not necessary to package all of the modules that the package supports so long as at least one module exists to allow the meta package to provide functionality. For instance, the package perl-JSON-Any (JSON::Any) provides a common interface to JSON, JSON::XS, JSON::PC, JSON::Syck and JSON::DWIM; JSON::PC and JSON::DWIM are not currently in Fedora and do not need to be packaged as, e.g. JSON::XS enables JSON::Any.

Conditionally enabling/disabling tests

One common way to disable a test for mock but enable it locally is to use a _with_foo macro test. e.g.:

%check
%{?!_with_network_tests: rm t/roster.t }
./Build test

With this construct, an offending test will be removed and not executed, unless --with network_tests is passed to rpmbuild or %_with_network_tests is defined somewhere, e.g. in a user's $HOME/.rpmmacros. This approach preserves the test suite for local builds while working within the technical limitations of the buildsystem.


Makefile.PL vs Build.PL

Perl modules typically utilize one of two different buildsystems:

  • ExtUtils::MakeMaker
  • Module::Build

The two different styles are easily recognizable: ExtUtils::MakeMaker employs the Makefile.PL build file, and is the "classical" approach; Module::Build is a newer approach, with support for things MakeMaker cannot do. While the ultimate choice of which system to employ is clearly in the hands of upstream, if Build.PL is present in a distribution the packager should employ that build framework unless there is a good reason to do otherwise.

See also PackagingTips/Perl#Makefile.PL_vs_Build.PL .

.h files in module packages

It is not uncommon for binary module packages to include .h files, see e.g. perl-DBI, perl-Glib, perl-Gtk2. For a variety of reasons these should not be split off into a -devel package.

Updates of packages

Summary of tools used for updates and helpful comments can be found here Perl/updates.

Useful tips

Some modules try to pull in modules from cpan. Instead of patching makefile, you can easily add PERL5_CPANPLUS_IS_RUNNING=1 to avoid CPAN entirely.

Perl SIG

People around Perl, who are packaging, maintaining & reviewing packages. If you are interested in Perl, join the mailing list, where are discussed latest issues.

New Perl packages should set the Fedora Perl SIG mailing list as a member of the initial-cc list for bugzilla. This can be done by adding the user perl-sig to the initial CC list when creating the New Package SCM Request.

%build
PERL5_CPANPLUS_IS_RUNNING=1 %{__perl} Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}