From: Vincent Pit Date: Mon, 5 Nov 2012 18:03:51 +0000 (-0200) Subject: Always use CPAN::Perl::Releases in the update script X-Git-Tag: v0.04~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=09ba6ffc4e2a17a9d256b90527e29c4bf0c7bdc0;p=perl%2Fmodules%2Fre-engine-Hooks.git Always use CPAN::Perl::Releases in the update script --- diff --git a/src/update.pl b/src/update.pl index fb4c25c..63d3bff 100644 --- a/src/update.pl +++ b/src/update.pl @@ -14,6 +14,7 @@ use Scalar::Util; use Time::HiRes; use Module::CoreList; +use CPAN::Perl::Releases; use version; use LWP::UserAgent; @@ -25,15 +26,6 @@ BEGIN { select $old_fh; } -my $has_cpan_perl_releases; -BEGIN { - local $@; - if (eval { require CPAN::Perl::Releases; 1 }) { - print "Will use CPAN::Perl::Releases\n"; - $has_cpan_perl_releases = 1; - } -} - my %opts; getopts('ft:m:', \%opts); @@ -195,31 +187,13 @@ sub fetch_uri { sub perl_archive_for { my $version = shift; - my $path; - - if ($has_cpan_perl_releases) { - my $tarballs = CPAN::Perl::Releases::perl_tarballs($version); - - if (defined $tarballs) { - $path = $tarballs->{'tar.gz'}; - } - } else { - my $uri = "http://search.cpan.org/dist/perl-$version"; + my $tarballs = CPAN::Perl::Releases::perl_tarballs($version); + my $path = $tarballs->{'tar.gz'}; + die "Could not find the archive for perl $version" unless defined $path; - local $_; - fetch_uri($uri => \$_); + my ($file) = ($path =~ m{([^/]*)$}); - if (m{id/(([^/])/\2([^/])/\2\3[^/]*/perl-\Q$version\E\.tar\.(?:gz|bz2))}) { - $path = $1; - } - } - - if (defined $path) { - my ($file) = ($path =~ m{([^/]*)$}); - return "http://$cpan_mirror/authors/id/$path", $file; - } else { - die "Could not infer the archive for perl $version"; - } + return "http://$cpan_mirror/authors/id/$path", $file; } sub bandwidth {