Ops, Entrepreneurism, Tools, and Thoughts.

New Flavour of Lifesaver: FPM

| Comments

I’ve been hunting for a good reason to get familiar with @jordansissel’s wonderful tool FPM. I have spent more time grovelling with rpm spec files than I ever wanted to but I haven’t been able to break out of the habit. Until today that is…

My problem is simple, despite setting up a sweet series of internet accessible yum repos to deploy product some people insist on a standalone installation method. I can’t deny, this is aggravating as snot. Alas, my problem is simple:

  1. How can I get a yum repo deliverable by media?
  2. How can I keep the install procedure as similar to those using the publicly available yum repos?

How to solve this issue using FPM and some cool features of yum:

  • I’m assuming you have an accessible yum repository setup the way you want.
  • Install the yum download only plugin and/or yum-utils
yum install yum-downloadonly
yum install yum-utils.noarch
  • Now you can access your yum repository but with a twist, you can simply download your package and all the dependencies. Examples:
yum install <package> --download 
yumdownloader <package> --resolve
  • At this point you have all your rpms, move them to a sensible directory structure. I suggest one that matches how you have your public yum repos setup. Try /data/repo/app/
  • Once your rpms are in /data/repo/app run createrepo on that directory. At this point you’ve got a yum repo on disk. Now it’s time to create the repolist file, call it standalone-app.repo
  • Repolist file:
name=Descriptive Name for your Repo

You’ll note that this is not enabled by default. Keep that in mind.
* Move your repolist to /etc/yum.repos.d/ so that yum picks it up. You’re ready to package this beast up.
* Make sure FPM is installed, gem install fpm
* FPM chant to package your repo into a rpm for distribution:

fpm -s dir -t rpm -n "NameOfPackage" -v <version number> /data/repo/app /etc/yum.repos.d/standalone-app.repo

Let that chew for a bit, when it’s done you’ll have an rpm. Move that rpm to another machine and install it.
* Magic time. That RPM you just made and installed has moved your repolist file to the /etc/yum.repo.d dir and put all your packages and yum repo files at /data/repo/app. Try performing a yum install from this local repo:

yum install app --enablerepo name-of-repo

Boom. That just happened. This is a pretty basic usage of FPM but let’s review what happened:
1. -s dir: you’re building an package based on directories and files
2. -t rpm: the result will be an rpm
3. -n “name”: give your package a name
4. -v version: give your package a version number
5. paths to directories and files, separated by spaces

Note how you didn’t have to wrap your mind around specfiles or any rpm specific stuff. I can’t tell you how huge this is. If you don’t need to care about the inner workings of rpm specfiles, don’t, FPM takes care of it. As I said, this is basic stuff. FPM has the ability to rip multiple package formats including apt, deb and many more. It’s a huge timesaver and worth taking a look at. Buy @jordansissel a beer if you see him.

Did I solve my problem? Yes
1. I can put this resultant RPM on a usb key or DVD if desired.
2. The install method is extremely close to the public yum repos with the exception of the –enablerepo flag.