« lib/CPANPLUS/Internals/Source/Memory.pm
↑ Summary
blib/lib/CPANPLUS/Internals/Source/SQLite/Tie.pm »
| 1 | package CPANPLUS::Dist::Autobundle; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use CPANPLUS::Error qw[error msg]; | ||
| 6 | use Params::Check qw[check]; | ||
| 7 | use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; | ||
| 8 | use vars qw[$VERSION]; | ||
| 9 | $VERSION = "0.9912"; | ||
| 10 | |||
| 11 | use base qw[CPANPLUS::Dist::Base]; | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | CPANPLUS::Dist::Autobundle - distribution class for installation snapshots | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | $modobj = $cb->parse_module( module => 'file://path/to/Snapshot_XXYY.pm' ); | ||
| 20 | $modobj->install; | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | C<CPANPLUS::Dist::Autobundle> is a distribution class for installing installation | ||
| 25 | snapshots as created by C<CPANPLUS>' C<autobundle> command. | ||
| 26 | |||
| 27 | All modules as mentioned in the snapshot will be installed on your system. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub init { | ||
| 32 | my $dist = shift; | ||
| 33 | my $status = $dist->status; | ||
| 34 | |||
| 35 | $status->mk_accessors( | ||
| 36 | qw[prepared created installed _prepare_args _create_args _install_args _metadata] | ||
| 37 | ); | ||
| 38 | |||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | sub prepare { | ||
| 43 | my $dist = shift; | ||
| 44 | my %args = @_; | ||
| 45 | |||
| 46 | ### store the arguments, so ->install can use them in recursive loops ### | ||
| 47 | $dist->status->_prepare_args( \%args ); | ||
| 48 | |||
| 49 | return $dist->status->prepared( 1 ); | ||
| 50 | } | ||
| 51 | |||
| 52 | sub create { | ||
| 53 | my $dist = shift; | ||
| 54 | my $self = $dist->parent; | ||
| 55 | |||
| 56 | ### we're also the cpan_dist, since we don't need to have anything | ||
| 57 | ### prepared | ||
| 58 | $dist = $self->status->dist_cpan if $self->status->dist_cpan; | ||
| 59 | $self->status->dist_cpan( $dist ) unless $self->status->dist_cpan; | ||
| 60 | |||
| 61 | my $cb = $self->parent; | ||
| 62 | my $conf = $cb->configure_object; | ||
| 63 | my %hash = @_; | ||
| 64 | |||
| 65 | my( $force, $verbose, $prereq_target, $prereq_format, $prereq_build); | ||
| 66 | |||
| 67 | my $args = do { | ||
| 68 | local $Params::Check::ALLOW_UNKNOWN = 1; | ||
| 69 | my $tmpl = { | ||
| 70 | force => { default => $conf->get_conf('force'), | ||
| 71 | store => \$force }, | ||
| 72 | verbose => { default => $conf->get_conf('verbose'), | ||
| 73 | store => \$verbose }, | ||
| 74 | prereq_target => { default => '', store => \$prereq_target }, | ||
| 75 | |||
| 76 | ### don't set the default prereq format to 'makemaker' -- wrong! | ||
| 77 | prereq_format => { #default => $self->status->installer_type, | ||
| 78 | default => '', | ||
| 79 | store => \$prereq_format }, | ||
| 80 | prereq_build => { default => 0, store => \$prereq_build }, | ||
| 81 | }; | ||
| 82 | |||
| 83 | check( $tmpl, \%hash ) or return; | ||
| 84 | }; | ||
| 85 | |||
| 86 | ### maybe we already ran a create on this object? ### | ||
| 87 | return 1 if $dist->status->created && !$force; | ||
| 88 | |||
| 89 | ### store the arguments, so ->install can use them in recursive loops ### | ||
| 90 | $dist->status->_create_args( \%hash ); | ||
| 91 | |||
| 92 | msg(loc("Resolving prerequisites mentioned in the bundle"), $verbose); | ||
| 93 | |||
| 94 | ### this will set the directory back to the start | ||
| 95 | ### dir, so we must chdir /again/ | ||
| 96 | my $ok = $dist->_resolve_prereqs( | ||
| 97 | format => $prereq_format, | ||
| 98 | verbose => $verbose, | ||
| 99 | prereqs => $self->status->prereqs, | ||
| 100 | target => $prereq_target, | ||
| 101 | force => $force, | ||
| 102 | prereq_build => $prereq_build, | ||
| 103 | ); | ||
| 104 | |||
| 105 | ### if all went well, mark it & return | ||
| 106 | return $dist->status->created( $ok ? 1 : 0); | ||
| 107 | } | ||
| 108 | |||
| 109 | sub install { | ||
| 110 | my $dist = shift; | ||
| 111 | my %args = @_; | ||
| 112 | |||
| 113 | ### store the arguments, so ->install can use them in recursive loops ### | ||
| 114 | $dist->status->_install_args( \%args ); | ||
| 115 | |||
| 116 | return $dist->status->installed( 1 ); | ||
| 117 | } | ||
| 118 | |||
| 119 | 1; |