[Bps-public-commit] r9991 - bpsbuilder/BPB/lib/BPB/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Dec 18 08:34:51 EST 2007


Author: sunnavy
Date: Tue Dec 18 08:34:50 2007
New Revision: 9991

Modified:
   bpsbuilder/BPB/lib/BPB/Source/CPAN.pm

Log:
use independant temporary .cpan directory

Modified: bpsbuilder/BPB/lib/BPB/Source/CPAN.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/CPAN.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/CPAN.pm	Tue Dec 18 08:34:50 2007
@@ -6,9 +6,41 @@
 use File::Spec;
 use BPB::Source::Compressed;
 use CPAN;
+use CPAN::Config;
+use Data::Dumper;
+use File::Temp qw/tempdir/;
+use File::Spec;
+use File::Slurp;
 
 use base qw/BPB::Source::Base/;
 
+my $cpan_dir = tempdir( CLEANUP => 0 );
+unshift @INC, $cpan_dir;
+
+sub new {
+    my $class = shift;
+    my $self  = $class->SUPER::new(@_);
+    mkdir File::Spec->catfile( $cpan_dir, 'CPAN' );
+    my $config_file = File::Spec->catfile( $cpan_dir, 'CPAN', 'MyConfig.pm' );
+
+    unless ( -f $config_file ) {
+        my $config = $CPAN::Config;
+        $CPAN::Config->{cpan_home} = File::Spec->catfile($cpan_dir);
+        $CPAN::Config->{build_dir} = File::Spec->catfile( $cpan_dir, 'build' );
+        $CPAN::Config->{histfile} =
+          File::Spec->catfile( $cpan_dir, 'histfile' );
+        $CPAN::Config->{keep_source_where} =
+          File::Spec->catfile( $cpan_dir, 'sources' );
+        $CPAN::Config->{prerequisites_policy} = 'follow';
+
+        write_file( $config_file,
+            Data::Dumper->Dump( [$CPAN::Config], ['$CPAN::Config'] ) );
+
+    }
+    require $config_file;
+    return $self;
+}
+
 =head2 run
 
 =cut
@@ -19,9 +51,7 @@
     my $self = shift;
     $self->SUPER::run();
     my $compressed = BPB::Source::Compressed->new(%$self);
-    $compressed->run(
-        '_require.yml' => $require_path,
-    );
+    $compressed->run( '_require.yml' => $require_path, );
 }
 
 sub _run {



More information about the Bps-public-commit mailing list