FPM is a powerful wrapper allowing you to create packages for multiple programs in multiple operating systems. In this tutorial, I show you how you can replace tedious packaging of third party applications with FPM.

What you need to complete this tutorial

  • A Linux distribution. I used Fedora but this works with anything.
  • Elevated privileges, if you want to install packages.

When a package manager is not simple enough

Sometimes, you want ultimate control over how you package an application. Other times, that’s overkill. For instance:

  • A third party application is simple or small enough that a TAR archive would be good enough to install it. However, you want to enjoy the benefits of upgrades and roll-backs, like the ones offered by RPM.
  • You need or want to package an application from one format (say .tar.gz) to a DEB or RPM.
  • You have to package multiple applications that are only offered in source format, or are pre-packaged binaries, and you don’t want to spend an eternity re-packaging.

Packaging an existing application the old way

I’ve written a tutorial explaining how to create an RPM for an existing application. Briefly, there are a few manual steps:

  1. Download the source or binary distribution.
  2. Prepare an RPM spec file, which takes care of compilation (or just the packaging) of the software, as well the install location.
  3. Lint the spec file to find bugs.

Let’s see how the jdumpertools RPM spec file works. First, take a look at the spec file:

Build it:

Now you can install it just like any other RPM:

It is not terrible, especially if you plan to make updates, but it can be easier!

Install FPM

The FPM project maintains a great getting started document, but here’s an overview of how I use it.

First, install some dependencies. For example, on Fedora:

And then install FPM itself:

Packaging jdumpertools as an RPM without a spec file

Now that FPM is installed, you need some files to package. The example application I’m using is jdumpertools, and it happens to come with a Makefile, so it’s easy to build it:

There’s no RPM spec file, but that doesn’t matter to FPM:

You can install the resulting RPM as usual.

Packaging for Debian

What about building for Debian? That’s just as easy:

You now have a DEB file that a Debian user can install using dpkg.

Self-extracting script and TAR

You can package applications as a self-extracting install script (-t sh), or just as a TAR archive (-t tar). To run a self-extracting script, a user must make it executable, and then run it:

This is already very convenient. But that’s not all FPM can do.

Re-packaging existing software

Suppose you want to distribute a CPAN module that isn’t packaged as an RPM. You could spend quality time packaging it up, or you can use FPM to do the work for you.

First, install a new dependency for Fedora:

And then build the RPM:

Verify your work:

Similarly, Python packages can be created. Here’s how to package the clickhouse-driver module from PyPi:

Suppose you want to create an RPM for OpenJDK 17. No problem, get the TAR file and package it:

What next?

Believe it or not, there’s still more FPM can do. I covered my favorite use cases, but the tool has much more to offer:


Jose Vicente Nunez

System Administrator/ DevOps.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *