From Fedora Project Wiki


The goal of cpanspec is to make following the various Fedora guidelines for Perl packages trivial (see Packaging/Perl ).


There are several ways to use cpanspec. The simplest is to let it fetch a module from CPAN for you, like this:

$ cpanspec -v String::Random
Updating /home/steve/.cpan/sources/modules/02packages.details.txt.gz...
Fetching /home/steve/.cpan/sources/modules/02packages.details.txt.gz from
/home/steve/.cpan/sources/modules/02packages.details.txt.gz is up to date.
Fetching String-Random-0.21.tar.gz from
Trying to fetch description from String-Random-0.21/lib/String/
Writing perl-String-Random.spec...

If you would like to override the default location of CPAN (, you can either set the CPAN environment variable, or you can pass the -c (or --cpan) option to cpanspec. (Be aware that this URL will end up in Source0, so you'll want to edit that before submitting the package for review.)

If you already have a module downloaded (for example, when packaging something not available on CPAN, or when you want to package something other than the latest release of a package), you can run cpanspec on the tar file (or zip file) that contains the module. The Source0 URL will be guessed, so be sure to verify it.

If the package you are trying to build is a script, not a perl module, you can pass the -n (or --noprefix) option to leave the "perl-" prefix off the resulting spec. Please be aware that the %files section of the generated spec will probably need some heavy editing. Support for scripts is probably the single biggest weakness of cpanspec at the time of this writing (version 1.64).

You can also use cpanspec to generate a source rpm by passing the -s (or --srpm) option. If you are feeling really lucky (or maybe crazy), you can also have cpanspec build a binary rpm by passing the -b (or --build) option. As of version 1.66, you can also use --follow to have cpanspec fetch any build dependencies that aren't already available.

There are may other options, so be sure to read through the man page .


The lack of support for scripts mentioned above is the single biggest issue I'm currently aware of. See /usr/share/doc/cpanspec-*/BUGS or the (likely not really current) CVS version of that file for more.


There is a simple shell script called cpanget included in the package that uses the same logic as cpanspec to fetch modules from CPAN.


The cpanget script will likely be replaced with a wrapper around cpanspec soon-ish to get rid of the dependency on wget/tar/zgrep/etc.

The full list of planned features is in the TODO file (/usr/share/doc/cpanspec-*/TODO or the CVS version of that file ).


For more information, see the cpanspec web site or the man page .

I also highly recommend referring to the documentation accumulated by the Perl SIG.