Permalink
Browse files

changes to fix RT 65001, in which LWP::Simple::get is too damned clev…

…er for its own good and breaks .txt.gz files
  • Loading branch information...
1 parent 949d327 commit 8413d34c319a5c51da6cff8db9d02e9118b6b24f @DrHyde committed May 27, 2012
Showing with 51 additions and 31 deletions.
  1. +4 −0 CHANGES
  2. +30 −26 Makefile.PL
  3. +17 −5 lib/CPAN/FindDependencies.pm
View
@@ -1,3 +1,7 @@
+2.4 2012-05-27 Fix for RT 65001, 02packages being corrupted
+ by LWP::Simple::get being too damned clever
+ for its own good
+
2.34 2010-05-29 Parallel testing didn't work on Windows;
SKIP if Makefile.PL times out but shouldn't have
View
@@ -2,33 +2,37 @@ use ExtUtils::MakeMaker;
use Config;
WriteMakefile(
- NAME => 'CPAN::FindDependencies',
- META_MERGE => {
- license => 'other',
- resource => {
- repository => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies'
- }
+ NAME => 'CPAN::FindDependencies',
+ META_MERGE => {
+ license => 'other',
+ resources => {
+ repository => {
+ web => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies'
+ },
+ bugtracker => {
+ web => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies/issues/new'
+ },
},
- VERSION_FROM => 'lib/CPAN/FindDependencies.pm',
- EXE_FILES => [qw(
- examples/cpandeps
- )],
- PREREQ_PM => {
- 'Parse::CPAN::Packages' => 2.31,
- 'Module::CoreList' => 2.12,
- # 'YAML' => 0.61,
- 'YAML::Tiny' => 1.36,
- 'LWP::Simple' => 1.41,
- 'Scalar::Util' => 1.14,
- 'URI::file' => 4.13,
- 'File::Temp' => 0.19,
- 'Capture::Tiny' => 0.05,
- 'Devel::CheckOS' => 1.52,
- },
- dist => {
- DIST_CP => 'cp',
- PREOP => "$Config{perlpath} -Mstrict -Mlib::CPAN::FindDependencies -w shared/doincludes \$(EXE_FILES) \$(TO_INST_PM)"
- }
+ },
+ VERSION_FROM => 'lib/CPAN/FindDependencies.pm',
+ EXE_FILES => [qw(
+ examples/cpandeps
+ )],
+ PREREQ_PM => {
+ 'Parse::CPAN::Packages' => 2.31,
+ 'Module::CoreList' => 2.67,
+ 'YAML::Tiny' => 1.36,
+ 'LWP::UserAgent' => 0,
+ 'Scalar::Util' => 1.14,
+ 'URI::file' => 4.13,
+ 'File::Temp' => 0.19,
+ 'Capture::Tiny' => 0.05,
+ 'Devel::CheckOS' => 1.52,
+ },
+ dist => {
+ DIST_CP => 'cp',
+ PREOP => "$Config{perlpath} -Mstrict -Mlib::CPAN::FindDependencies -w shared/doincludes \$(EXE_FILES) \$(TO_INST_PM)"
+ }
);
# commented out cos doesn't work on Doze
@@ -6,7 +6,7 @@ use strict;
use vars qw($p $VERSION @ISA @EXPORT_OK);
use YAML::Tiny ();
-use LWP::Simple;
+use LWP::UserAgent;
use Module::CoreList;
use Scalar::Util qw(blessed);
use CPAN::FindDependencies::Dependency;
@@ -17,7 +17,7 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(finddeps);
-$VERSION = '2.34';
+$VERSION = '2.4';
use constant DEFAULT02PACKAGES => 'http://www.cpan.org/modules/02packages.details.txt.gz';
use constant MAXINT => ~0;
@@ -142,7 +142,7 @@ L<http://search.cpan.org>
=head1 AUTHOR, LICENCE and COPYRIGHT
-Copyright 2007 - 2010 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
+Copyright 2007 - 2012 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
This software is free-as-in-speech software, and may be used,
distributed, and modified under the terms of either the GNU
@@ -224,10 +224,22 @@ sub _get02packages {
die($@) if($@);
$file = URI::file->new_abs($file);
}
- get($file || DEFAULT02PACKAGES) ||
+ _get($file || DEFAULT02PACKAGES) ||
die(__PACKAGE__.": Couldn't fetch 02packages index file\n");
}
+sub _get {
+ my $url = shift;
+ my $ua = LWP::UserAgent->new();
+ $ua->agent(__PACKAGE__."/$VERSION");
+ my $response = $ua->get($url);
+ if($response->is_success()) {
+ return $response->content();
+ } else {
+ return undef;
+ }
+}
+
sub _incore {
my %args = @_;
my $core = $Module::CoreList::version{$args{perl}}{$args{module}};
@@ -304,7 +316,7 @@ sub _get_file_cached {
$contents = <$cachefh>;
close($cachefh);
} else {
- $contents = get($src);
+ $contents = _get($src);
if($contents && $opts->{cachedir} && -d $opts->{cachedir}) {
open(my $cachefh, '>', $opts->{cachedir}."/$destfile") ||
_emitwarning('Error writing '.$opts->{cachedir}."/$destfile: $!");

0 comments on commit 8413d34

Please sign in to comment.