[carton] 240/472: Fixed the way to build the list of mirrors.

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit 5739372621f57e19b01cd0b0dbb47aeb89dabdac
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Sat Jun 1 14:54:15 2013 +0900

    Fixed the way to build the list of mirrors.
    
    Always use public CPAN as a fallback, even before BackPAN, so that
    modules not found in DarkPAN will go through looking up CPAN anyway.
    
    Stop cascading in bundle command since the lock file should have
    everything in theory.
---
 lib/Carton.pm | 35 +++++++++++++++++++----------------
 xt/CLI.pm     |  2 +-
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/lib/Carton.pm b/lib/Carton.pm
index a2bb038..6d2458d 100644
--- a/lib/Carton.pm
+++ b/lib/Carton.pm
@@ -34,22 +34,34 @@ sub local_cache {
     File::Spec->rel2abs("$_[0]->{path}/cache");
 }
 
+sub effective_mirrors {
+    my $self = shift;
+
+    # push default CPAN mirror always, as a fallback
+    my @mirrors = ($self->{mirror});
+    push @mirrors, $DefaultMirror if $self->use_darkpan;
+    push @mirrors, 'http://backpan.perl.org/';
+
+    @mirrors;
+}
+
+sub use_darkpan {
+    my $self = shift;
+    $self->{mirror} ne $DefaultMirror;
+}
+
 sub bundle {
     my($self, $cpanfile, $lock) = @_;
 
     $lock->write_index($self->{mirror_file});
 
-    my $mirror = $self->{mirror} || $DefaultMirror;
     my $local_cache = $self->local_cache; # because $self->{path} is localized
     local $self->{path} = File::Temp::tempdir(CLEANUP => 1); # ignore installed
 
     $self->run_cpanm(
-        "--mirror", $mirror,
-        "--mirror", "http://backpan.perl.org/", # fallback
+        (map { ("--mirror", $_) } $self->effective_mirrors),
         "--mirror-index", $self->{mirror_file},
         "--skip-satisfied",
-        "--cascade-search",
-        ( $mirror ne $DefaultMirror ? "--mirror-only" : () ),
         "--save-dists", $local_cache,
         "--installdeps", ".",
     );
@@ -63,21 +75,12 @@ sub install {
         $lock->write_index($self->{mirror_file});
     }
 
-    my $mirror = $self->{mirror} || $DefaultMirror;
-
-    my $is_default_mirror = 0;
-    if ( !ref $mirror ) {
-        $is_default_mirror = $mirror eq $DefaultMirror ? 1 : 0;
-        $mirror = [split /,/, $mirror];
-    }
-
     $self->run_cpanm(
-        (map { ("--mirror", $_) } @{$mirror}),
-        "--mirror", "http://backpan.perl.org/", # fallback
+        (map { ("--mirror", $_) } $self->effective_mirrors),
         "--skip-satisfied",
-        ( $is_default_mirror ? () : "--mirror-only" ),
         ( $lock ? ("--mirror-index", $self->{mirror_file}) : () ),
         ( $cascade ? "--cascade-search" : () ),
+        ( $self->use_darkpan ? "--mirror-only" : () ),
         "--installdeps", ".",
     ) or die "Installing modules failed\n";
 }
diff --git a/xt/CLI.pm b/xt/CLI.pm
index 27ef0eb..c72191a 100644
--- a/xt/CLI.pm
+++ b/xt/CLI.pm
@@ -6,7 +6,7 @@ our @EXPORT = qw(run cli);
 use Test::Requires qw( Directory::Scratch Capture::Tiny File::pushd );
 
 sub cli {
-    my $dir = Directory::Scratch->new();
+    my $dir = Directory::Scratch->new(CLEANUP => !$ENV{NO_CLEANUP});
     Carton::CLI::Tested->new(dir => $dir);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git



More information about the Pkg-perl-cvs-commits mailing list