summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-01 15:49:26 +0900
committerTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-01 15:50:27 +0900
commit7264929d01504a8414e0d41dfd02bfae10420c47 (patch)
tree0d2e50af856039b961160ce6a69b916ba4d451d7
parent5c8f94569d907247926648bb1480ff92fee966ff (diff)
downloadcarton-7264929d01504a8414e0d41dfd02bfae10420c47.tar.gz
use vendor/cache for bundling. Fix #88
-rw-r--r--lib/Carton.pm19
-rw-r--r--lib/Carton/CLI.pm14
-rw-r--r--xt/cli/bundle.t2
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;