summaryrefslogtreecommitdiff
path: root/lib/ExtUtils/Installed.pm
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2002-03-28 23:12:47 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-29 14:45:52 +0000
commitf6d6199cd6711f5e8a8e6c1a57445fa6f848c822 (patch)
treea3b30650d6c0eec8c7513c42453ae2e7f28cc5b2 /lib/ExtUtils/Installed.pm
parent798fbbe475389cc5bd681489265a68eee841b426 (diff)
downloadperl-f6d6199cd6711f5e8a8e6c1a57445fa6f848c822.tar.gz
MakeMaker sync 5.48_03 -> 5.53_01
Message-ID: <20020329091247.GA7432@blackrider> (with two nits: (1) change lib/Extutils/Command/MM.pm in MANIFEST to be lib/ExtUtils/Command/MM.pm (2) Add @INC to compile.t) p4raw-id: //depot/perl@15599
Diffstat (limited to 'lib/ExtUtils/Installed.pm')
-rw-r--r--lib/ExtUtils/Installed.pm328
1 files changed, 158 insertions, 170 deletions
diff --git a/lib/ExtUtils/Installed.pm b/lib/ExtUtils/Installed.pm
index 5b7f66327b..8498f35fdf 100644
--- a/lib/ExtUtils/Installed.pm
+++ b/lib/ExtUtils/Installed.pm
@@ -1,6 +1,6 @@
package ExtUtils::Installed;
-use 5.006_001;
+use 5.006;
use strict;
use Carp qw();
use ExtUtils::Packlist;
@@ -9,203 +9,191 @@ use Config;
use File::Find;
use File::Basename;
use File::Spec;
-our $VERSION = '0.04';
+require VMS::Filespec if $^O eq 'VMS';
+
+our $VERSION = '0.05';
my $DOSISH = ($^O =~ /^(MSWin\d\d|os2|dos|mint)$/);
-sub _is_prefix
-{
-my ($self, $path, $prefix) = @_;
-if (substr($path, 0, length($prefix)) eq $prefix)
- {
- return(1);
- }
-if ($DOSISH)
- {
- $path =~ s|\\|/|g;
- $prefix =~ s|\\|/|g;
- if ($path =~ m{^\Q$prefix\E}i)
- {
- return(1);
- }
- }
-return(0);
+sub _is_prefix {
+ my ($self, $path, $prefix) = @_;
+ return unless defined $prefix && defined $path;
+
+ if( $^O eq 'VMS' ) {
+ $prefix = VMS::Filespec::unixify($prefix);
+ $path = VMS::Filespec::unixify($path);
+ }
+ return 1 if substr($path, 0, length($prefix)) eq $prefix;
+
+ if ($DOSISH) {
+ $path =~ s|\\|/|g;
+ $prefix =~ s|\\|/|g;
+ return 1 if $path =~ m{^\Q$prefix\E}i;
+ }
+ return(0);
}
-sub _is_doc($$)
-{
-my ($self, $path) = @_;
-my $man1dir = $Config{man1direxp};
-my $man3dir = $Config{man3direxp};
-return(($man1dir && $self->_is_prefix($path, $man1dir))
- ||
- ($man3dir && $self->_is_prefix($path, $man3dir))
- ? 1 : 0)
+sub _is_doc {
+ my ($self, $path) = @_;
+ my $man1dir = $Config{man1direxp};
+ my $man3dir = $Config{man3direxp};
+ return(($man1dir && $self->_is_prefix($path, $man1dir))
+ ||
+ ($man3dir && $self->_is_prefix($path, $man3dir))
+ ? 1 : 0)
}
-sub _is_type($$$)
-{
-my ($self, $path, $type) = @_;
-return(1) if ($type eq "all");
-
-if ($type eq "doc")
- {
- return($self->_is_doc($path))
- }
-if ($type eq "prog")
- {
- return($self->_is_prefix($path, $Config{prefixexp})
- &&
- !($self->_is_doc($path))
- ? 1 : 0);
- }
-return(0);
+sub _is_type {
+ my ($self, $path, $type) = @_;
+ return 1 if $type eq "all";
+
+ return($self->_is_doc($path)) if $type eq "doc";
+
+ if ($type eq "prog") {
+ return($self->_is_prefix($path, $Config{prefix} || $Config{prefixexp})
+ &&
+ !($self->_is_doc($path))
+ ? 1 : 0);
+ }
+ return(0);
}
-sub _is_under($$;)
-{
-my ($self, $path, @under) = @_;
-$under[0] = "" if (! @under);
-foreach my $dir (@under)
- {
- return(1) if ($self->_is_prefix($path, $dir));
- }
-return(0);
-}
+sub _is_under {
+ my ($self, $path, @under) = @_;
+ $under[0] = "" if (! @under);
+ foreach my $dir (@under) {
+ return(1) if ($self->_is_prefix($path, $dir));
+ }
-sub new($)
-{
-my ($class) = @_;
-$class = ref($class) || $class;
-my $self = {};
-
-my $archlib = $Config{archlibexp};
-my $sitearch = $Config{sitearchexp};
-
-if ($DOSISH)
- {
- $archlib =~ s|\\|/|g;
- $sitearch =~ s|\\|/|g;
- }
-
-# Read the core packlist
-$self->{Perl}{packlist} =
- ExtUtils::Packlist->new( File::Spec->catfile($archlib, '.packlist') );
-$self->{Perl}{version} = $Config{version};
-
-# Read the module packlists
-my $sub = sub
- {
- # Only process module .packlists
- return if ($_) ne ".packlist" || $File::Find::dir eq $archlib;
-
- # Hack of the leading bits of the paths & convert to a module name
- my $module = $File::Find::name;
- $module =~ s!\Q$archlib\E/auto/(.*)/.packlist!$1!s;
- $module =~ s!\Q$sitearch\E/auto/(.*)/.packlist!$1!s;
- my $modfile = "$module.pm";
- $module =~ s!/!::!g;
-
- # Find the top-level module file in @INC
- $self->{$module}{version} = '';
- foreach my $dir (@INC)
- {
- my $p = File::Spec->catfile($dir, $modfile);
- if (-f $p)
- {
- $self->{$module}{version} = MM->parse_version($p);
- last;
- }
- }
-
- # Read the .packlist
- $self->{$module}{packlist} = ExtUtils::Packlist->new($File::Find::name);
- };
-find($sub, $archlib, $sitearch);
-
-return(bless($self, $class));
+ return(0);
}
-sub modules($)
-{
-my ($self) = @_;
-return(sort(keys(%$self)));
+sub new {
+ my ($class) = @_;
+ $class = ref($class) || $class;
+ my $self = {};
+
+ my $archlib = $Config{archlibexp};
+ my $sitearch = $Config{sitearchexp};
+
+ # File::Find does not know how to deal with VMS filepaths.
+ if( $^O eq 'VMS' ) {
+ $archlib = VMS::Filespec::unixify($archlib);
+ $sitearch = VMS::Filespec::unixify($sitearch);
+ }
+
+ if ($DOSISH) {
+ $archlib =~ s|\\|/|g;
+ $sitearch =~ s|\\|/|g;
+ }
+
+ # Read the core packlist
+ $self->{Perl}{packlist} =
+ ExtUtils::Packlist->new( File::Spec->catfile($archlib, '.packlist') );
+ $self->{Perl}{version} = $Config{version};
+
+ # Read the module packlists
+ my $sub = sub {
+ # Only process module .packlists
+ return if ($_) ne ".packlist" || $File::Find::dir eq $archlib;
+
+ # Hack of the leading bits of the paths & convert to a module name
+ my $module = $File::Find::name;
+
+ $module =~ s!\Q$archlib\E/?auto/(.*)/.packlist!$1!s or
+ $module =~ s!\Q$sitearch\E/?auto/(.*)/.packlist!$1!s;
+ my $modfile = "$module.pm";
+ $module =~ s!/!::!g;
+
+ # Find the top-level module file in @INC
+ $self->{$module}{version} = '';
+ foreach my $dir (@INC) {
+ my $p = File::Spec->catfile($dir, $modfile);
+ if (-f $p) {
+ require ExtUtils::MM;
+ $self->{$module}{version} = MM->parse_version($p);
+ last;
+ }
+ }
+
+ # Read the .packlist
+ $self->{$module}{packlist} =
+ ExtUtils::Packlist->new($File::Find::name);
+ };
+
+ my(@dirs) = grep { -e } ($archlib, $sitearch);
+ find($sub, @dirs) if @dirs;
+
+ return(bless($self, $class));
}
-sub files($$;$)
-{
-my ($self, $module, $type, @under) = @_;
-
-# Validate arguments
-Carp::croak("$module is not installed") if (! exists($self->{$module}));
-$type = "all" if (! defined($type));
-Carp::croak('type must be "all", "prog" or "doc"')
- if ($type ne "all" && $type ne "prog" && $type ne "doc");
-
-my (@files);
-foreach my $file (keys(%{$self->{$module}{packlist}}))
- {
- push(@files, $file)
- if ($self->_is_type($file, $type) && $self->_is_under($file, @under));
- }
-return(@files);
+sub modules {
+ my ($self) = @_;
+ return sort keys %$self;
}
-sub directories($$;$)
-{
-my ($self, $module, $type, @under) = @_;
-my (%dirs);
-foreach my $file ($self->files($module, $type, @under))
- {
- $dirs{dirname($file)}++;
- }
-return(sort(keys(%dirs)));
+sub files {
+ my ($self, $module, $type, @under) = @_;
+
+ # Validate arguments
+ Carp::croak("$module is not installed") if (! exists($self->{$module}));
+ $type = "all" if (! defined($type));
+ Carp::croak('type must be "all", "prog" or "doc"')
+ if ($type ne "all" && $type ne "prog" && $type ne "doc");
+
+ my (@files);
+ foreach my $file (keys(%{$self->{$module}{packlist}})) {
+ push(@files, $file)
+ if ($self->_is_type($file, $type) &&
+ $self->_is_under($file, @under));
+ }
+ return(@files);
}
-sub directory_tree($$;$)
-{
-my ($self, $module, $type, @under) = @_;
-my (%dirs);
-foreach my $dir ($self->directories($module, $type, @under))
- {
- $dirs{$dir}++;
- my ($last) = ("");
- while ($last ne $dir)
- {
- $last = $dir;
- $dir = dirname($dir);
- last if (! $self->_is_under($dir, @under));
- $dirs{$dir}++;
- }
- }
-return(sort(keys(%dirs)));
+sub directories {
+ my ($self, $module, $type, @under) = @_;
+ my (%dirs);
+ foreach my $file ($self->files($module, $type, @under)) {
+ $dirs{dirname($file)}++;
+ }
+ return sort keys %dirs;
}
-sub validate($;$)
-{
-my ($self, $module, $remove) = @_;
-Carp::croak("$module is not installed") if (! exists($self->{$module}));
-return($self->{$module}{packlist}->validate($remove));
+sub directory_tree {
+ my ($self, $module, $type, @under) = @_;
+ my (%dirs);
+ foreach my $dir ($self->directories($module, $type, @under)) {
+ $dirs{$dir}++;
+ my ($last) = ("");
+ while ($last ne $dir) {
+ $last = $dir;
+ $dir = dirname($dir);
+ last if !$self->_is_under($dir, @under);
+ $dirs{$dir}++;
+ }
+ }
+ return(sort(keys(%dirs)));
}
-sub packlist($$)
-{
-my ($self, $module) = @_;
-Carp::croak("$module is not installed") if (! exists($self->{$module}));
-return($self->{$module}{packlist});
+sub validate {
+ my ($self, $module, $remove) = @_;
+ Carp::croak("$module is not installed") if (! exists($self->{$module}));
+ return($self->{$module}{packlist}->validate($remove));
}
-sub version($$)
-{
-my ($self, $module) = @_;
-Carp::croak("$module is not installed") if (! exists($self->{$module}));
-return($self->{$module}{version});
+sub packlist {
+ my ($self, $module) = @_;
+ Carp::croak("$module is not installed") if (! exists($self->{$module}));
+ return($self->{$module}{packlist});
}
-sub DESTROY
-{
+sub version {
+ my ($self, $module) = @_;
+ Carp::croak("$module is not installed") if (! exists($self->{$module}));
+ return($self->{$module}{version});
}
+
1;
__END__