Permalink
Browse files

Fix bundle command, so that it will use .lock to build packages to de…

…termine versions
  • Loading branch information...
miyagawa committed Feb 6, 2013
1 parent f6b5c4c commit 858b7deedc4c28e7cacbd1fc1adf9b1ff5a31a09
Showing with 18 additions and 21 deletions.
  1. +11 −18 lib/Carton.pm
  2. +7 −3 lib/Carton/CLI.pm
View
@@ -36,14 +36,6 @@ sub lock { $_[0]->{lock} }
sub local_mirror { File::Spec->rel2abs("$_[0]->{path}/cache") }
-sub download_from_cpanfile {
- my($self, $cpanfile, $local_mirror) = @_;
-
- my @modules = $self->list_dependencies;
- $self->download_conservative(\@modules, $local_mirror, 1)
- or die "Bundling modules failed\n";
-}
-
sub install_from_cpanfile {
my($self, $file, $cascade) = @_;
@@ -80,30 +72,31 @@ sub dedupe_modules {
return [ reverse @result ];
}
-sub download_conservative {
- my($self, $modules, $dir, $cascade) = @_;
- $modules = $self->dedupe_modules($modules);
+sub download_from_cpanfile {
+ my($self, $cpanfile, $local_mirror) = @_;
+
+ my @modules = $self->list_dependencies;
+ my $modules = $self->dedupe_modules(\@modules);
+
+ my $index = $self->build_index($self->lock->{modules});
+ $self->build_mirror_file($index, $self->{mirror_file});
my $mirror = $self->{mirror} || $DefaultMirror;
local $self->{path} = File::Temp::tempdir(CLEANUP => 1); # ignore installed
$self->run_cpanm(
+ "-v",
"--mirror", $mirror,
"--mirror", "http://backpan.perl.org/", # fallback
+ "--mirror-index", $self->{mirror_file},
"--no-skip-satisfied",
( $mirror ne $DefaultMirror ? "--mirror-only" : () ),
- ( $cascade ? "--cascade-search" : () ),
"--scandeps",
- "--save-dists", $dir,
+ "--save-dists", $local_mirror,
@$modules,
);
-
- # write 02packages using local installations
- my %installs = $self->find_installs;
- my $index = $self->build_index(\%installs);
- $self->build_mirror_file($index, $self->{mirror_file});
}
sub install_conservative {
View
@@ -136,17 +136,21 @@ sub cmd_bundle {
$self->parse_options(\@args, "p|path=s" => sub { $self->carton->{path} = $_[1] });
+ my $lock = $self->find_lock;
my $local_mirror = $self->carton->local_mirror;
$self->carton->configure(
- mirror_file => $self->mirror_file, # $lock object?
+ lock => $lock,
+ mirror_file => $self->mirror_file,
);
- if (my $cpanfile = $self->has_cpanfile) {
+ my $cpanfile = $self->has_cpanfile;
+
+ if ($cpanfile && $lock) {
$self->print("Bundling modules using $cpanfile\n");
$self->carton->download_from_cpanfile($cpanfile, $local_mirror);
} else {
- $self->error("Can't locate build file\n");
+ $self->error("Can't locate cpanfile and lock file. Run carton install first\n");
}
$self->printf("Complete! Modules were bundled into %s\n", $local_mirror, SUCCESS);

0 comments on commit 858b7de

Please sign in to comment.