Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

What Does CPAN Mirror "Freshness Date" Mean?

by awohld (Hermit)
on Sep 10, 2007 at 04:51 UTC ( [id://637990]=perlquestion: print w/replies, xml ) Need Help??

awohld has asked for the wisdom of the Perl Monks concerning the following question:

I was looking at CPAN mirror sites like Hoobly Classifides and its freshness date is May 20th 2007. A lot of other mirrors give the same date.

I read that the mirrors are updated very often.

So what does the "Freshness Date" actually mean?
  • Comment on What Does CPAN Mirror "Freshness Date" Mean?

Replies are listed 'Best First'.
Re: What Does CPAN Mirror "Freshness Date" Mean?
by merlyn (Sage) on Sep 10, 2007 at 05:00 UTC
Re: What Does CPAN Mirror "Freshness Date" Mean?
by CountZero (Bishop) on Sep 10, 2007 at 11:05 UTC
    I read that the mirrors are updated very often.

    That is all a function of the local policy at the mirror site.

    I update my local "minicpan" on my laptop once a day on basis of a mirror which updates itself 2 to 3 times a day. As a rule of thumb I try to link to a mirror which updates not less than about twice as fast as I update my local repository. That way I am pretty sure to get a reasonable "fresh" copy.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: What Does CPAN Mirror "Freshness Date" Mean?
by Intrepid (Deacon) on Sep 10, 2007 at 19:26 UTC

    I've got some code that is not a direct answer to your question but addresses a related concern that CPAN users should have. It regards the freshness of the list of mirrors which gets stored locally when the CPAN setup (init run) first takes place. Due to what I consider a misdesign or missing feature of CPAN, that file is never checked for staleness; thus if you do rerun a setup (cpan> o conf init) some time, you will be presented with a list of mirrors to choose from that may miss some good, recently-added ones that you'd want, or include some now bogus, decommissioned ones that have had their virtual plugs pulled.

    I use this as a shell (bash) function which I run when I feel like it. A more automation-oriented person would likely want to make it into a cron job or something similar.

    #!/usr/bin/env perl use File::stat; use CPAN; use LWP::Simple ("mirror"); use warnings; use strict; CPAN::Config->load; my $fhost; my $mbdata = $CPAN::Config->{keep_source_where}.q[/MIRRORED.BY]; if (-e $mbdata and -M _ < 14) { print qq[$mbdata: freshness is OK, it was last modified: ] . gmtime stat($mbdata)->mtime() } else { ($fhost)=grep(/^http/,@{$CPAN::Config->{urllist}}); die "No suitable cpan http mirror host, aborting. Sorry." unless $ +fhost; printf qq[%s\n%s\n] , qq[File $mbdata not found, or local file may be stale.] , qq[will d/l fresh MIRRORED.BY file from $fhost, please wait +...]; mirror($fhost .q[MIRRORED.BY] , $mbdata) and print q[New MIRRORED.BY file timestamp in UTC: ] . gmtime(stat($mbdata)->mtime) .qq[\n] or die qq[Retrieval of MIRRORED.BY from $fhost FAILED. Sorry +.] }

    Here's the bash-wrapped form of the same code:

    function freshen_MIRROREDBY { perl -MFile::stat -MCPAN -MLWP::Simple=mirror -le ' CPAN::Config->load; my $fhost; my $mbdata = $CPAN::Config->{keep_source_where}.q[/MIRRORED.BY +]; if (-e $mbdata and -M _ < 14) { print qq[$mbdata: freshness is OK, last modified: ] . gmtime stat($mbdata)->mtime() } else { ($fhost)=grep(/^http/,@{$CPAN::Config->{urllist}}); die "No suitable cpan http mirror host, aborting. Sorry." +unless $fhost; printf qq[%s\n%s\n] , qq[File $mbdata not found, or local file may be stale +.] , qq[will d/l fresh MIRRORED.BY file from $fhost, pleas +e wait ...]; mirror($fhost .q[MIRRORED.BY] , $mbdata) and print q[New MIRRORED.BY file timestamp in UTC: ] . gmtime(stat($mbdata)->mtime) . qq[\n] or die qq[Retrieval of MIRRORED.BY from $fhost FAIL +ED. Sorry.] }' }

    I hope this is useful to someone. I don't dare hope that the numerous anal among the Perlmonks readership won't punish the posting of code as usual by finding some petty style mistakes to justify a bitchy downvote orgy.

      Have you suggested adding this feature to Andreas? He's pretty responsive to feedback from users.
Re: What Does CPAN Mirror "Freshness Date" Mean?
by strredwolf (Chaplain) on Sep 10, 2007 at 13:31 UTC

    It's like a sandwich at 7-Eleven. Do you get the one that was made today, or the one that was made three days ago?

    No, you get the one made today because the meat and cheese is fresher. Different 7-Elevens may cycle their goods out at different rates. You can't really tell*.

    Same goes with CPAN mirrors. Do you go for the one that just picked up the hopefully bug-fixed version of Image::Size that was released today (not that it was, only for an example here) or the ones that still have a Flash-related bug in them from two weeks ago?

    * As an aside, I keep going to Asian rim-owned 7-Elevens and get frustrated by the language barrier and general demeanor of the employees. Yet, I go to a few domestic 7-Eleven and get along quite well with the employees. Cultural differences, perhapse.

    --
    $Stalag99{"URL"}="http://stalag99.net";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://637990]
Approved by planetscape
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found