7

I have a command-line utility called Maid that I currently distribute as a RubyGem. I'd also like to distribute it as a .deb package to make it easier for Ubuntu users to install.

Right now, Ubuntu users have to do quite a bit manually, especially for someone unfamiliar with Ruby:

sudo apt-get install ruby
sudo apt-get install rubygems
# Make sure `ruby` and `gem` are in `$PATH`
sudo gem install maid
maid version # example command

Ideally, I want a single command to install on a fresh Ubuntu installation:

sudo apt-get install maid
maid version # example command

The suite of gem2deb tools (gem2tgz, dh-make-ruby, etc.) are almost what I'm looking for. But by default gem2deb doesn't package any of the gem dependencies that are required. Maid is really simple and only depends on thor at runtime. (Edit: as Maid has evolved, and now has more dependencies.) But without that dependency, nothing works.

So, how do I package this Ruby application for Ubuntu and also include its gem dependencies? Are there any other tools I could use or tutorials/examples I could follow?

Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83
  • I'm doing something similar, albeit not as complicated as maid. - https://launchpad.net/~jamesgifford/+archive/factero and https://github.com/jrgifford/ruby-debian-packaging – jrg Sep 03 '12 at 00:28

2 Answers2

3

Because apt-get and gem are both dependency resolving, you can just make a meta package that depends on ruby1.9.1 (which itself brings in Rubygems and everything else). Then in the post-install script, just do a sudo gem1.9.1 install maid.

I can't lay out the whole process of making a package here, but there are a lot of good tutorials on it around the web.

Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83
Linuxios
  • 34,849
  • 13
  • 91
  • 116
3

Using fpm you can (among others) directly create debs from gems. The wiki has an extensive example. The gist of it is to call

cd /tmp
fpm -s gem -t deb maid
Holger Just
  • 52,918
  • 14
  • 115
  • 123
  • I came across `fpm` in my research. It seems like a good project, but I'm not sure what to think about having to create/distribute packages like `rubygem-thor-0.14.6.amd64.deb`. I've seen a number of Ruby projects embed their dependencies inside their `.deb` package for that reason, which also seems problematic. – Benjamin Oakes Sep 02 '12 at 19:54
  • 1
    A good compromise is to create your own apt repository and maintain that for your users. A good companion to fpm is [freight](https://github.com/rcrowley/freight/) which provides some easy to use helpers for maintaining such a repository. That said, you can also incorporate your dependencies with fpm, but would have to deal with potential package overlapping. Sadly, there's no such thing as a free lunch. – Holger Just Sep 02 '12 at 20:19
  • I might do that with a PPA. I might anticipate problems with dependencies if I ever want Maid to be in the Ubuntu Software Center, however. Do you have a link for more information about "incorporating dependencies" with `fpm`? Also, for what it's worth, I found that `fpm` didn't add `ruby` as a dependency in the control file. Know anything further? – Benjamin Oakes Sep 02 '12 at 22:54
  • Well, you can simply package the full directory. You would have to specify the metadata yourself. You can also add/override the default metadata. See the wiki for more details. – Holger Just Sep 04 '12 at 10:37