Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created February 23, 2012 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordansissel/1890238 to your computer and use it in GitHub Desktop.
Save jordansissel/1890238 to your computer and use it in GitHub Desktop.
fpm refactoring

so fpm's internals is gnarly and also has no tests (strong correlation there).

WHile thinking about what a 'source' and 'target' are in fpm, I decided that everything is really a 'package' type of thing.

like, you add files to a 'directory' package. You can add rpms to an 'rpm' package. By 'add' I mean load and import.

so this was my new proposed public API in fpm:

dir = FPM::Package::Dir.new
dir << "/etc"
rpm = dir.convert(FPM::Package::RPM)
rpm.output("my.rpm")

This becomes neat because you can compose multiple things to make mega packages if you really really wanted to, like this:

gem = FPM::Package::Gem.new
gem << "json"   # adds the json gem contents
gem << "rails"  # Adds the rails gem contents
rpm = gem.convert(FPM::Package::RPM)
rpm << "libmysqlclient"    # Adds the 'libmysqlclient' package contents 
rpm.output("big.rpm")

The result of the above is that 'big.rpm' provides rubygem(json), rubygem(rails), libymysqlclient, and includes all files and otherwise dependencies of all of them.

Should make for some neat experimentations, anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment