2006-10-06 (Fri)

_ Converting Gems to Debs

I have set up some scripts [1] that automatically convert gems (*.gem) in rubyforge.org to Debian packages (*.deb). The current way is not complete at all, but it just works. The packages are available, adding the following lines to your /etc/apt/sources.list :

deb     http://debian.sgtpepper.net/ experimental main 
deb-src http://debian.sgtpepper.net/ experimental main 

Of 866 gems in rubyforge, 767 are converted, including 79 binary gems. You can see them by $ apt-cache search rubygems-.

The Debian package generated is named rubygems-<gem_name>.deb. It just wraps the gem. In other words, installing it by aptitude (apt-get) is very equal to installing the gem by the gem command (i.e. $ sudo gem install <gem_name>). Rubygems package has been in the Debian experimental distribution [2]. If you use it and be happy with it (I hope so), you might feel no advantage.

All of the files in the converted packages are installed under /var/lib/gems. You might expect that library files and executables go to /usr/lib/ruby/1.8 and /usr/bin respectively. But as of now this can not be done.

Gems shipped only with Ruby code, called pure ruby gems, are converted fine. However, what include C extensions, called binary gems, would not because the spec file of Rubygems does not have capability to specify library dependencies --- even if so, they would not always match names of Debian's packages. My scripts have a hook to write dependencies of each gem. Since it has to be done manually, few gems are supported now (some happen to be successfully built without explicit dependencies because the server already has them, which would not work on your box). Actually, I am not willing to cover binary gems. They --- of cource, as well as pure ruby gems --- should be debianized in a proper way by Debian developers. Anyway, there is a hook. If you send me a patch, it will be applied.

Props:

1. You can manage packages by aptitude (apt-get) that you would be more familiar with to install gems, instead of the gem command.

2. Some binary gems are built, meaning that you can install them without compiling at your box. Sorry, the architecture supported currently is only amd64.

Cons:

1. My service might not last forever.

2. Most binary gems are not supported.

3. You can not install multiple versions of the gem. The old version of the gem will be replaced by the new one as aptitude (apt-get) usually does.

Footnotes:

[1] They exist in pkg-ruby-extras's svn repository (tools/gemsd/*). Thanks to Akira Yamada who made dh_rubygems.rb to convert a gem to a deb and Marcus Rueckert who made a patch for rubygems --build-root option.

[2] Adding the apt lines that follows, install rubygems package.

deb http://ftp.debian.org/debian/ experimental main contrib non-free
deb http://ftp.debian.org/debian/ experimental main contrib non-free
[]