[carton] 242/472: use vendor/cache for bundling. Fix #88

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 7264929d01504a8414e0d41dfd02bfae10420c47
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Sat Jun 1 15:49:26 2013 +0900

    use vendor/cache for bundling. Fix #88
---
 lib/Carton.pm     | 19 +++++++------------
 lib/Carton/CLI.pm | 14 +++++---------
 xt/cli/bundle.t   |  2 +-
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/lib/Carton.pm b/lib/Carton.pm
index 6d2458d..91582d5 100644
--- a/lib/Carton.pm
+++ b/lib/Carton.pm
@@ -25,20 +25,16 @@ sub new {
     }, $class;
 }
 
-sub use_local_mirror {
-    my $self = shift;
-    $self->{mirror} = $self->local_cache;
-}
-
 sub local_cache {
-    File::Spec->rel2abs("$_[0]->{path}/cache");
+    File::Spec->rel2abs("vendor/cache");
 }
 
 sub effective_mirrors {
-    my $self = shift;
+    my($self, $cached) = @_;
 
     # push default CPAN mirror always, as a fallback
-    my @mirrors = ($self->{mirror});
+    my @mirrors;
+    push @mirrors, ($cached ? $self->local_cache : $self->{mirror});
     push @mirrors, $DefaultMirror if $self->use_darkpan;
     push @mirrors, 'http://backpan.perl.org/';
 
@@ -55,20 +51,19 @@ sub bundle {
 
     $lock->write_index($self->{mirror_file});
 
-    my $local_cache = $self->local_cache; # because $self->{path} is localized
     local $self->{path} = File::Temp::tempdir(CLEANUP => 1); # ignore installed
 
     $self->run_cpanm(
         (map { ("--mirror", $_) } $self->effective_mirrors),
         "--mirror-index", $self->{mirror_file},
         "--skip-satisfied",
-        "--save-dists", $local_cache,
+        "--save-dists", $self->local_cache,
         "--installdeps", ".",
     );
 }
 
 sub install {
-    my($self, $file, $lock, $cascade) = @_;
+    my($self, $file, $lock, $cascade, $cached) = @_;
 
     # TODO merge CPANfile git to mirror even if lock doesn't exist
     if ($lock) {
@@ -76,7 +71,7 @@ sub install {
     }
 
     $self->run_cpanm(
-        (map { ("--mirror", $_) } $self->effective_mirrors),
+        (map { ("--mirror", $_) } $self->effective_mirrors($cached)),
         "--skip-satisfied",
         ( $lock ? ("--mirror-index", $self->{mirror_file}) : () ),
         ( $cascade ? "--cascade-search" : () ),
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index 301b461..6f4a62c 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -159,25 +159,21 @@ sub cmd_install {
     $self->parse_options(
         \@args,
         "p|path=s"    => sub { $self->carton->{path} = $_[1] },
-        "deployment!" => \$self->{deployment},
-        "cached!"     => \$self->{use_local_mirror},
+        "deployment!" => \my $deployment,
+        "cached!"     => \my $cached,
     );
 
     $self->carton->{mirror_file} = $self->mirror_file;
 
-    if ($self->{use_local_mirror}) {
-        $self->carton->use_local_mirror;
-    }
-
     my $lock = $self->find_lock;
     my $cpanfile = $self->find_cpanfile;
 
-    if ($self->{deployment}) {
+    if ($deployment) {
         $self->print("Installing modules using $cpanfile (deployment mode)\n");
-        $self->carton->install($cpanfile, $lock);
+        $self->carton->install($cpanfile, $lock, 0, $cached);
     } else {
         $self->print("Installing modules using $cpanfile\n");
-        $self->carton->install($cpanfile, $lock, 1);
+        $self->carton->install($cpanfile, $lock, 1, $cached);
         $self->carton->update_lock_file($self->lock_file);
     }
 
diff --git a/xt/cli/bundle.t b/xt/cli/bundle.t
index 0762764..2469291 100644
--- a/xt/cli/bundle.t
+++ b/xt/cli/bundle.t
@@ -12,7 +12,7 @@ EOF
     $app->run("install");
     $app->run("bundle");
 
-    ok -f ($app->dir . "/local/cache/authors/id/D/DO/DOY/Try-Tiny-0.12.tar.gz");
+    ok -f ($app->dir . "/vendor/cache/authors/id/D/DO/DOY/Try-Tiny-0.12.tar.gz");
 }
 
 done_testing;

-- 
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