r32824 - in /branches/upstream/libcpan-mini-perl: ./ current/ current/bin/ current/lib/ current/lib/CPAN/ current/t/
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Thu Apr 9 00:11:04 UTC 2009
Author: ryan52-guest
Date: Thu Apr 9 00:10:58 2009
New Revision: 32824
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=32824
Log:
[svn-inject] Installing original source of libcpan-mini-perl
Added:
branches/upstream/libcpan-mini-perl/
branches/upstream/libcpan-mini-perl/current/
branches/upstream/libcpan-mini-perl/current/Changes
branches/upstream/libcpan-mini-perl/current/MANIFEST
branches/upstream/libcpan-mini-perl/current/META.yml
branches/upstream/libcpan-mini-perl/current/Makefile.PL
branches/upstream/libcpan-mini-perl/current/README
branches/upstream/libcpan-mini-perl/current/bin/
branches/upstream/libcpan-mini-perl/current/bin/minicpan
branches/upstream/libcpan-mini-perl/current/lib/
branches/upstream/libcpan-mini-perl/current/lib/CPAN/
branches/upstream/libcpan-mini-perl/current/lib/CPAN/Mini.pm
branches/upstream/libcpan-mini-perl/current/t/
branches/upstream/libcpan-mini-perl/current/t/00_load.t
branches/upstream/libcpan-mini-perl/current/t/filter.t
branches/upstream/libcpan-mini-perl/current/t/pod-coverage.t
branches/upstream/libcpan-mini-perl/current/t/pod.t
Added: branches/upstream/libcpan-mini-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/Changes?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/Changes (added)
+++ branches/upstream/libcpan-mini-perl/current/Changes Thu Apr 9 00:10:58 2009
@@ -1,0 +1,62 @@
+0.550 2006-08-08
+ add tilde expansion for homedir in local mirror specification
+ move configuration reading into CPAN::Mini
+ document a few previously-undocumented things
+ documentation cleanup
+ added unused-by-script option to use current mtime for indices
+ (this helps CPANPLUS do the right thing)
+
+0.500 2006-07-11
+ we no longer need File::HomeDir::Win32 on Windows
+ provide the also_mirror option to get other static files
+
+0.40 2005-11-04
+ remove force option to trace
+ create local mirror if needed
+ notice if local mirror -e && ! -d
+ cleared out stupid /\A\s+\z/ lines
+
+0.38 2005-10-13 00:05
+ more intelligently divide cleanup tasks (isn't ADAMK great?)
+ move arg validity check constructor (to silence ADAMK)
+ add some more checks for validity (stolen from ADAMK)
+ add errors option and -qq commandline option for it
+
+0.36 2005-01-06 18:40
+ code refs can be passed to _filters, which were slightly refactored
+
+0.32 2004-12-31 15:45
+ added an old alpha binary for perl to the perls to skip
+
+0.30 2004-12-28 10:00
+ added a "new" method for construction
+ update_mirror can act as class or instance method
+ added clean_file method
+
+0.26 2004-12-02 15:05
+ require version 5.6 of perl in Makefile.PL
+
+0.24 2004-11-29 14:30
+ dirmode is correctly octalized (thanks SSORICHE)
+ sungo's *_filters patch
+
+0.20 2004-09-28 10:20
+ added config file
+ added file_allowed (to override cleanup)
+ the -d option, long documented, now works
+
+0.18 2004-09-21 20:15
+ canonpath File::Find::name to avoid horrible Win32 bug
+ added -v to print version of CPAN::Mini
+
+0.16 2004-09-07 21:50
+ added -d to set mode for created dirs
+
+0.14 2004-08-28 17:05
+ uses Pod::Usage
+ now skips ponie and parrot (not just perl)
+ -p option to override the above skipping
+ "seen_changes" attribute and return value added
+
+0.10 2004-08-26 10:50
+ initial release
Added: branches/upstream/libcpan-mini-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/MANIFEST?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/MANIFEST (added)
+++ branches/upstream/libcpan-mini-perl/current/MANIFEST Thu Apr 9 00:10:58 2009
@@ -1,0 +1,11 @@
+bin/minicpan
+lib/CPAN/Mini.pm
+Changes
+Makefile.PL
+MANIFEST This list of files
+README
+t/00_load.t
+t/filter.t
+t/pod-coverage.t
+t/pod.t
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libcpan-mini-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/META.yml?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/META.yml (added)
+++ branches/upstream/libcpan-mini-perl/current/META.yml Thu Apr 9 00:10:58 2009
@@ -1,0 +1,15 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: CPAN-Mini
+version: 0.550
+version_from: lib/CPAN/Mini.pm
+installdirs: site
+requires:
+ Compress::Zlib: 1.20
+ File::HomeDir: 0.57
+ LWP: 5
+ Pod::Usage: 1
+ URI: 1
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30
Added: branches/upstream/libcpan-mini-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/Makefile.PL?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/Makefile.PL (added)
+++ branches/upstream/libcpan-mini-perl/current/Makefile.PL Thu Apr 9 00:10:58 2009
@@ -1,0 +1,16 @@
+use 5.006;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ 'NAME' => 'CPAN::Mini',
+ 'VERSION_FROM' => 'lib/CPAN/Mini.pm',
+ 'EXE_FILES' => [ 'bin/minicpan' ],
+ 'PREREQ_PM' => {
+ 'URI' => 1,
+ 'LWP' => 5,
+ 'Compress::Zlib' => '1.20',
+ 'File::HomeDir' => '0.57', # Win32 Support
+ 'Pod::Usage' => 1,
+ },
+ 'PREREQ_PRINT' => 1
+);
Added: branches/upstream/libcpan-mini-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/README?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/README (added)
+++ branches/upstream/libcpan-mini-perl/current/README Thu Apr 9 00:10:58 2009
@@ -1,0 +1,10 @@
+README for CPAN::Mini
+
+CPAN::Mini provides a simple mechanism to build and update a minimal mirror of
+the CPAN on your local disk. It contains only those files needed to install
+the newest version of every distribution. Those files are:
+
+ * 01mailrc.txt.gz
+ * 02packages.details.txt.gz
+ * 03modlist.data.gz
+ * the last non-developer release of every dist for every author
Added: branches/upstream/libcpan-mini-perl/current/bin/minicpan
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/bin/minicpan?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/bin/minicpan (added)
+++ branches/upstream/libcpan-mini-perl/current/bin/minicpan Thu Apr 9 00:10:58 2009
@@ -1,0 +1,117 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+=head1 NAME
+
+minicpan - uses CPAN::Mini to create or update a local mirror
+
+=head1 SYNOPSIS
+
+ minicpan [options]
+
+ Options
+ -l LOCAL - where is the local minicpan? (required)
+ -r REMOTE - where is the remote cpan mirror? (required)
+ -d 0### - permissions (numeric) to use when creating directories
+ -f - check all directories, even if indices are unchanged
+ -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)
+
+=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;
+use File::HomeDir;
+use File::Spec;
+use Getopt::Long qw(GetOptions);
+use Pod::Usage;
+
+sub display_version {
+ my $class = shift;
+ no strict 'refs';
+ print "minicpan",
+ ($class ne 'CPAN::Mini' ? ' (from CPAN::Mini)' : ''),
+ ", powered by $class ", ${"$class\:\:VERSION"}, "\n\n";
+ exit;
+}
+
+my %config = CPAN::Mini->read_config;
+my $class = 'CPAN::Mini';
+my $version;
+
+GetOptions(
+ "c|class=s" => \$class,
+ "h|help" => sub { pod2usage(1); },
+ "v|version" => sub { $version = 1 },
+ "l|local=s" => \$config{local},
+ "r|remote=s" => \$config{remote},
+ "d|dirmode=s" => \$config{dirmode},
+ "qq" => sub { $config{quiet} = 2; $config{errors} = 0; },
+ "q+" => \$config{quiet},
+ "f+" => \$config{force},
+ "p+" => \$config{perl},
+ "x+" => \$config{exact_mirror},
+) or pod2usage(2);
+
+eval "require $class";
+die $@ if $@;
+
+display_version($class) if $version;
+pod2usage(2) unless $config{local} and $config{remote};
+
+$|++;
+$config{dirmode} &&= oct($config{dirmode});
+
+CPAN::Mini->update_mirror(
+ remote => $config{remote},
+ local => $config{local},
+ trace => (not $config{quiet}),
+ force => $config{force},
+ dirmode => $config{dirmode},
+ also_mirror => $config{also_mirror},
+ exact_mirror => ($config{exact_mirror}),
+ module_filters => ($config{module_filters}),
+ path_filters => ($config{path_filters}),
+ skip_perl => (not $config{perl}),
+ (defined $config{errors} ? (errors => $config{errors}) : ()),
+);
+
+=head1 CONFIGURATION FILE
+
+C<minicpan> will read the file C<~/.minicpanrc> to get configuration
+information. The file is a simple set of names and values, as in the following
+example:
+
+ local: /home/rjbs/mirrors/minicpan/
+ remote: http://your.favorite.cpan/cpan/
+ exact_mirror: 1
+
+=head1 TO DO
+
+Improve command-line options.
+
+=head1 SEE ALSO
+
+Randal Schwartz's original article, which can be found here:
+
+ http://www.stonehenge.com/merlyn/LinuxMag/col42.html
+
+=head1 AUTHORS
+
+Randal Schwartz <F<merlyn at stonehenge.com>> did all the work.
+
+Ricardo SIGNES <F<rjbs at cpan.org>> made a module and distribution.
+
+This code was copyrighted in 2004, and is released under the same terms as Perl
+itself.
+
+=cut
Added: branches/upstream/libcpan-mini-perl/current/lib/CPAN/Mini.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/lib/CPAN/Mini.pm?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/lib/CPAN/Mini.pm (added)
+++ branches/upstream/libcpan-mini-perl/current/lib/CPAN/Mini.pm Thu Apr 9 00:10:58 2009
@@ -1,0 +1,521 @@
+package CPAN::Mini;
+our $VERSION = '0.550';
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+CPAN::Mini - create a minimal mirror of CPAN
+
+=head1 VERSION
+
+version 0.550
+
+ $Id: /my/cs/projects/minicpan/trunk/lib/CPAN/Mini.pm 24759 2006-08-08T22:42:40.881515Z rjbs $
+
+=head1 SYNOPSIS
+
+(If you're not going to do something weird, you probably want to look at the
+L<minicpan> command, instead.)
+
+ use CPAN::Mini;
+
+ CPAN::Mini->update_mirror(
+ remote => "http://cpan.mirrors.comintern.su",
+ local => "/usr/share/mirrors/cpan",
+ trace => 1
+ );
+
+=head1 DESCRIPTION
+
+CPAN::Mini provides a simple mechanism to build and update a minimal mirror of
+the CPAN on your local disk. It contains only those files needed to install
+the newest version of every distribution. Those files are:
+
+=over 4
+
+=item * 01mailrc.txt.gz
+
+=item * 02packages.details.txt.gz
+
+=item * 03modlist.data.gz
+
+=item * the last non-developer release of every dist for every author
+
+=back
+
+=cut
+
+use Carp ();
+
+use File::Path ();
+use File::Basename ();
+use File::Spec ();
+use File::Find ();
+
+use URI ();
+use LWP::Simple ();
+
+use Compress::Zlib ();
+
+=head1 METHODS
+
+=head2 update_mirror
+
+ CPAN::Mini->update_mirror(
+ remote => "http://cpan.mirrors.comintern.su",
+ local => "/usr/share/mirrors/cpan",
+ force => 0,
+ trace => 1
+ );
+
+This is the only method that need be called from outside this module. It will
+update the local mirror with the files from the remote mirror.
+
+If called as a class method, C<update_mirror> creates an ephemeral CPAN::Mini
+object on which other methods are called. That object is used to store mirror
+location and state.
+
+This method returns the number of files updated.
+
+The following options are recognized:
+
+=over 4
+
+=item * C<dirmode>
+
+Generally an octal number, this option sets the permissions of created
+directories. It defaults to 0711.
+
+=item * C<force>
+
+If true, this option will cause CPAN::Mini to read the entire module list and
+update anything out of date, even if the module list itself wasn't out of date
+on this run.
+
+=item * C<skip_perl>
+
+If true, CPAN::Mini will skip the major language distributions: perl, parrot,
+and ponie.
+
+=item * C<trace>
+
+If true, CPAN::Mini will print status messages to STDOUT as it works.
+
+=item * C<errors>
+
+If true, CPAN::Mini will warn with status messages on errors. (default: true)
+
+=item * C<path_filters>
+
+This options provides a set of rules for filtering paths. If a distribution
+matches one of the rules in C<path_filters>, it will not be mirrored. A regex
+rule is matched if the path matches the regex; a code rule is matched if the
+code returns 1 when the path is passed to it. For example, the following
+setting would skip all distributions from RJBS and SUNGO:
+
+ path_filters => [
+ qr/RJBS/,
+ sub { $_[0] =~ /SUNGO/ }
+ ]
+
+=item * C<module_filters>
+
+This option provides a set of rules for filtering modules. It behaves like
+path_filters, but acts only on module names. (Since most modules are in
+distributions with more than one module, this setting will probably be less
+useful than C<path_filters>.) For example, this setting will skip any
+distribution containing only modules with the word "Acme" in them:
+
+ module_filters => [ qr/Acme/i ]
+
+=item * C<also_mirror>
+
+This option should be an arrayref of extra files in the remote CPAN to mirror
+locally.
+
+=item * C<skip_cleanup>
+
+If this option is true, CPAN::Mini will not try delete unmirrored files when it
+has finished mirroring
+
+=back
+
+=cut
+
+sub update_mirror {
+ my $self = shift;
+ $self = $self->new(@_) unless ref $self;
+
+ # mirrored tracks the already done, keyed by filename
+ # 1 = local-checked, 2 = remote-mirrored
+ $self->mirror_indices;
+
+ return unless $self->{force} or $self->{changes_made};
+
+ # now walk the packages list
+ my $details = File::Spec->catfile(
+ $self->{local},
+ qw(modules 02packages.details.txt.gz)
+ );
+
+ my $gz = Compress::Zlib::gzopen($details, "rb")
+ or die "Cannot open details: $Compress::Zlib::gzerrno";
+
+ my $inheader = 1;
+ while ($gz->gzreadline($_) > 0) {
+ if ($inheader) {
+ $inheader = 0 unless /\S/;
+ next;
+ }
+
+ my ($module, $version, $path) = split;
+ next if $self->_filter_module({
+ module => $module,
+ version => $version,
+ path => $path,
+ });
+
+ $self->mirror_file("authors/id/$path", 1);
+ }
+
+ # eliminate files we don't need
+ $self->clean_unmirrored unless $self->{skip_cleanup};
+ return $self->{changes_made};
+}
+
+=head2 new
+
+ my $minicpan = CPAN::Mini->new;
+
+This method constructs a new CPAN::Mini object. Its parameters are described
+above, under C<update_mirror>.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my %defaults = (
+ changes_made => 0,
+ dirmode => 0711,
+ errors => 1,
+ mirrored => {}
+ );
+
+ my $self = bless { %defaults, @_ } => $class;
+
+ Carp::croak "no local mirror supplied" unless $self->{local};
+
+ substr($self->{local}, 0, 1, $class->__homedir)
+ if substr($self->{local}, 0, 1) eq '~';
+
+ Carp::croak "local mirror path exists but is not a directory"
+ if (-e $self->{local}) and not (-d $self->{local});
+
+ File::Path::mkpath($self->{local}, $self->{trace}, $self->{dirmode})
+ unless -e $self->{local};
+
+ Carp::croak "no write permission to local mirror" unless -w $self->{local};
+
+ Carp::croak "no remote mirror supplied" unless $self->{remote};
+ Carp::croak "unable to contact the remote mirror"
+ unless LWP::Simple::head($self->{remote});
+
+ return $self;
+}
+
+=head2 mirror_indices
+
+ $minicpan->mirror_indices;
+
+This method updates the index files from the CPAN.
+
+=cut
+
+sub mirror_indices {
+ my $self = shift;
+
+ my @fixed_mirrors = qw(
+ authors/01mailrc.txt.gz
+ modules/02packages.details.txt.gz
+ modules/03modlist.data.gz
+ );
+
+ # XXX: Should the 0 be a 1, below? -- rjbs, 2006-08-08
+ $self->mirror_file($_, undef, 0) for @fixed_mirrors, @{$self->{also_mirror}};
+}
+
+=head2 mirror_file
+
+ $minicpan->mirror_file($path, $skip_if_present)
+
+This method will mirror the given file from the remote to the local mirror,
+overwriting any existing file unless C<$skip_if_present> is true.
+
+=cut
+
+sub mirror_file {
+ my $self = shift;
+ my $path = shift; # partial URL
+ my $skip_if_present = shift; # true/false
+ my $update_times = shift; # true/false
+
+ # full URL
+ my $remote_uri = URI->new_abs($path, $self->{remote})->as_string;
+
+ # native absolute file
+ my $local_file = File::Spec->catfile($self->{local}, split "/", $path);
+
+ my $checksum_might_be_up_to_date = 1;
+
+ if ($skip_if_present and -f $local_file) {
+ ## upgrade to checked if not already
+ $self->{mirrored}{$local_file} = 1 unless $self->{mirrored}{$local_file};
+ } elsif (($self->{mirrored}{$local_file} || 0) < 2) {
+ ## upgrade to full mirror
+ $self->{mirrored}{$local_file} = 2;
+
+ File::Path::mkpath(
+ File::Basename::dirname($local_file),
+ $self->{trace},
+ $self->{dirmode}
+ );
+
+ $self->trace($path);
+ my $status = LWP::Simple::mirror($remote_uri, $local_file);
+
+ if ($status == LWP::Simple::RC_OK) {
+ utime undef, undef, $local_file if $update_times;
+ $checksum_might_be_up_to_date = 0;
+ $self->trace(" ... updated\n");
+ $self->{changes_made}++;
+ } elsif ($status != LWP::Simple::RC_NOT_MODIFIED) {
+ warn( ($self->{trace} ? "\n" : '')
+ . "$remote_uri: $status\n") if $self->{errors};
+ return;
+ } else {
+ $self->trace(" ... up to date\n");
+ }
+ }
+
+ if ($path =~ m{^authors/id}) { # maybe fetch CHECKSUMS
+ my $checksum_path =
+ URI->new_abs("CHECKSUMS", $remote_uri)->rel($self->{remote});
+ if ($path ne $checksum_path) {
+ $self->mirror_file($checksum_path, $checksum_might_be_up_to_date);
+ }
+ }
+}
+
+=begin devel
+
+=head2 _filter_module
+
+ next if
+ $self->_filter_module({ module => $foo, version => $foo, path => $foo });
+
+This internal-only method encapsulates the logic where we figure out if a
+module is to be mirrored or not. Better stated, this method holds the filter
+chain logic. C<update_mirror()> takes an optional set of filter parameters. As
+C<update_mirror()> encounters a distribution, it calls this method to figure
+out whether or not it should be downloaded. The user provided filters are taken
+into account. Returns 1 if the distribution is filtered (to be skipped).
+Returns 0 if the distribution is to not filtered (not to be skipped).
+
+=end devel
+
+=cut
+
+sub __do_filter {
+ my ($self, $filter, $file) = @_;
+ return unless $filter;
+ if (ref($filter) eq 'ARRAY') {
+ for (@$filter) {
+ return 1 if $self->__do_filter($_, $file);
+ }
+ }
+ if (ref($filter) eq 'CODE') {
+ return $filter->($file);
+ } else {
+ return $file =~ $filter;
+ }
+}
+
+sub _filter_module {
+ my $self = shift;
+ my $args = shift;
+
+ if ($self->{skip_perl}) {
+ return 1 if $args->{path} =~ m{/(?:emb|syb|bio)*perl-\d}i;
+ return 1 if $args->{path} =~ m{/(?:parrot|ponie)-\d}i;
+ return 1 if $args->{path} =~ m{/\bperl5\.004}i;
+ }
+
+ return 1 if $self->__do_filter($self->{path_filters}, $args->{path});
+ return 1 if $self->__do_filter($self->{module_filters}, $args->{module});
+ return 0;
+}
+
+=head2 file_allowed
+
+ next unless $minicpan->file_allowed($filename);
+
+This method returns true if the given file is allowed to exist in the local
+mirror, even if it isn't one of the required mirror files.
+
+By default, only dot-files are allowed.
+
+=cut
+
+sub file_allowed {
+ my ($self, $file) = @_;
+ return if $self->{exact_mirror};
+ return (substr(File::Basename::basename($file),0,1) eq '.') ? 1 : 0;
+}
+
+=head2 clean_unmirrored
+
+ $minicpan->clean_unmirrored;
+
+This method looks through the local mirror's files. If it finds a file that
+neither belongs in the mirror nor is allowed (see the C<file_allowed> method),
+C<clean_file> is called on the file.
+
+=cut
+
+sub clean_unmirrored {
+ my $self = shift;
+
+ File::Find::find sub {
+ my $file = File::Spec->canonpath($File::Find::name);
+ return unless (-f $file and not $self->{mirrored}{$file});
+ return if $self->file_allowed($file);
+ $self->trace("cleaning $file ...");
+ if ($self->clean_file($file)) {
+ $self->trace("done\n");
+ } else {
+ $self->trace("couldn't be cleaned\n");
+ }
+ }, $self->{local};
+}
+
+=head2 clean_file
+
+ $minicpan->clean_file($filename);
+
+This method, called by C<clean_unmirrored>, deletes the named file. It returns
+true if the file is successfully unlinked. Otherwise, it returns false.
+
+=cut
+
+sub clean_file {
+ my ($self, $file) = @_;
+
+ unless (unlink $file) {
+ warn "$file ... cannot be removed: $!" if $self->{errors};
+ return;
+ }
+ return 1;
+}
+
+=head2 trace
+
+ $minicpan->trace($message);
+
+If the object is mirroring verbosely, this method will print messages sent to
+it.
+
+=cut
+
+sub trace {
+ my ($self, $message) = @_;
+ print "$message" if $self->{trace};
+}
+
+=head2 read_config
+
+ my %config = CPAN::Mini->read_config;
+
+This routine returns a set of arguments that can be passed to CPAN::Mini's
+C<new> or C<update_mirror> methods. It will look for a file called
+F<.minicpanrc> in the user's home directory as determined by
+L<File::HomeDir|File::HomeDir>.
+
+=cut
+
+sub __homedir {
+ my ($class) = @_;
+
+ my $homedir = File::HomeDir->my_home || $ENV{HOME};
+
+ Carp::croak "couldn't determine your home directory! set HOME env variable"
+ unless defined $homedir;
+
+ return $homedir;
+}
+
+sub read_config {
+ my ($class) = @_;
+
+ my $filename = File::Spec->catfile($class->__homedir, '.minicpanrc');
+
+ return unless -e $filename;
+
+ open my $config_file, '<', $filename
+ or die "couldn't open config file $filename: $!";
+
+ my %config;
+ while (<$config_file>) {
+ chomp;
+ next if /\A\s*\Z/sm;
+ if (/\A(\w+):\s*(.+)\Z/sm) { $config{$1} = $2; }
+ }
+ for (qw(also_mirror)) {
+ $config{$_} = [ grep { length } split /\s+/, $config{$_}] if $config{$_};
+ }
+ for (qw(module_filters path_filters)) {
+ $config{$_} = [ map { qr/$_/ } split /\s+/, $config{$_} ] if $config{$_};
+ }
+ return %config;
+}
+
+=head2
+
+=head1 SEE ALSO
+
+Randal Schwartz's original article on minicpan, here:
+
+ http://www.stonehenge.com/merlyn/LinuxMag/col42.html
+
+L<CPANPLUS::Backend>, which provides the C<local_mirror> method, which performs
+the same task as this module.
+
+=head1 THANKS
+
+Thanks to David Dyck for letting me know about my stupid documentation errors.
+
+Thanks to Roy Fulbright for finding an obnoxious bug on Win32.
+
+Thanks to Shawn Sorichetti for fixing a stupid octal-number-as-string bug.
+
+Thanks to sungo for implementing the filters, so I can finally stop mirroring
+bioperl, and Robert Rothenberg for suggesting adding coderef rules.
+
+Thanks to Adam Kennedy for noticing and complaining about a lot of stupid
+little design decisions.
+
+=head1 AUTHORS
+
+Randal Schwartz <F<merlyn at stonehenge.com>> wrote the original F<minicpan>
+script.
+
+Ricardo SIGNES <F<rjbs at cpan.org>> turned Randal's script into a module and CPAN
+distribution, and has maintained it since its release as such.
+
+This code was copyrighted in 2004, and is released under the same terms as Perl
+itself.
+
+=cut
+
+1;
Added: branches/upstream/libcpan-mini-perl/current/t/00_load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/t/00_load.t?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/t/00_load.t (added)
+++ branches/upstream/libcpan-mini-perl/current/t/00_load.t Thu Apr 9 00:10:58 2009
@@ -1,0 +1,7 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+use_ok( 'CPAN::Mini' );
+
+diag( "Testing CPAN::Mini $CPAN::Mini::VERSION" );
Added: branches/upstream/libcpan-mini-perl/current/t/filter.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/t/filter.t?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/t/filter.t (added)
+++ branches/upstream/libcpan-mini-perl/current/t/filter.t Thu Apr 9 00:10:58 2009
@@ -1,0 +1,157 @@
+#!perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 19;
+
+use CPAN::Mini;
+
+my $self = {
+ changes_made => 1,
+ force => 1,
+};
+
+bless $self, "CPAN::Mini";
+################################################
+# skip_perl
+
+$self->{skip_perl} = 1;
+
+ok($self->_filter_module({
+ module => 'perl',
+ version => '0.01',
+ path => '/perl-0.01.tar.gz',
+}), "perl distro skip check");
+
+ok($self->_filter_module({
+ module => 'bioperl',
+ version => '0.01',
+ path => '/bioperl-0.01.tar.gz',
+}), "bioperl distro skip check");
+
+ok($self->_filter_module({
+ module => 'embperl',
+ version => '0.01',
+ path => '/embperl-0.01.tar.gz',
+}), "embperl distro skip check");
+
+ok(!$self->_filter_module({
+ module => 'notperl',
+ version => '0.01',
+ path => '/POE-0.01.tar.gz',
+}), "POE distro not-skip check");
+
+ok($self->_filter_module({
+ module => 'ponie',
+ version => '0.01',
+ path => '/ponie-0.01.tar.gz',
+}), "ponie distro skip check");
+
+ok($self->_filter_module({
+ module => 'parrot',
+ version => '0.01',
+ path => '/parrot-0.01.tar.gz',
+}), "parrot distro skip check");
+
+delete $self->{skip_perl};
+
+ok(!$self->_filter_module({
+ module => 'perl',
+ version => '0.01',
+ path => '/perl-0.01.tar.gz',
+}), "perl distro no-skip check");
+
+################################################
+# path_filters
+
+$self->{path_filters} = qr/skipme/;
+
+ok($self->_filter_module({
+ module => 'skipme',
+ version => '0.01',
+ path => '/skipme-0.01.tar.gz',
+}), "path_filters skip check skipme 1");
+
+ok(!$self->_filter_module({
+ module => 'noskip',
+ version => '0.01',
+ path => '/noskip-0.01.tar.gz',
+}), "path_filters no-skip check");
+
+$self->{path_filters} = [
+ qr/skipme/,
+ qr/burnme/,
+ sub { return $_[0] =~ /subskip/ }
+];
+
+ok($self->_filter_module({
+ module => 'skipme',
+ version => '0.01',
+ path => '/skipme-0.01.tar.gz',
+}), "path_filters skip check skipme 2");
+
+ok($self->_filter_module({
+ module => 'burnme',
+ version => '0.01',
+ path => '/burnme-0.01.tar.gz',
+}), "path_filters skip check burnme");
+
+ok($self->_filter_module({
+ module => 'submod',
+ version => '0.01',
+ path => '/subskip-0.01.tar.gz',
+}), "path_filters skip check (by sub)");
+
+ok(!$self->_filter_module({
+ module => 'noskip',
+ version => '0.01',
+ path => '/noskip-0.01.tar.gz',
+}), "path_filters no-skip check");
+
+################################################
+# module_filters
+
+$self->{module_filters} = qr/skipme/;
+
+ok($self->_filter_module({
+ module => 'skipme',
+ version => '0.01',
+ path => '/skipme-0.01.tar.gz',
+}), "module_filters skip check skipme 1");
+
+ok(!$self->_filter_module({
+ module => 'noskip',
+ version => '0.01',
+ path => '/noskip-0.01.tar.gz',
+}), "module_filters no-skip check");
+
+$self->{module_filters} = [
+ qr/skipme/,
+ qr/burnme/,
+ sub { $_[0] =~ /submod/ }
+];
+
+ok($self->_filter_module({
+ module => 'skipme',
+ version => '0.01',
+ path => '/skipme-0.01.tar.gz',
+}), "module_filters skip check skipme 2");
+
+ok($self->_filter_module({
+ module => 'burnme',
+ version => '0.01',
+ path => '/burnme-0.01.tar.gz',
+}), "module_filters skip check burnme");
+
+ok($self->_filter_module({
+ module => 'submod',
+ version => '0.01',
+ path => '/subskip-0.01.tar.gz',
+}), "module_filters skip check (by sub)");
+
+ok(!$self->_filter_module({
+ module => 'noskip',
+ version => '0.01',
+ path => '/noskip-0.01.tar.gz',
+}), "module_filters no-skip check");
Added: branches/upstream/libcpan-mini-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/t/pod-coverage.t?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libcpan-mini-perl/current/t/pod-coverage.t Thu Apr 9 00:10:58 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: branches/upstream/libcpan-mini-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-mini-perl/current/t/pod.t?rev=32824&op=file
==============================================================================
--- branches/upstream/libcpan-mini-perl/current/t/pod.t (added)
+++ branches/upstream/libcpan-mini-perl/current/t/pod.t Thu Apr 9 00:10:58 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Pkg-perl-cvs-commits
mailing list