I'm apt to play the cpanflute
Posted: 26 June 2003 at 02:07:36
We had some weird weather yesterday. Rain and hail... and it was sunny.
Rain and hail and sun
Yeah- it was weird. Pea-size hailstones too. The runoff drains in front of Jay's house were not up to taking the volume of water running down the street and the yard started to flood. I went out with a rake, waded into knee-high water and stuck the rake handle down through the drain grating and tried to dislodge whatever was keeping the water from running into the sewer system. After moving the rake handle around for a couple of minutes, the water started draining into the grating a lot better.
Making RPMs from CPAN modules
I recently needed to install MIMEDefang on a Red Hat system and found it was somewhat frustrating.
It was frustrating because I didn't want to compile it from source — I wanted to install the binary RPM or build a binary RPM from a source RPM. The RPMs required a bunch of Perl CPAN modules to be installed... but as RPMs.
Some RPMs are available as part of the Red Hat Linux distribution. Others can be found via websites like rpmfind.net. I thought there had to be an easy way to create RPMs from CPAN tarballs so I did some Googling and found a reference to a tool called “cpanflute”.
I found some pages that mentioned cpanflute, but nothing like a comprehensive project home page. On a whim, I decided to see if my apt4rpm repository cache had any hints.
% apt-cache search cpanflute perl-RPM-Specfile - Perl module for creating rpm packages of other perl modules.
Now I had a package I could install that contained something “cpanflute”. I installed this package.
# apt-get install perl-RPM-Specfile The following NEW packages will be installed: perl-RPM-Specfile 0 packages upgraded, 1 newly installed, 0 removed and 1 not upgraded. Need to get 0B/12.6kB of archives. After unpacking 19.1kB of additional disk space will be used. Executing RPM (-Uvh)... Preparing... ########################################### [100%] 1:perl-RPM-Specfile ########################################### [100%]
Now, I wanted to see what was in this RPM. I did an rpm -ql on the package.
/usr/bin/cpanflute2 /usr/lib/perl5/site_perl/5.8.0/RPM/Specfile.pm /usr/share/doc/perl-RPM-Specfile-1.11 /usr/share/doc/perl-RPM-Specfile-1.11/Changes /usr/share/doc/perl-RPM-Specfile-1.11/README /usr/share/man/man3/RPM::Specfile.3pm.gz
Lo and behold, a program called cpanflute2... but no man page or documentation. (No, the README didn't have anything useful and neither did the perldoc.) So, I looked at the script itself.
The --help option dumped out some great usage information.
% cpanflute2 --help cpanflute2 Version 1.11 cpanflute2 [--arch=] [--buildall] [--create] [--descfile=...] [--email=...] [--epoch=...] [--outdir=...] [--name=...] [--noarch] [--noperlreqs] [--patch=...] [--perlver=...] [--release=...] [--requires=...] [ --buildrequires=...] [--test] [--tmpdir=...] [--version=...] (archive) cpanflute2 --usage --arch= Set package to this arch if it is not noarch. Defaults to system default (normally i386). --buildall Build binary RPM's also. --create Have %setup macro create the base directory before unpacking the tarball. --descfile= Path to a text file whose contents should be substituted for the description of the RPM. --email= Email address placed in specfile. Defaults to Doran Barton. --epoch= Set specfile Epoch tag. --outdir= Where to output the SRPM and or RPM. Defaults to ./ --name= Name of CPAN module. Defaults to parsing this from the tarball filename. --noarch Forces architecture noarch. --noperlreqs If set PERL interpreter requirements for things like large file support will not be added. By default they are added. --patch= Patch to use. --perlver= Version of PERL to require. Defaults to 2:5.8.0. --release= Release of RPM to build. Defaults to 8. --requires= Add items for the Requires directive in the spec file. --sign Sign the RPMs with the key in specified via ~/.rpmmacros --buildrequires= Add items for the BuildRequires directive in the spec file. --test Run "make test" in %build. --tmpdir= Temporary directory in which to build. Defaults to /tmp. --version= Version of CPAN module. Defaults to parsing this from the tarball filename. --installdirs= Specify which INSTALLDIRS setting to use (see MakeMaker) (archive) Name of gzipped tarball containing CPAN source.
So, it looks like a lot of optional arguments, but mostly you're just giving it a tarball archive. So, I tried it with one of the MIMEDefang required modules.
% cpanflute2 IO-stringy-2.108.tar.gz Wrote: ./perl-IO-stringy-2.108-8.src.rpm
Whoa.
At this point, all I had to do is install and build the source RPM:
# rpm -ivh perl-IO-stringy-2.108-8.src.rpm 1:perl-IO-stringy ########################################### [100%] # rpmbuild -ba /usr/src/redhat/SPECS/perl-IO-stringy.spec
That created a binary RPM in /usr/src/redhat/RPMS/i386 that I could install.
# rpm -ivh /usr/src/redhat/RPMS/i386/perl-IO-stringy-2.108-8.i386.rpm Preparing... ########################################### [100%] 1:perl-IO-stringy ########################################### [100%]
So I just had to do this for each CPAN module (and their dependencies) required by MIMEDefang. It would be nice if there was an apt archive of CPAN module RPMs so that everything could be automagically built, but this wasn't too bad.
And I had fun doing it.