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
this:
%_topdir /home/fozz/rpm
%packager [email protected]
Then, create the base directories for building RPM packages in your
%{_topdir}:
mkdir ~/rpm/{BUILD,SPECS,SOURCES,RPMS,SRPMS}
Install 'cpanspec':
sudo yum -y install cpanspec
Then, go to your ~/rpm/SPECS directory. Let's say you need to install the
Data::Printer packages. Do:
cpanspec Data::Printer
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
Then, build:
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:
cpanspec File::HomeDir
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!
Install!
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. - <[email protected]> - 801-520-9875
Open source consulting, custom development, systems/network administration
"Vertical parking only."
-- Seen in a Tokyo traffic handbook
signature.asc
Description: This is a digitally signed message part.
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
