On Mon, May 23, 2011 at 11:52:39AM -0700, Jeffrey Thalhammer wrote:

> After looking at David Wheeler's PGXN and David Cantrell's CPAN snapshots, 
> I've come up with a story.  Tell me if you think this makes sense (or not):
> 
> Historically, CPAN mirrors have always been static files.  In other words, 
> the paths in the 02packages file always pointed directly to some physical 
> file on disk.  This made it possible to access mirrors the with the older 
> ftp:// and file:// protocols supported by CPAN.pm.  It also made 
> synchronizing the mirrors easy with tools like rsync.
> 
> This has worked well for a long time.  But the need to support older 
> protocols limits the flexibility of a CPAN mirror.  If you drop support for 
> ftp:// and file://, and just focus on http:// then things can become more 
> interesting.  This open the door for a CPAN server (like the PGXN::Manager) 
> that can do all sorts of things.

Your mirror only has to support file:// if you want it to live on a
user's local disk, and only has to support ftp:// if you want to give
FTP access.  I realise that this is obvious, but please bear with me :-)

You can support whatever craziness you want over HTTP.

The only place in CPAN::Config which mentions the mirror's URL is this:
  urllist => [q[http://cp5.6.2an.barnyard.co.uk/]],

Crucially, it derives URLs for both the index and the distributions from
that.  So, if you have a magic mirror and are willing to do the heavy
lifting on the server (and please bear in mind it's *very* heavy lifting -
my daily rebuilds of static 02packages files take about 7 hours, and
to build a mirror like cp2011-05an takes about 12 hours) you could
simply configure CPAN.pm to use:
  urllist => [q[http://example.com/perl/5.8.8/asat/2008-05-04Z11:43:22]],

CPAN.pm would then get its index by requesting:
  
http://example.com/perl/5.8.8/asat/2008-05-04Z11:43:22/modules/02packages.details.txt.gz

and you can, of course, construct whatever the hell you want in
response, provided it has the right format.  That file would normally
read something like ...

  Description: This is a whitespace-seperated file.
  Description: Each line is modulename moduleversion filename.
  Line-Count: 33800
  Last-Updated: Tue, 24 May 2011 06:22:15 GMT
  
  AAAA::Crypt::DH 0.04 B/BI/BINGOS/AAAA-Crypt-DH-0.04.tar.gz
  ABI 1.0 M/MA/MALAY/ABI-1.0.tar.gz
  ACH::Builder 0.03 T/TK/TKEEFER/ACH-Builder-0.03.tar.gz
  ACME::Error 0.03 C/CW/CWEST/ACME-Error-0.03.tar.gz

but there's no reason why the meat of it couldn't be stuff like ...

  AAAA::Crypt::DH 99999999 distcontaining/AAAA::Crypt::DH

which CPAN.pm would resolve to ...

  
http://example.com/perl/5.8.8/asat/2008-05-04Z11:43:22/authors/id/distcontaining/AAAA::Crypt::DH

which, apart from the annoying 'authors/id/' in the middle, which could
be trivially dealt with using mod_rewrite, looks deliciously RESTish.

-- 
David Cantrell | Reality Engineer, Ministry of Information

  Your call is important to me.  To see if it's important to
  you I'm going to make you wait on hold for five minutes.
  All calls are recorded for blackmail and amusement purposes.

Reply via email to