[CFT] Installing multiple Rubygem port versions from the same directory

Greg Larkin glarkin at FreeBSD.org
Tue May 21 16:14:50 UTC 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greetings,

A while back, I started working on ports for the vagrant
(http://www.vagrantup.com/) and veewee
(https://github.com/jedi4ever/veewee) tools.  At the time, vagrant was
packaged as a Ruby gem with a variety of other gem dependencies.  Some
of the dependencies were already in the ports tree, but they were the
wrong versions.

Gem dependency lists are often very specific regarding acceptable
versions, and the ports tree had a couple of examples of gems that were
duplicated so that different major versions could be used as
dependencies for other ports (e.g. devel/rubygem-json and
devel/rubygem-json146).

I have been working on a way to install any version of a gem from a
single ports tree directory, as well as install multiple simultaneous
versions of the same gem.  I'd like to offer my patches for review,
comments and testing, and you can find them here:

http://people.freebsd.org/~glarkin/diffs/usr-ports-Mk-rubygem-versions.diff
http://people.freebsd.org/~glarkin/diffs/usr-ports-devel-rubygem-port-examples.diff

Both diffs were generated against r318392.  The first one patches
Mk/bsd.ruby.mk and creates Mk/bsd.rubygem-versions.mk.  The second one
patches devel/rubygem-childprocess and devel/rubygem-ffi to show how the
new multi-version support works.

One of the key features in bsd.rubygem-versions.mk is that it creates
additional version-specific targets like "install-1.3.4",
"clean-3.0.19", etc., based on the list of versions for each gem.

Here is the process for adding multi-version support to a gem port:

cd /usr/ports/devel/rubygem-foobar
mkdir -p files      # Or "svn mkdir files", if it doesn't exist
make gem-versions   # Creates the version list helper files
#
# Fix *_DEPENDS in Makefile, if necessary (see below)
#
make install-0.0.6 clean-0.0.6
make install-1.4.5 clean-1.4.5
make install-0.9 clean-0.9
#
# etc...

Since each gem version may need a different dependency list, I added
version-specific *_DEPENDS support like so:

# Using the examples from above:
RUN_DEPENDS006+=   
rubygem-quux123>=1.2.3:${PORTSDIR}/devel/rubygem-quux:install-1.2.3 \
                   
rubygem-bar0019<=0.0.999:${PORTSDIR}/devel/rubygem-bar:install-0.0.19
#
RUN_DEPENDS09+=    
rubygem-quux1210>=1.2.3:${PORTSDIR}/devel/rubygem-quux:install-1.2.10 \
                   
rubygem-quux1210<=1.2.999:${PORTSDIR}/devel/rubygem-quux:install-1.2.10 \
                   
rubygem-bar0019<=0.0.999:${PORTSDIR}/devel/rubygem-bar:install-0.0.19
#
RUN_DEPENDS145+=   
rubygem-quux23<=2.3.999:${PORTSDIR}/devel/rubygem-quux:install-2.3.10 \
                   
rubygem-bar0019<=0.0.999:${PORTSDIR}/devel/rubygem-bar:install-0.0.19 \
                   
rubygem-null222>=1.0.3:${PORTSDIR}/devel/rubygem-null:install-2.2.2

In the first example, the quux gem must be at least version 1.2.3 and
that one is installed.  If version 4.0.10 were available, that would be
acceptable as well.  The bar gem version must be >= 0.0.1 and < 0.1 (cf:
http://docs.rubygems.org/read/chapter/16#page74).  Since there is no
"~>" operator in our depends system yet, I'm manually approximating it
here by testing against and upper version of 0.0.999 and counting on the
port maintainer to call the proper install target for the dependency.

In the second example, quux has a slightly more complex version
requirement, namely ">=1.2.3, ~>1.2".  Any version of quux at least
1.2.3 and less than 1.3 is acceptable.

In the last example, the null gem must be at least version 1.0.3, but
there is no upper bound.  The port maintainer has decided to install
version 2.2.2, which may or may not be the most recent one.

I look forward to your feedback,
Greg

- -- 
Greg Larkin

http://www.FreeBSD.org/           - The Power To Serve
http://www.sourcehosting.net/     - Ready. Set. Code.
http://twitter.com/cpucycle/      - Follow you, follow me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlGbnW4ACgkQ0sRouByUApAJeACcDLLdzpNuGH4KYikgzB0+VW78
ekYAn3orS0K7MemO1RKYINUEs5G9fKcp
=nc9B
-----END PGP SIGNATURE-----



More information about the freebsd-ruby mailing list