gem2rpm is a simple utility that transforms rubygems GEM format packages into the equivalent RPM packages.
I manage several Linux-based servers and I already spent time making sure that the machines have a local update server, automatically get updates, are monitored, etc. The whole system uses yum and rpm to do its work. I distribute my own software to these machines as rpms.
The problem I had was specifying dependencies between non-ruby and ruby software. If I had a tool that required rake to build it, there was no way to encode that in the RPM spec file. With gems installed via gem2rpm the dependencies can once again be fully specified in rpms.
Easy:
gzip -d gem2rpm.gz
. chmod 755 gem2rpm
.
/usr/local/bin
or your personal
bin
directory. Once you're set up, do gem2rpm
your-gem-file-here.gem
. This will build an RPM that
does mostly what you want.
To get set up, you'll need an RPM build tree. If you're running a recent Fedora Core release, you can create $HOME/rpmbuild like so:
sudo yum install fedora-rpmdevtools fedora-buildrpmtree
Otherwise you can build as root (not recommended) or read up about how to set up a non-root rpm build tree. The simplest way to do this is like so:
mkdir $HOME/rpmbuild cp -r /usr/src/redhat/* $HOME/rpmbuild echo "%_topdir %(echo $HOME)/rpmbuild" >> $HOME/.rpmmacros
gem2rpm normally requires rubygems to function. This creates a chicken and egg problem. gem2rpm includes code to make an rpm from rubygems, which is not normally distributed as a gem. To bootstrap the system, assuming you have an rpm build tree in $HOME/rpmbuild, do:
gem2rpm -a noarch -g 'System Environment/Base' rubygems-0.9.0.tgz
sudo rpm -ivh $HOME/rpmbuild/RPMS/noarch/rubygems-0.9.0-1.noarch.rpm
Or if you're impatient, I keep an rpm of rubygems around too (rubygems-0.9.0-1.noarch.rpm). A big thanks go to Jim Weirich for creating such a useful tool.
* Sun Apr 02 2006 Jim Weirich- 0.7.1-1 - rake release 0.7.1.
This changelog entry in effect considers gem2rpm to be mere translation of one package format into another. There's no way to specify an ongoing log of changes as a repackager.
(In no particular order):
gem2rpm
package
and gem will fetch the gem in the usual way and have
gem2rpm build an rpm from it. platform
or
extensions
attributes. These should make the -a
command-line option redundant.
required_ruby_version
to generate the correctly versioned
ruby dependency for the package. Currently the dependency is on ruby
alone. %{parent}-%{child}
. Addons
are defined as:
If a new package is considered an "addon" package that enhances or adds a new functionality to an existing Fedora Core or Fedora Extras package without being useful on its own, its name should reflect this fact.
For perl, you see packages like perl-String-CRC32
,
which includes the String::CRC32
library. It should be
straightforward to determine generate similar package names for ruby
libraries, e.g. ruby-activerecord.
While it's easy to determine if a package includes only library code, it's not easy to figure out if a whether or not a dependency within a dependent package depends on an addon package. For example, looking at activerecord*.gem, it's clear that this is a library and should therefore be called ruby-activerectord*.rpm. It's not clear, when looking at the dependencies for rails that activerecord was a library only. Rubygems only says that rails depends on activerecord.
There's not a whole lot to be done about this without some kind of global knowledge. For the moment, the gem2rpm package names match the rubygems names rather than the external packagers' standards.
Contact Gil <gil (at) fooplanet (dot) com> with comments, feedback, patches, or suggestions.