weidner -> computer -> linux -> rpm de EN
Stand: 2002-12-18
(2001-04-27)

RPMs from Perl modules with cpanflute

It was always tedious making RPM packages for perl modules from CPAN.

2001 I came across the program /usr/lib/rpm/cpanflute from the package rpm-build (4.0.2). Using cpanflute makes building a RPM package really easy.

Usage

/usr/lib/rpm/cpanflute [options] tar-file

options: --email=text
         --create
	 --n=string

The Options

--email=text
The text will be used for the %changelog entry in the spec file. If this option isn't given cpanflute uses logname [at] redhat.com.
--create
When this option is given, cpanflute will add a -c (create directory) to the %setup macro in the spec file. This makes it possible to create RPMs from tar files without a directory in it.
-n=text
This option is not in use (as far as I could see from the source of cpanflute).

Auxiliary directories

The version of cpanflute I had (from rpm-build-4.0.2) uses the following (hard coded) auxiliary directories that must be in place before starting cpanflute:

/tmp/cpan/junk
/tmp/cpan/temp

A real life example

I fetched the perl module MIME-Base64 from CPAN.

Then I generate and install the RPM packages with the following steps (lines broken for readability):

$ /usr/lib/rpm/cpanflute --email=mathias@weidner.in-bad-schmiedeberg.de MIME-Base64-2.12.tar.gz
$ rpm --rebuild /tmp/cpan/temp/perl-MIME-Base64-2.12-6.src.rpm
$ sudo rpm --Uvh redhat/RPMS/i386/perl-MIME-Base64-2.12-6.i386.rpm

First I call cpanflute and give my email address for the %changelog entry and the name of the tar archive. cpanflute generates a source RPM, i.e. a package that contains the original source and the commands to compile it and make a binary package.

Next I take the source RPM, compile it and may install it. If anything goes wrong I can always edit the spec file.

If you're familiar with rpm then you've possibly noticed that the source RPM has perl- prepended to its name and that the release number of the RPM is 6. This is hard coded in cpanflute.

Another way to generate RPM packages from perl modules is 'cpan2rpm - A Perl module packager' that can be found at CPAN.
Dave Fogarty made me aware of this.