Monday, December 24th, 2007...1:43 am
CPAN Perl modules as RPMs v/s PAR
After sweating for three days converting a huge number of Perl CPAN modules into RPMs, I finally decided to go the PAR way. I’m trying to get a nice overview of all the Perl CPAN modules required for most of my web applications. This is currently for my product imsense, which is an IM (Instant Messaging) Proxy, firewall and message archiver, but I need this for my other web based projects too.
The primary modules I require are:
- Template (The Template Toolkit) - A templating system
- DBIx::Class - A sexy ORM (Object Relational Mapper) for database abstraction
- CGI::Application - An even sexier web application framework!
- Curses::UI - For any console apps
- Log::Log4perl - For system wide logging
- POE - A Perl Object Environment for writing network servers and clients (It can do much more)
Imagine my state of my mind when I decided to manually work through each of the above modules, gather all their dependencies and turn them into RPMs using cpan2rpm. No, it was not perverse! My main aim was; and still is, to get to know each CPAN module (with all dependencies) which power up my webapp. I must say it was a good learning experience, but extremely tiring.
I gave up midway through DBIx::Class. I managed to go through all the modules which make up Template Toolkit, Curses::UI, Log::Log4perl and POE. DBIx::Class required loads of modules, and I was exhausted by then.
I had a little knowledge of what PAR was, and how it could help me. I decided to spend a few hours to get to know it better, and those hours were well spent indeed. PAR is a Perl Archive Toolkit, which gives Perl developers the ability to package, maintain and deploy their Perl based applications. It can even package it all into a single executable built for a specific architecture.
This is what I did. First, install PAR::Dist on the target system. This only needs a base installation of perl. PAR::Dist has no other dependencies. On your build machine, use cpan2par from the PAR::Dist::FromCPAN module to create a PAR file from a CPAN module.
I ran it this way:
$ cpan2par -f -p DBIx::Class
and what I got was a PAR file of the DBIx::Class module and all its dependencies as additional PAR files!
Transfer the PAR files to the target system, and use the install_par() method from the PAR::Dist module. Again, the target system is a bare bones Linux system with only a base installation of perl; no other CPAN modules.
A short script which will install all PAR files in the current directory.
#!/usr/bin/perl
use strict; use warnings;use PAR::Dist;
my @par_files = glob(”*.par”);
for (@par_files) {
install_par($_);
}
And now the target system is all setup with a working installation of the DBIx::Class module. Handling upgrades should be easy. Just create a new PAR file and deploy it to the target system. PAR supports repositories too, similar to yum, which I definitely need to check out soon.
CPAN can search for data for affiliate marketing. PERL can read through sites for search engine marketing. Many people find advertising flyers to have minimum value. Through internet advertising, millions of users come across 1000’s of web companies daily. Excellent marketing can make you rich. But start with a good web site design that will appeal to millions of users. Advertise your website through a good web hosting company and then you will see yourself getting somewhere.
Leave a Reply