Update CPANPLUS to 0.85_06
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / Backend.pm
index 75beb2e..fb71fcf 100644 (file)
@@ -369,19 +369,21 @@ for my $func (qw[fetch extract install readme files distributions]) {
         my $conf = $self->configure_object;
         my %hash = @_;
 
-        local $Params::Check::NO_DUPLICATES = 1;
-        local $Params::Check::ALLOW_UNKNOWN = 1;
-
         my ($mods);
-        my $tmpl = {
-            modules     => { default  => [],    strict_type => 1,
-                             required => 1,     store => \$mods },
-        };
+        my $args = do {
+            local $Params::Check::NO_DUPLICATES = 1;
+            local $Params::Check::ALLOW_UNKNOWN = 1;
+
+            my $tmpl = {
+                modules     => { default  => [],    strict_type => 1,
+                                 required => 1,     store => \$mods },
+            };
 
-        my $args = check( $tmpl, \%hash ) or return;
+            check( $tmpl, \%hash );
+        } or return;
 
         ### make them all into module objects ###
-        my %mods = map {$_ => $self->parse_module(module => $_) || ''} @$mods;
+        my %mods = map { $_ => $self->parse_module(module => $_) || '' } @$mods;
 
         my $flag; my $href;
         while( my($name,$obj) = each %mods ) {
@@ -556,8 +558,8 @@ sub parse_module {
     } else {
         $author = shift @parts || '';
     }
-    
-    my($pkg, $version, $ext) = 
+
+    my($pkg, $version, $ext, $full) = 
         $self->_split_package_string( package => $dist );
     
     ### translate a distribution into a module name ###
@@ -599,8 +601,12 @@ sub parse_module {
                 my $modobj = CPANPLUS::Module::Fake->new(
                     module  => $maybe->module,
                     version => $version,
-                    package => $pkg . '-' . $version . '.' .
-                                    $maybe->package_extension,
+                    ### no extension? use the extension the original package
+                    ### had instead
+                    package => do { $ext 
+                                        ? $full 
+                                        : $full .'.'. $maybe->package_extension 
+                                },
                     path    => $path,
                     author  => $auth_obj,
                     _id     => $maybe->_id
@@ -941,7 +947,14 @@ sub local_mirror {
 
 Writes out a snapshot of your current installation in C<CPAN> bundle
 style. This can then be used to install the same modules for a
-different or on a different machine.
+different or on a different machine by issuing the following commands:
+
+    ### using the default shell:
+    CPAN Terminal> i file://path/to/Snapshot_XXYY.pm
+    
+    ### using the API
+    $modobj = $cb->parse_module( module => 'file://path/to/Snapshot_XXYY.pm' );
+    $modobj->install;
 
 It will, by default, write to an 'autobundle' directory under your
 cpanplus homedirectory, but you can override that by supplying a
@@ -1022,7 +1035,7 @@ sub autobundle {
     my $perl_v  = join '', `$^X -V`;
 
     print $fh <<EOF;
-package $name
+package $name;
 
 \$VERSION = '0.01';
 
@@ -1036,7 +1049,7 @@ $name - Snapshot of your installation at $now
 
 $head SYNOPSIS
 
-perl -MCPANPLUS -e "install $name"
+perl -MCPANPLUS -e "install file://full/path/to/$name"
 
 $head CONTENTS
 
@@ -1058,6 +1071,31 @@ EOF
     return $file;
 }
 
+=head2 $bool = $cb->save_state
+
+Explicit command to save memory state to disk. This can be used to save
+information to disk about where a module was extracted, the result of 
+C<make test>, etc. This will then be re-loaded into memory when a new
+session starts.
+
+The capability of saving state to disk depends on the source engine
+being used (See C<CPANPLUS::Config> for the option to choose your
+source engine). The default storage engine supports this option.
+
+Most users will not need this command, but it can handy for automated
+systems like setting up CPAN smoke testers.
+
+The method will return true if it managed to save the state to disk, 
+or false if it did not.
+
+=cut
+
+sub save_state {
+    my $self = shift;
+    return $self->_save_state( @_ );
+}
+
+
 ### XXX these wrappers are not individually tested! only the underlying
 ### code through source.t and indirectly trought he CustomSource plugin.
 =pod