Perl Modules: CPAN vs Yum
Doran L. Barton
fozz at hypermoo.com
Fri Jun 29 22:43:36 MDT 2012
On Friday, June 29, 2012 10:10:12 PM Jacob Albretsen wrote:
> So the question is.... is it a good practice to mix the two ways to install
> Perl modues? Will I run into issues mixing the two?
A lot of Perl developers that use CentOS tend to just use perlbrew and cpanm,
but this can be problematic. Perl's CPAN libraries are nowhere near as good as
a good package manager like dpkg or rpm.
So, what's the best way to build and install CPAN modules that aren't in
standard repositories for CentOS? My preference is using 'cpanspec'. This will
fetch the CPAN tarball for a module and build a .spec file for you. 80-90% of
the time, you can build RPM packages without altering this spec file.
Occasionally, you'll need to add items to the %files section like when a module
includes files in /usr/bin or in /usr/man/man1 (as opposed to /usr/man/man3).
If you've already got an RPM build environment set up, you're a few steps
ahead already. Otherwise, create a ~/.rpmmacros file that looks something like
%packager fozz at hypermoo.com
Then, create the base directories for building RPM packages in your
sudo yum -y install cpanspec
Then, go to your ~/rpm/SPECS directory. Let's say you need to install the
Data::Printer packages. Do:
This will download (from CPAN) the source tarball and build a perl-Data-
Printer-$version.spec file which you can build an RPM package from. First, move
the tarball into the sources directory:
mv Data-Printer-0.3.tar.gz ../SOURCES
rpmbuild -ba perl-Data-Printer.spec
Oh dear, this spits out some failed dependencies:
error: Failed build dependencies:
perl(File::HomeDir) >= 0.91 is needed by perl-Data-Printer-0.3-1.noarch
perl(Hash::FieldHash) is needed by perl-Data-Printer-0.3-1.noarch
perl(Sort::Naturally) is needed by perl-Data-Printer-0.3-1.noarch
Well, this is where cpanspec gets less fun. If you can't install these
dependencies with yum then you're going to have to use cpanspec to build each
of the dependencies before you can build perl-Data-Printer.spec:
mv File-HomeDir-0.99.tar.gz ../SOURCES
rpmbuild -ba perl-File-HomeDir.spec
This one didn't give me any dependency problems and built an RPM. Wahoo!
sudo rpm -ivh ~/rpm/RPMS/noarch/perl-File-HomeDir-0.99-1.noarch.rpm
Then, you'd go through the same process for Hash::FieldHash, Sort::Naturally,
and then get back to building perl-Data-Printer and you're done.
This saves a lot of time compared to building your own .spec files for each of
the CPAN packages, but dependencies can be a pain. There are a few yum
repositories out there that provide a lot of the packages that aren't included
in the CentOS base repository or the EPEL repository, but they don't always
play nice with each other. For example, rpmforge (see repoforge.org) has a lot
of Perl RPMs. YMMV.
Hope that helps.
Doran L. Barton - Hypermoo Inc. - <fozz at hypermoo.com> - 801-520-9875
Open source consulting, custom development, systems/network administration
"Vertical parking only."
-- Seen in a Tokyo traffic handbook
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://plug.org/pipermail/plug/attachments/20120629/06917aae/attachment.bin
More information about the PLUG