Carton

 view release on metacpan or  search on metacpan

lib/Carton/Builder.pm  view on Meta::CPAN

package Carton::Builder;
use strict;
use Class::Tiny {
    mirror => undef,
    index  => undef,
    cascade => sub { 1 },
    without => sub { [] },
    cpanfile => undef,
};

sub effective_mirrors {
    my $self = shift;

    # push default CPAN mirror always, as a fallback
    # TODO don't pass fallback if --cached is set?

lib/Carton/Builder.pm  view on Meta::CPAN

    }
}

sub install {
    my($self, $path) = @_;

    $self->run_install(
        "-L", $path,
        (map { ("--mirror", $_->url) } $self->effective_mirrors),
        ( $self->index ? ("--mirror-index", $self->index) : () ),
        ( $self->cascade ? "--cascade-search" : () ),
        ( $self->custom_mirror ? "--mirror-only" : () ),
        "--save-dists", "$path/cache",
        $self->groups,
        "--cpanfile", $self->cpanfile,
        "--installdeps", $self->cpanfile->dirname,
    ) or die "Installing modules failed\n";
}

sub groups {
    my $self = shift;

lib/Carton/CLI.pm  view on Meta::CPAN

    );

    my $env = Carton::Environment->build($cpanfile_path, $install_path);
    $env->snapshot->load_if_exists;

    if ($deployment && !$env->snapshot->loaded) {
        $self->error("--deployment requires cpanfile.snapshot: Run `carton install` and make sure cpanfile.snapshot is checked into your version control.\n");
    }

    my $builder = Carton::Builder->new(
        cascade => 1,
        mirror  => $self->mirror,
        without => \@without,
        cpanfile => $env->cpanfile,
    );

    # TODO: --without with no .lock won't fetch the groups, resulting in insufficient requirements

    if ($deployment) {
        $self->print("Installing modules using @{[$env->cpanfile]} (deployment mode)\n");
        $builder->cascade(0);
    } else {
        $self->print("Installing modules using @{[$env->cpanfile]}\n");
    }

    # TODO merge CPANfile git to mirror even if lock doesn't exist
    if ($env->snapshot->loaded) {
        my $index_file = $env->install_path->child("cache/modules/02packages.details.txt");
           $index_file->parent->mkpath;

        $env->snapshot->write_index($index_file);

lib/Carton/Doc/Install.pod  view on Meta::CPAN


=back

If you run C<carton install> for the first time
(i.e. I<cpanfile.snapshot> does not exist), carton will fetch all the
modules specified, resolve dependencies and install all required
modules from CPAN.

If I<cpanfile.snapshot> file does exist, carton will still try to install
modules specified or updated in I<cpanfile>, but uses I<cpanfile.snapshot>
for the dependency resolution, and then cascades to CPAN.

carton will analyze all the dependencies and their version
information, and it is saved into I<cpanfile.snapshot> file. It is important
to add I<cpanfile.snapshot> file into a version controlled repository and
commit the changes as you update your dependencies.

=head2 DEPLOYMENT MODE

If you specify the C<--deployment> command line option or the
I<cpanfile.snapshot> exists, carton will only use the dependencies



( run in 0.472 second using v1.01-cache-2.11-cpan-49f99fa48dc )