Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 8413d34c319a5c51da6cff8db9d02e9118b6b24f 1 parent 949d327
David Cantrell authored May 27, 2012
4  CHANGES
... ...
@@ -1,3 +1,7 @@
  1
+2.4     2012-05-27      Fix for RT 65001, 02packages being corrupted
  2
+                          by LWP::Simple::get being too damned clever
  3
+                          for its own good
  4
+
1 5
 2.34    2010-05-29      Parallel testing didn't work on Windows;
2 6
                         SKIP if Makefile.PL times out but shouldn't have
3 7
 
56  Makefile.PL
@@ -2,33 +2,37 @@ use ExtUtils::MakeMaker;
2 2
 use Config;
3 3
 
4 4
 WriteMakefile(
5  
-    NAME         => 'CPAN::FindDependencies',
6  
-    META_MERGE => {
7  
-        license => 'other',
8  
-        resource => {
9  
-	    repository => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies'
10  
-        }
  5
+  NAME         => 'CPAN::FindDependencies',
  6
+  META_MERGE => {
  7
+    license => 'other',
  8
+    resources => {
  9
+      repository => {
  10
+        web => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies'
  11
+      },
  12
+      bugtracker => {
  13
+        web => 'https://github.com/DrHyde/perl-modules-CPAN-FindDependencies/issues/new'
  14
+      },
11 15
     },
12  
-    VERSION_FROM => 'lib/CPAN/FindDependencies.pm',
13  
-    EXE_FILES    => [qw(
14  
-        examples/cpandeps
15  
-    )],
16  
-    PREREQ_PM    => {
17  
-        'Parse::CPAN::Packages' => 2.31,
18  
-        'Module::CoreList'      => 2.12,
19  
-        # 'YAML'                  => 0.61,
20  
-        'YAML::Tiny'            => 1.36,
21  
-        'LWP::Simple'           => 1.41,
22  
-        'Scalar::Util'          => 1.14,
23  
-        'URI::file'             => 4.13,
24  
-        'File::Temp'            => 0.19,
25  
-        'Capture::Tiny'         => 0.05,
26  
-        'Devel::CheckOS'        => 1.52,
27  
-    },
28  
-    dist => {
29  
-        DIST_CP => 'cp',
30  
-        PREOP => "$Config{perlpath} -Mstrict -Mlib::CPAN::FindDependencies -w shared/doincludes \$(EXE_FILES) \$(TO_INST_PM)"
31  
-    }
  16
+  },
  17
+  VERSION_FROM => 'lib/CPAN/FindDependencies.pm',
  18
+  EXE_FILES    => [qw(
  19
+    examples/cpandeps
  20
+  )],
  21
+  PREREQ_PM    => {
  22
+    'Parse::CPAN::Packages' => 2.31,
  23
+    'Module::CoreList'      => 2.67,
  24
+    'YAML::Tiny'            => 1.36,
  25
+    'LWP::UserAgent'        => 0,
  26
+    'Scalar::Util'          => 1.14,
  27
+    'URI::file'             => 4.13,
  28
+    'File::Temp'            => 0.19,
  29
+    'Capture::Tiny'         => 0.05,
  30
+    'Devel::CheckOS'        => 1.52,
  31
+  },
  32
+  dist => {
  33
+    DIST_CP => 'cp',
  34
+    PREOP => "$Config{perlpath} -Mstrict -Mlib::CPAN::FindDependencies -w shared/doincludes \$(EXE_FILES) \$(TO_INST_PM)"
  35
+  }
32 36
 );
33 37
 
34 38
 # commented out cos doesn't work on Doze
22  lib/CPAN/FindDependencies.pm
@@ -6,7 +6,7 @@ use strict;
6 6
 use vars qw($p $VERSION @ISA @EXPORT_OK);
7 7
 
8 8
 use YAML::Tiny ();
9  
-use LWP::Simple;
  9
+use LWP::UserAgent;
10 10
 use Module::CoreList;
11 11
 use Scalar::Util qw(blessed);
12 12
 use CPAN::FindDependencies::Dependency;
@@ -17,7 +17,7 @@ require Exporter;
17 17
 @ISA = qw(Exporter);
18 18
 @EXPORT_OK = qw(finddeps);
19 19
 
20  
-$VERSION = '2.34';
  20
+$VERSION = '2.4';
21 21
 
22 22
 use constant DEFAULT02PACKAGES => 'http://www.cpan.org/modules/02packages.details.txt.gz';
23 23
 use constant MAXINT => ~0;
@@ -142,7 +142,7 @@ L<http://search.cpan.org>
142 142
 
143 143
 =head1 AUTHOR, LICENCE and COPYRIGHT
144 144
 
145  
-Copyright 2007 - 2010 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
  145
+Copyright 2007 - 2012 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
146 146
 
147 147
 This software is free-as-in-speech software, and may be used,
148 148
 distributed, and modified under the terms of either the GNU
@@ -224,10 +224,22 @@ sub _get02packages {
224 224
         die($@) if($@);
225 225
         $file = URI::file->new_abs($file);
226 226
     }
227  
-    get($file || DEFAULT02PACKAGES) ||
  227
+    _get($file || DEFAULT02PACKAGES) ||
228 228
         die(__PACKAGE__.": Couldn't fetch 02packages index file\n");
229 229
 }
230 230
 
  231
+sub _get {
  232
+    my $url = shift;
  233
+    my $ua = LWP::UserAgent->new();
  234
+    $ua->agent(__PACKAGE__."/$VERSION");
  235
+    my $response = $ua->get($url);
  236
+    if($response->is_success()) {
  237
+        return $response->content();
  238
+    } else {
  239
+        return undef;
  240
+    }
  241
+}
  242
+
231 243
 sub _incore {
232 244
     my %args = @_;
233 245
     my $core = $Module::CoreList::version{$args{perl}}{$args{module}};
@@ -304,7 +316,7 @@ sub _get_file_cached {
304 316
         $contents = <$cachefh>;
305 317
         close($cachefh);
306 318
     } else {
307  
-        $contents = get($src);
  319
+        $contents = _get($src);
308 320
         if($contents && $opts->{cachedir} && -d $opts->{cachedir}) {
309 321
             open(my $cachefh, '>', $opts->{cachedir}."/$destfile") ||
310 322
                 _emitwarning('Error writing '.$opts->{cachedir}."/$destfile: $!");

0 notes on commit 8413d34

Please sign in to comment.
Something went wrong with that request. Please try again.