January, 2008

Jan 08

Creating RubyGems .debs for Maemo

I’m writing an application (more on that sometime soon) using the very nice Ruby bindings for Maemo. I’ve got some dependencies that are packaged as RubyGems that I wanted to be managed through the Application Manager, so I created some .debs for them. Here is their temporary home The rake, hpricot, feed-normalizer, simple-rss, atom and htmlentities gems are available in my repository. I didn’t create the rubygems and librubygems packages themselves – I was sent them, but couldn’t find them hosted elsewhere.

It took me a little while to suss out how to create the .debs so I’ve included the steps here in case anyone finds themselves in the same boat. This works for native Ruby gems and compiled C extensions.

  1. Install the gem inside Scratchbox. Irritatingly, “gem install example” doesn’t always want to do very much, so you may need to dowload the gem file and “gem install example-0.1.gem”.
  2. Make a new directory with the rubygems-<package>-<version> syntax (the rubygems- prefix seemed to make sense to me): mkdir rubygems-example-0.1
  3. cd rubygems-example-0.1/ ; mkdir gems specifications bin
  4. cp -r /targets/CHINOOK_ARMEL/var/lib/gems/1.8/gems/example-0.1/ gems
  5. cp /targets/CHINOOK_ARMEL/var/lib/gems/1.8/specifications/example-0.1.gemspec specifications/
  6. cp /targets/CHINOOK_ARMEL/var/lib/gems/1.8/bin/example bin/ (if there are any bins)
  7. Create a Makefile with this content (you will need to replace the spaces at the start of the lines with tabs):
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/gems/
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/bin/     <------ REMOVE THIS LINE IF THERE ARE NO BINS
            mkdir -p $(DESTDIR)/var/lib/gems/1.8/specifications/
            cp -r gems/* $(DESTDIR)/var/lib/gems/1.8/gems/
            cp bin/* $(DESTDIR)/var/lib/gems/1.8/bin/     <------ REMOVE THIS LINE IF THERE ARE NO BINS
            cp specifications/* $(DESTDIR)/var/lib/gems/1.8/specifications/
  8. dh_make -e you@example.com then choose the type of package.
  9. Edit debian/control to suit. Make sure the section is something like user/Utilities, not just Utilities if you want the package to show in the Application Manager.
  10. dpkg-buildpackage -rfakeroot -b
  11. The parent directory should now contain rubygems-example_0.1-1_armel.deb

As a final note, /var/lib/gems/1.8/bin/ may not be in $PATH, so you'll need to deal with that if you have files in bin/.