Fast and dirty RPMs

This post appeared originally in our sysadvent series and has been moved here following the discontinuation of the sysadvent microsite

Everything was ready. The deploy should have been clean and fast. But then, the developers had added just another language module. Not a big thing, just something you could have pulled down, and stashed somewhere below /usr/local. But then, there is this policy that was added early in the project process: All software should be packaged as rpm files. Sounded a dream for the ops people, this time we should get it done right. But for this single library, there are no packages to find. You’ve searched EPEL, you’ve been through rpmfusion, and you’ve googled them all, rpmfind, pbone, and even fedora but nope, no package to be found. So what do you do?

You could of course write the spec-file from scratch and build the package. But you should already be on your way home. Are there any shortcuts? Well, of course there are.

On your EL7 EPEL equipped buildbox, start by setting up an rpm build tree. You need to install the EPEL repositories, of course.

sudo yum install rpmdevtools
rpmdev-setuptree

Wrap some Perl modules

Try cpanspec! As a random example, we use the Perl module DateTimeX::Seinfeld:

sudo yum install cpanspec
cd ~/rpmbuild/SPECS
cpanspec -v --packager "Random J. Hacker <random@example.com>" DateTimeX::Seinfeld
sudo yum-builddep perl-DateTimeX-Seinfeld.spec
rpmbuild -bb Color-Palette-0.100003.tar.gz

Done! Next!

Bundle some python modules

For easy python pip module packing, try pyp2rpm. Here we use the kaptan module as example, building it for python2.7:

sudo yum install pyp2rpm
sudo sed -i 's/http:/https:/g;' \
  /usr/lib/python2.7/site-packages/pyp2rpm/settings.py # Yep, that's a bug
pyp2rpm -p2 kaptan > ~/rpmbuild/SPECS/python-kaptan.spec
sudo yum-builddep ~/rpmbuild/SPECS/python2-kaptan.spec
rpmbuild -bb ~/rpmbuild/SPECS/python2-kaptan.spec

Package a few ruby gems

For fast ruby gem packaging, we use gem2rpm. Here we use another random example, a gem called sawyer:

sudo yum install rubygem-gem2rpm
cd ~/rpmbuild/SOURCES
gem fetch sawyer
gem2rpm -t fedora-21-25 sawyer-0.8.1.gem -o ~/rpmbuild/SPECS/rubygem-sawyer.spec
rpmbuild -bb ~/rpmbuild/SPECS/rubygem-sawyer.spec

Note that we use the fedora templates. They tend to work quite well with both EL7 and EPEL.

Swaddle some pear modules

For smart packaging of PHP pear modules, try the built-in function make-rpm-spec. For this example, we use the Archive_Tar module

sudo yum install php-pear-PEAR-Command-Packaging
cd ~/rpmbuild/SOURCES
pear download Archive_Tar
pear make-rpm-spec Archive_Tar-1.4.3.tgz
rpmbuild -bb php-pear-Archive-Tar.spec

Easy!

Ingvar Hagelund

Team Lead, Application Management for Media at Redpill Linpro

Ingvar has been a system administrator at Redpill Linpro for more than 20 years. He is also a long time contributor to the Fedora and EPEL projects.

Alarms made right

At my work, we’re very much dependent on alarms. The systems need to be operational 24/7. When unexpected issues arise, timely manual intervention may be essential. We need good monitoring systems to catch whatever is wrong and good alarm systems to make someone aware that something urgently needs attention. I would claim that we’re quite good at setting up, tuning, and handling alarms.

When I’m not at work, I’m often sailing, often single-handedly for longer distances. Alarms are important for ... [continue reading]

Just-Make-toolbox

Published on March 22, 2024

Containerized Development Environment

Published on February 28, 2024