Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add --download command #118

Open
wants to merge 1 commit into from

8 participants

@perlancar

--download command is used for downloading tarballs only, without
building/installing. Internally, it sets --save-dists=$CWD if --save-dists is
not specified.

Steven Haryanto (on PC) Add --download command
--download command is used for downloading tarballs only, without
building/installing. Internally, it sets --save-dists=$CWD if --save-dists is
not specified.
707ad11
@vti

If we can vote here, I vote +1.

@miyagawa
Owner

@masaki if we merge this patch I guess Carton's bundle command doesn't need to install deps?

@masaki

@miyagawa this logic returns before build_stuff() which contains "scandeps", so I guess cpanm cannot fetch dependency modules and Carton cannot bundle completely.

@miyagawa
Owner

right, so we need to download while scanning deps, which I think needs to install into a temporary path anyway.

@yanick

Just want to add my voice to the +1 crowd. This option would be quite useful for quick module retrieval...

@zebardy

:+1: +1 from me as well :). This would allow for perl-carton/carton#168 to be implemented. What is the status of this? Any changes/discussions needed to help push this issue forward?

@perlpunk

I'd love to see this, too

@sni

would be great to get this into upstream. Exactly what i need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 30, 2011
  1. Add --download command

    Steven Haryanto (on PC) authored
    --download command is used for downloading tarballs only, without
    building/installing. Internally, it sets --save-dists=$CWD if --save-dists is
    not specified.
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/App/cpanminus/script.pm
View
18 lib/App/cpanminus/script.pm
@@ -104,6 +104,7 @@ sub parse_options {
'i|install' => sub { $self->{cmd} = 'install' },
'info' => sub { $self->{cmd} = 'info' },
'look' => sub { $self->{cmd} = 'look'; $self->{skip_installed} = 0 },
+ 'download' => sub { $self->{cmd} = 'download'; $self->{skip_installed} = 0 },
'self-upgrade' => sub { $self->{cmd} = 'install'; $self->{skip_installed} = 1; push @ARGV, 'App::cpanminus' },
'uninst-shadows!' => \$self->{uninstall_shadows},
'lwp!' => \$self->{try_lwp},
@@ -120,6 +121,10 @@ sub parse_options {
'skip-configure!' => \$self->{skip_configure},
);
+ if ($self->{cmd} eq 'download' && !$self->{save_dists}) {
+ $self->{save_dists} = $self->maybe_abs(Cwd::cwd);
+ }
+
if (!@ARGV && $0 ne '-' && !-t STDIN){ # e.g. # cpanm < author/requires.cpanm
push @ARGV, $self->load_argv_from_fh(\*STDIN);
$self->{load_from_stdin} = 1;
@@ -415,6 +420,7 @@ Commands:
--self-upgrade upgrades itself
--info Displays distribution info on CPAN
--look Opens the distribution with your SHELL
+ --download Only download tarballs
-V,--version Displays software version
Examples:
@@ -428,6 +434,7 @@ Examples:
cpanm --installdeps . # install all the deps for the current directory
cpanm -L extlib Plack # install Plack and all non-core deps into extlib
cpanm --mirror http://cpan.cpantesters.org/ DBI # use the fast-syncing mirror
+ cpanm --download CGI Data::FormValidator # only download tarballs (to --save-dists or .)
You can also specify the default options in PERL_CPANM_OPT environment variable in the shell rc:
@@ -893,6 +900,10 @@ sub install_module {
$dist->{dir} ||= $self->fetch_module($dist);
+ if ($self->{cmd} eq 'download') {
+ return 1;
+ }
+
unless ($dist->{dir}) {
$self->diag_fail("Failed to fetch distribution $dist->{distvname}", 1);
return;
@@ -966,7 +977,12 @@ sub fetch_module {
if (my $save = $self->{save_dists}) {
my $path = "$save/authors/id/$dist->{pathname}";
- $self->chat("Copying $name to $path\n");
+ my $msg = "Copying $name to $path\n";
+ if ($self->{cmd} eq 'download') {
+ $self->diag($msg);
+ } else {
+ $self->chat($msg);
+ }
File::Path::mkpath([ File::Basename::dirname($path) ], 0, 0777);
File::Copy::copy($file, $path) or warn $!;
}
Something went wrong with that request. Please try again.