Date: | Fri, 23 Dec 2005 00:47:10 -0800 |
From: | Yitzchak Scott-Thoennes <sthoenna [...] efn.org> |
To: | bug-CPAN-Mini [...] rt.cpan.org |
Subject: | [PATCH] add bundle option, allow skip_cleanup in rc file |
This adds a -b|bundle option to specify a bundle file and only
mirror the bundle's contents. I'd hope this would prevent the
proliferation of modules like CPAN::Mini::Phalanx100.
Also allow skip_cleanup in the .minicpanrc file.
--- CPAN-Mini-0.40/bin/minicpan.orig 2005-09-05 21:24:38.000000000 -0700
+++ CPAN-Mini-0.40/bin/minicpan 2005-12-23 00:31:47.681542400 -0800
@@ -18,15 +18,13 @@
-p - mirror perl, ponie, and parrot distributions
-q - run in quiet mode (don't print status)
-qq - run in silent mode (don't even print warnings)
+ -b FILE - only modules listed in the given bundle file
=head1 DESCRIPTION
This simple shell script just updates (or creates) a miniature CPAN mirror as
described in CPAN::Mini.
-The local and remote mirror locations are (for now) hardcoded and should be
-updated before running this script for the first time.
-
=cut
use CPAN::Mini;
@@ -84,6 +82,7 @@
"l|local=s" => \$config{local},
"r|remote=s" => \$config{remote},
"d|dirmode=s" => \$config{dirmode},
+ "b|bundle=s" => \$config{bundle},
"qq" => sub { $config{quiet} = 2; $config{errors} = 0; },
"q+" => \$config{quiet},
"f+" => \$config{force},
@@ -91,6 +90,21 @@
"x+" => \$config{exact_mirror},
) or pod2usage(2);
+# make a suitable module filter if just doing a bundle
+if ($config{bundle}) {
+ my $file = delete $config{bundle};
+ open my $fh, "<", $file or die "Couldn't open bundle file $file: $!\n";
+ my %contents;
+ while (<$fh>) {
+ next unless /^=head1\s+CONTENTS/ .. /^=(?!head1\s+CONTENTS)/;
+ next if /^=/;
+ s/\#.*//;
+ next if /^\s+$/;
+ $contents{(split " ", $_, 2)[0]} = 1;
+ }
+ push @{$config{module_filters}}, sub { !exists $contents{$_[0]} };
+}
+
eval "require $class";
die $@ if $@;
@@ -106,6 +120,7 @@
trace => (not $config{quiet}),
force => $config{force},
dirmode => $config{dirmode},
+ skip_cleanup => $config{skip_cleanup},
skip_perl => (not $config{perl}),
exact_mirror => ($config{exact_mirror}),
module_filters => ($config{module_filters}),