[ANN] Archive 0.1 and version.rb


Both modules are also included in the (to be released) development
version of rpkg.



Parses and compares version strings like '0.1.0-20021010',

Examples from the tests:

  v = Version['0.1.0']
  assert [0, 1, 0], v.to_a
  assert_equal 0, v[0]
  assert_equal 1, v[1]
  assert_equal 0, v[2]

  v = Version['0.1.0-20021099']
  assert_equal 20021099, v[3]

  v = Version['0.1.4-unstable']
  assert_equal 'unstable', v[3]

  v1 = Version['0.1.0']
  v2 = Version['']
  assert v2 > v1

  v1 = Version['0.1.0']
  v2 = Version['0.1.0-20021010']
  assert v2 > v1
  v1 = Version['0.1.0']
  v2 = Version['0.1.0-unstable']
  assert v2 > v1

archive-0.1.tar.gz (from the notes):

= What is it

A framework for reading, modifying and writing archive and
archive-like files through a uniform interface.

= How it works

The following gets a reader for an archive file of type ArcType
(e.g. Mbox, Tar, Ar…)

io = File.open(‘archive’)
reader = Archive::Reader::ArcType.new(io)

The following iterates over the archive, returning each entry as it
is found.

reader.scan do |entry|


The following scans the archive and returns a modifiable
representation of it.

entries = reader.scan

The following iterates over the archive and builds no representation
of it (i.e. sequential access only).

reader.scan(false) do |entry|


The following writes the (possibly modified) representation to disk.

io = File.open(‘target’)
writer = Archive::Writer::ArcType.new(io)
entries.each do |entry|

The following is a shortcut for the previous.

io = File.open(‘target’)
Archive::Writer::ArcType.write(io, entries)

Currently supported archive types are ar, mbox, and rpkg (or Debian)
archive format.



Massimiliano Mirra wrote:


Both modules are also included in the (to be released) development
version of rpkg.

Very cool, Massimiliano.

Say, I thought I’d take our private conversation public, and a little

We’d been talking about the difference between Debians package management
system and Gentoo’s Portage. Since rpkg is a port of Debian’s system, I’ll
refer to it instead of .deb.

There’s one other thing that I’d like to see in a package management system:
sparse updates.

In Portage, everything is compiled on the client; binaries are allowed, but
discouraged. rpkg will allow you to compile on the client, but the primary
distribution mode is binary. One thing that neither of these systems
support is sparse updates. A sparse update is like rsync, CVS, or unison.
You only get the diffs between files. This would reduce network traffic in
the vast majority of source-based distributions; it probably wouldn’t help
binary-based distributions too much. However, practically all Ruby
packages are distributed as source; either they’re Ruby code, or they have
some native component that is compiled on the client.

Consider a hypothetical system. I use CVS here because CVS is extremely
common as a source repository, and CVS clients for practically every OS.

    1) 'cvs checkout' project.
    2) Make a tarball from checkout directory.
    3) Build and install.
    4) Delete build directory

    1) Unpack previous tarball
    2) 'cvs up -z3' the directory
    3) Rebuild tarball
    3) Build and install
    4) Delete build directory

Rather than downloading a binary in which only a couple of files may have
changed, we sparsely download only the diffs.

An alternative for Ruby that I was considering for a while was using rsync
to directly upgrade a package, but this would only work for pure Ruby
projects, and would require that the software source supply an rsync
server, which is much less common than CVS.


… “Put your hand on a hot stove for a minute and it seems like an
<|> hour. Sit with a pretty girl for an hour and it seems like a
/|\ minute. THAT’s relativity.”
/| – Albert Einstein