Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


add gem source handler #10

wants to merge 1 commit into from

4 participants

scott smith Bernd Ahlers Pranay Kanwar Tray
scott smith

I just started using fpm-cookery and would like a uniform interface to building packages. Since I use fpm to build Ruby gems, I hacked this branch together.

I don't know if this is of any value to you. Here's an example recipe:

class RubygemJson173 < FPM::Cookery::Recipe
  description 'This is a JSON implementation as a Ruby extension in C.'

  name 'rubygem-json'
  version '1:1.7.3'
  revision 1
  homepage ''
  source '', :with => :gem, :name => 'json', :version => '1.7.3', :as => 'json-1.7.3.gem'
  sha256 '1070e6cd2fedc0cb06e7e56a980b884bdf6e61a9184abb1c6e677d308b4c26d9'

  section 'ruby'

  def build
    # noop

  def install
    system "gem install --ignore-dependencies --no-rdoc --no-ri --bindir #{destdir}/usr/bin --install-dir=#{destdir}/usr/lib/ruby/gems/1.8 json-1.7.3.gem"
scott smith

It would be cool to have some of the default fpm functionality in this though, like dependencies etc.

Bernd Ahlers

Thanks for your work! I was wondering, wouldn't it be easier to just provide a separate recipe class for rubygems? fpm knows how to handle rubygem sources already. (fpm -s gem -t deb json)

Something like this.

class JSON < FPM::Cookery::RubygemRecipe
  name 'json'
  version '1.7.3'

I think that should be enough. (maybe add dependecy handling later) What do you think?

Pranay Kanwar

+1 for FPM::Cookery::RubygemRecipe.

Sébastien Masset smasset referenced this pull request

Gem Recipes #18


Another :+1: for class-specific overrides - we could extend this out to cover all the various things FPM can input from, so that one can easily define how to build a specific NPM/egg/gem package based off of a main, package-specific base.

Bernd Ahlers

Closing this because the gem receipes pull request (#18) has been merged.

Bernd Ahlers bernd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 11, 2012
  1. scott smith

    add gem source handler

    ohlol authored
This page is out of date. Refresh to see the latest.
1  lib/fpm/cookery/source_handler.rb
@@ -3,6 +3,7 @@
require 'fpm/cookery/source_handler/svn'
require 'fpm/cookery/source_handler/git'
require 'fpm/cookery/source_handler/hg'
+require 'fpm/cookery/source_handler/gem'
require 'fpm/cookery/log'
module FPM
38 lib/fpm/cookery/source_handler/gem.rb
@@ -0,0 +1,38 @@
+require 'fpm/cookery/source_handler/template'
+require 'fpm/cookery/log'
+module FPM
+ module Cookery
+ class SourceHandler
+ class Gem < FPM::Cookery::SourceHandler::Template
+ NAME = :gem
+ CHECKSUM = true
+ def fetch
+ name = options[:name]
+ version = options[:version]
+ if local_path.exist?
+ "Using cached file #{local_path}"
+ else
+ Dir.chdir(cachedir) do
+ gem(name, version, url) unless local_path.exist?
+ end
+ end
+ local_path
+ end
+ def extract
+ FileUtils.cp(local_path, '.')
+ Dir.pwd
+ end
+ private
+ def gem(name, version, source)
+ safesystem('gem', 'fetch', name, '-v', version, '--source', source)
+ end
+ end
+ end
+ end
Something went wrong with that request. Please try again.