Build an RPM in the Cloud

If you are as frustrated as I am when you try to launch a stock Amazon AMI as an EC2 instance in Amazon's cloud and then try to do any kind of Perl development, then here's an AMI image or you.

Search the community AMIs for this: ami-0043036a

The image contains pre-installed tools so you can easily roll a new RPM using cpanspec and rpmbuild.

Amazon AMIs are now shipped with Perl version 5.16 and unfortunately Amazon's rpm repo does not contain all of the modules you might want or need. If you enable the epel repo, you'll find some incompatibilities with those rpms and things quickly get frustrating.

Adding to the frustration is the fact that cpanspec from the epel repo itself has a broken dependency and if you manage to figure out how to work around that, you'll find yourself cursing either Perl, Moose, epel, Amazon or maybe all of the above.

Yes, this problem has been solved by building your own perl (plenv, perlbrew) and then using cpanm to install the modules you need, but if you want (or have) to stay in the rpm world and play nice with the O/S version of perl, then you might want to try this image out.

No doubt someone will point out that using the O/S perl binary for application development is not the way to do Perl application development, and I don't necessarily disagree.

But, in the spirit of the season, I decided to share a few hours of work for those that might also have experienced this problem.

Launch an EC2 using this image and try something like this:

 $ cpanget Text::Wrapper
 $ cpanspec -v --packager="ec2-user" Text::Wrapper
 $ mv Text-Wrapper-1.05.tar.gz rpm-build/SOURCES
 $ mv perl-Text-Wrapper.spec rpm-build/SPECS
 $ rpmbuild -ba rpm-build/SPECS/perl-Text-Wrapper.spec

Leave a comment

About bigfoot

user-pic I blog about Perl and Bedrock.