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.

Comparison of different compression tools

Working with various compressed files on a daily basis, I found I didn’t actually know how the different tools performed compared to each other. I know different compression will best fit different types of data, but I wanted to compare using a large generic file.

The setup

The file I chose was a 4194304000 byte (4.0 GB) Ubuntu installation disk image.

The machine tasked with doing of the bit-mashing was an Ubuntu with a AMD Ryzen 9 5900X 12-Core ... [continue reading]

Why TCP keepalive may be important

Published on December 17, 2024

The irony of insecure security software

Published on December 09, 2024