[Triumf-linux-managers] FYI - cpan2rpm
Andrew Daviel
advax at triumf.ca
Fri Dec 18 18:51:09 PST 2009
FYI - cpan2rpm - making RPMs from Perl CPAN modules
(if CPAN means nothing to you, abort now :-)
Further to my story on system recovery without re-installation, and the
merits of getting as many system files into RPM as possible, I have been
playing with cpan2rpm and cpanspec.
Much Perl software, such as SpamAssassin, relies on other Perl modules.
The documentation often suggests getting these from CPAN (www.cpan.org).
External modules are identified in code e.g. "use Compress::Zlib"
and there is a script bin/cpan included with Perl which can be used to
retrieve and install packages e.g.
cpan> install Compress::Zlib
.. this needs XX and YY, shall Y get them ? Y
.. build,install etc.
Alternatively, most Perl packages come in a tarball with Makefile.PL, so
that the recipe
$ tar -zxf FooBar-1.0.tar.gz ; cd FooBar-1.0
$ perl Makefile.PL
$ make
$ make test
$ sudo make install
will build and install a module Foo::Bar
These processes tend to install files all over the place, in /usr/bin,
/usr/lib/perl5/site_perl etc. with no obvious way to track what package
they belong to (though there is a contents file dropped in
/usr/lib/perl5/site_perl/nnn/Foo/Bar/.packlist)
It is a better idea to install modules with RPM if possible. Then they
can be easily updated, verified, restored or removed. (or dpkg for
Debian-based systems)
Fedora (hence RHEL and SL) have packaged many Perl modules using
cpanspec. So the first suggestion is to look for a Perl module in Yum.
Kel points out that the RPM names are mangled from the module names
(colons being illegal) and that yum can be used to translate:
$ yum provides 'perl(Mail::Address)' - CPAN module to RPM package name
$ rpm -q --provides perl-MailTools - list modules in RPM package
There are many more Perl modules in the EPEL repository.
Failing a pre-built RPM, cpan2rpm may be used to build an RPM :
# cpan2rpm Foo::Bar - download and build a package, leaving an RPM in
/usr/src/redhat/RPMS/xxx/perl-FooBar-nnn.rpm
cpan2rpm can also be used on an existing cpan build, offering the
possibility of retroactively packaging a module previously installed with
bin/cpan or "make install" :
# cd ~/.cpan/build/FooBar-0.1
# cpan2rpm .
Checking if an existing install matches a package is slightly tricky;
sometimes there are trivial differences e.g. 'exec /usr/bin/perl'
One can try (before installing)
$ rpm -Vp /usr/src/redhat/RPMS/xxx/perl-FooBar-nnn.rpm
or install at an alternate root and check manually, e.g.
$ mkdir -p /tmp/rpm/var/lock/rpm
$ rpm --initdb --root /tmp/rpm
$ rpm -hi -r /tmp/rpm /usr/src/redhat/RPMS/xxx/perl-FooBar-nnn.rpm
$ diff -r /tmp/rpm/usr/lib/perl5/site_perl/nnn /usr/lib/perl5/site_perl/nnn
(The more general case, of easily making an RPM from some "./configure;
make install" package, I have not figured out. Anyone know a way ?)
--
Andrew Daviel, TRIUMF, Canada
Tel. +1 (604) 222-7376 (Pacific Time)
Network Security Manager
More information about the Triumf-linux-managers
mailing list