[Rt-commit] r14648 - in rtfm/trunk: . inc/Module/Install
falcone at bestpractical.com
falcone at bestpractical.com
Wed Jul 30 15:53:02 EDT 2008
Author: falcone
Date: Wed Jul 30 15:52:59 2008
New Revision: 14648
Modified:
rtfm/trunk/ (props changed)
rtfm/trunk/inc/Module/Install.pm
rtfm/trunk/inc/Module/Install/AutoInstall.pm
rtfm/trunk/inc/Module/Install/Base.pm
rtfm/trunk/inc/Module/Install/Can.pm
rtfm/trunk/inc/Module/Install/Fetch.pm
rtfm/trunk/inc/Module/Install/Include.pm
rtfm/trunk/inc/Module/Install/Makefile.pm
rtfm/trunk/inc/Module/Install/Metadata.pm
rtfm/trunk/inc/Module/Install/RTx.pm
rtfm/trunk/inc/Module/Install/Win32.pm
rtfm/trunk/inc/Module/Install/WriteAll.pm
Log:
r36362 at ketch: falcone | 2008-07-29 15:43:38 -0400
* update Module::Install and Module::Install::RTx
Modified: rtfm/trunk/inc/Module/Install.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install.pm (original)
+++ rtfm/trunk/inc/Module/Install.pm Wed Jul 30 15:52:59 2008
@@ -30,11 +30,7 @@
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.72';
-
- *inc::Module::Install::VERSION = *VERSION;
- @inc::Module::Install::ISA = __PACKAGE__;
-
+ $VERSION = '0.70';
}
@@ -99,20 +95,14 @@
-# To save some more typing in Module::Install installers, every...
-# use inc::Module::Install
-# ...also acts as an implicit use strict.
-$^H |= strict::bits(qw(refs subs vars));
-
-
-
-
-
use Cwd ();
use File::Find ();
use File::Path ();
use FindBin;
+*inc::Module::Install::VERSION = *VERSION;
+ at inc::Module::Install::ISA = __PACKAGE__;
+
sub autoload {
my $self = shift;
my $who = $self->_caller;
@@ -155,7 +145,8 @@
}
sub preload {
- my $self = shift;
+ my ($self) = @_;
+
unless ( $self->{extensions} ) {
$self->load_extensions(
"$self->{prefix}/$self->{path}", $self
@@ -211,7 +202,6 @@
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
- $args{wrote} = 0;
bless( \%args, $class );
}
@@ -287,9 +277,9 @@
# correctly. Otherwise, root through the file to locate the case-preserved
# version of the package name.
if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
- my $content = Module::Install::_read($subpath . '.pm');
- my $in_pod = 0;
- foreach ( split //, $content ) {
+ open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $subpath.pm: $!";
+ my $in_pod = 0;
+ while ( <PKGFILE> ) {
$in_pod = 1 if /^=\w/;
$in_pod = 0 if /^=cut/;
next if ($in_pod || /^=cut/); # skip pod text
@@ -299,6 +289,7 @@
last;
}
}
+ close PKGFILE;
}
push @found, [ $file, $pkg ];
@@ -307,13 +298,6 @@
@found;
}
-
-
-
-
-#####################################################################
-# Utility Functions
-
sub _caller {
my $depth = 0;
my $call = caller($depth);
@@ -324,30 +308,6 @@
return $call;
}
-sub _read {
- local *FH;
- open FH, "< $_[0]" or die "open($_[0]): $!";
- my $str = do { local $/; <FH> };
- close FH or die "close($_[0]): $!";
- return $str;
-}
-
-sub _write {
- local *FH;
- open FH, "> $_[0]" or die "open($_[0]): $!";
- foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" }
- close FH or die "close($_[0]): $!";
-}
-
-sub _version {
- my $s = shift || 0;
- $s =~ s/^(\d+)\.?//;
- my $l = $1 || 0;
- my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g;
- $l = $l . '.' . join '', @v if @v;
- return $l + 0;
-}
-
1;
# Copyright 2008 Adam Kennedy.
Modified: rtfm/trunk/inc/Module/Install/AutoInstall.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/AutoInstall.pm (original)
+++ rtfm/trunk/inc/Module/Install/AutoInstall.pm Wed Jul 30 15:52:59 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.68';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: rtfm/trunk/inc/Module/Install/Base.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Base.pm (original)
+++ rtfm/trunk/inc/Module/Install/Base.pm Wed Jul 30 15:52:59 2008
@@ -1,7 +1,7 @@
#line 1
package Module::Install::Base;
-$VERSION = '0.72';
+$VERSION = '0.70';
# Suspend handler for "redefined" warnings
BEGIN {
Modified: rtfm/trunk/inc/Module/Install/Can.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Can.pm (original)
+++ rtfm/trunk/inc/Module/Install/Can.pm Wed Jul 30 15:52:59 2008
@@ -11,7 +11,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: rtfm/trunk/inc/Module/Install/Fetch.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Fetch.pm (original)
+++ rtfm/trunk/inc/Module/Install/Fetch.pm Wed Jul 30 15:52:59 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: rtfm/trunk/inc/Module/Install/Include.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Include.pm (original)
+++ rtfm/trunk/inc/Module/Install/Include.pm Wed Jul 30 15:52:59 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: rtfm/trunk/inc/Module/Install/Makefile.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Makefile.pm (original)
+++ rtfm/trunk/inc/Module/Install/Makefile.pm Wed Jul 30 15:52:59 2008
@@ -7,7 +7,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
@@ -63,18 +63,18 @@
sub clean_files {
my $self = shift;
my $clean = $self->makemaker_args->{clean} ||= {};
- %$clean = (
+ %$clean = (
%$clean,
- FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_),
+ FILES => join(' ', grep length, $clean->{FILES}, @_),
);
}
sub realclean_files {
- my $self = shift;
+ my $self = shift;
my $realclean = $self->makemaker_args->{realclean} ||= {};
- %$realclean = (
+ %$realclean = (
%$realclean,
- FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_),
+ FILES => join(' ', grep length, $realclean->{FILES}, @_),
);
}
@@ -121,8 +121,8 @@
# Generate the
my $args = $self->makemaker_args;
$args->{DISTNAME} = $self->name;
- $args->{NAME} = $self->module_name || $self->name;
- $args->{VERSION} = $self->version;
+ $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+ $args->{VERSION} = $self->version || $self->determine_VERSION($args);
$args->{NAME} =~ s/-/::/g;
if ( $self->tests ) {
$args->{test} = { TESTS => $self->tests };
Modified: rtfm/trunk/inc/Module/Install/Metadata.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Metadata.pm (original)
+++ rtfm/trunk/inc/Module/Install/Metadata.pm Wed Jul 30 15:52:59 2008
@@ -6,30 +6,18 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
my @scalar_keys = qw{
- name
- module_name
- abstract
- author
- version
- license
- distribution_type
- perl_version
- tests
- installdirs
+ name module_name abstract author version license
+ distribution_type perl_version tests installdirs
};
my @tuple_keys = qw{
- configure_requires
- build_requires
- requires
- recommends
- bundles
+ configure_requires build_requires requires recommends bundles
};
sub Meta { shift }
@@ -45,60 +33,33 @@
};
}
-sub requires {
- my $self = shift;
- while ( @_ ) {
- my $module = shift or last;
- my $version = shift || 0;
- push @{ $self->{values}->{requires} }, [ $module, $version ];
- }
- $self->{values}{requires};
-}
-
-sub build_requires {
- my $self = shift;
- while ( @_ ) {
- my $module = shift or last;
- my $version = shift || 0;
- push @{ $self->{values}->{build_requires} }, [ $module, $version ];
- }
- $self->{values}{build_requires};
-}
-
-sub configure_requires {
- my $self = shift;
- while ( @_ ) {
- my $module = shift or last;
- my $version = shift || 0;
- push @{ $self->{values}->{configure_requires} }, [ $module, $version ];
- }
- $self->{values}{configure_requires};
-}
-
-sub recommends {
- my $self = shift;
- while ( @_ ) {
- my $module = shift or last;
- my $version = shift || 0;
- push @{ $self->{values}->{recommends} }, [ $module, $version ];
- }
- $self->{values}{recommends};
-}
+foreach my $key (@tuple_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{values}{$key} unless @_;
-sub bundles {
- my $self = shift;
- while ( @_ ) {
- my $module = shift or last;
- my $version = shift || 0;
- push @{ $self->{values}->{bundles} }, [ $module, $version ];
- }
- $self->{values}{bundles};
+ my @rv;
+ while (@_) {
+ my $module = shift or last;
+ my $version = shift || 0;
+ if ( $module eq 'perl' ) {
+ $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+ {$1 + $2/1_000 + $3/1_000_000}e;
+ $self->perl_version($version);
+ next;
+ }
+ my $rv = [ $module, $version ];
+ push @rv, $rv;
+ }
+ push @{ $self->{values}{$key} }, @rv;
+ @rv;
+ };
}
# Aliases for build_requires that will have alternative
# meanings in some future version of META.yml.
-sub test_requires { shift->build_requires(@_) }
-sub install_requires { shift->build_requires(@_) }
+sub test_requires { shift->build_requires(@_) }
+sub install_requires { shift->build_requires(@_) }
# Aliases for installdirs options
sub install_as_core { $_[0]->installdirs('perl') }
@@ -119,7 +80,7 @@
warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
return $self;
}
- $self->{values}{dynamic_config} = $_[0] ? 1 : 0;
+ $self->{'values'}{'dynamic_config'} = $_[0] ? 1 : 0;
return $self;
}
@@ -134,21 +95,19 @@
die "all_from: cannot find $file from $name" unless -e $file;
}
- # Some methods pull from POD instead of code.
- # If there is a matching .pod, use that instead
- my $pod = $file;
- $pod =~ s/\.pm$/.pod/i;
- $pod = $file unless -e $pod;
-
- # Pull the different values
- $self->name_from($file) unless $self->name;
$self->version_from($file) unless $self->version;
$self->perl_version_from($file) unless $self->perl_version;
- $self->author_from($pod) unless $self->author;
- $self->license_from($pod) unless $self->license;
- $self->abstract_from($pod) unless $self->abstract;
- return 1;
+ # The remaining probes read from POD sections; if the file
+ # has an accompanying .pod, use that instead
+ my $pod = $file;
+ if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
+ $file = $pod;
+ }
+
+ $self->author_from($file) unless $self->author;
+ $self->license_from($file) unless $self->license;
+ $self->abstract_from($file) unless $self->abstract;
}
sub provides {
@@ -224,10 +183,10 @@
sub read {
my $self = shift;
- $self->include_deps( 'YAML::Tiny', 0 );
+ $self->include_deps( 'YAML', 0 );
- require YAML::Tiny;
- my $data = YAML::Tiny::LoadFile('META.yml');
+ require YAML;
+ my $data = YAML::LoadFile('META.yml');
# Call methods explicitly in case user has already set some values.
while ( my ( $key, $value ) = each %$data ) {
@@ -267,29 +226,16 @@
);
}
-sub name_from {
- my $self = shift;
- if (
- Module::Install::_read($_[0]) =~ m/
- ^ \s*
- package \s*
- ([\w:]+)
- \s* ;
- /ixms
- ) {
- my $name = $1;
- $name =~ s{::}{-}g;
- $self->name($name);
- } else {
- die "Cannot determine name from $_[0]\n";
- return;
- }
+sub _slurp {
+ local *FH;
+ open FH, "< $_[1]" or die "Cannot open $_[1].pod: $!";
+ do { local $/; <FH> };
}
sub perl_version_from {
- my $self = shift;
+ my ( $self, $file ) = @_;
if (
- Module::Install::_read($_[0]) =~ m/
+ $self->_slurp($file) =~ m/
^
use \s*
v?
@@ -297,18 +243,18 @@
\s* ;
/ixms
) {
- my $perl_version = $1;
- $perl_version =~ s{_}{}g;
- $self->perl_version($perl_version);
+ my $v = $1;
+ $v =~ s{_}{}g;
+ $self->perl_version($1);
} else {
- warn "Cannot determine perl version info from $_[0]\n";
+ warn "Cannot determine perl version info from $file\n";
return;
}
}
sub author_from {
- my $self = shift;
- my $content = Module::Install::_read($_[0]);
+ my ( $self, $file ) = @_;
+ my $content = $self->_slurp($file);
if ($content =~ m/
=head \d \s+ (?:authors?)\b \s*
([^\n]*)
@@ -322,14 +268,15 @@
$author =~ s{E<gt>}{>}g;
$self->author($author);
} else {
- warn "Cannot determine author info from $_[0]\n";
+ warn "Cannot determine author info from $file\n";
}
}
sub license_from {
- my $self = shift;
+ my ( $self, $file ) = @_;
+
if (
- Module::Install::_read($_[0]) =~ m/
+ $self->_slurp($file) =~ m/
(
=head \d \s+
(?:licen[cs]e|licensing|copyright|legal)\b
@@ -364,23 +311,8 @@
}
}
- warn "Cannot determine license info from $_[0]\n";
+ warn "Cannot determine license info from $file\n";
return 'unknown';
}
-sub install_script {
- my $self = shift;
- my $args = $self->makemaker_args;
- my $exe = $args->{EXE_FILES} ||= [];
- foreach ( @_ ) {
- if ( -f $_ ) {
- push @$exe, $_;
- } elsif ( -d 'script' and -f "script/$_" ) {
- push @$exe, "script/$_";
- } else {
- die "Cannot find script '$_'";
- }
- }
-}
-
1;
Modified: rtfm/trunk/inc/Module/Install/RTx.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/RTx.pm (original)
+++ rtfm/trunk/inc/Module/Install/RTx.pm Wed Jul 30 15:52:59 2008
@@ -14,6 +14,9 @@
use File::Glob ();
use File::Basename ();
+my @DIRS = qw(etc lib html bin sbin po var);
+my @INDEX_DIRS = qw(lib bin sbin);
+
sub RTx {
my ( $self, $name ) = @_;
@@ -60,8 +63,8 @@
$RT::LocalVarPath ||= $RT::VarPath;
$RT::LocalPoPath ||= $RT::LocalLexiconPath;
$RT::LocalHtmlPath ||= $RT::MasonComponentRoot;
+ $RT::LocalLibPath ||= "$RT::LocalPath/lib";
- my %path;
my $with_subdirs = $ENV{WITH_SUBDIRS};
@ARGV = grep { /WITH_SUBDIRS=(.*)/ ? ( ( $with_subdirs = $1 ), 0 ) : 1 }
@ARGV;
@@ -69,36 +72,38 @@
my %subdirs;
%subdirs = map { $_ => 1 } split( /\s*,\s*/, $with_subdirs )
if defined $with_subdirs;
-
- foreach (qw(bin etc html po sbin var)) {
- next unless -d "$FindBin::Bin/$_";
- next if keys %subdirs and !$subdirs{$_};
- $self->no_index( directory => $_ );
-
- no strict 'refs';
- my $varname = "RT::Local" . ucfirst($_) . "Path";
- $path{$_} = ${$varname} || "$RT::LocalPath/$_";
+ unless ( keys %subdirs ) {
+ $subdirs{$_} = 1 foreach grep -d "$FindBin::Bin/$_", @DIRS;
}
- $path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
- $path{lib} = "$RT::LocalPath/lib" unless keys %subdirs and !$subdirs{'lib'};
-
# If we're running on RT 3.8 with plugin support, we really wany
# to install libs, mason templates and po files into plugin specific
# directories
- if ($RT::LocalPluginPath) {
- foreach my $path (qw(lib po html etc bin sbin)) {
- next unless -d "$FindBin::Bin/$path";
- next if %subdirs and !$subdirs{$path};
- $path{$path} = $RT::LocalPluginPath . "/$original_name/$path";
+ my %path;
+ if ( $RT::LocalPluginPath ) {
+ $path{$_} = $RT::LocalPluginPath . "/$original_name/$_"
+ foreach @DIRS;
+ } else {
+ foreach ( @DIRS ) {
+ no strict 'refs';
+ my $varname = "RT::Local" . ucfirst($_) . "Path";
+ $path{$_} = ${$varname} || "$RT::LocalPath/$_";
}
+
+ $path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
}
- my $args = join( ', ', map "q($_)", %path );
- print "./$_\t=> $path{$_}\n" for sort keys %path;
+ my %index = map { $_ => 1 } @INDEX_DIRS;
+ $self->no_index( directory => $_ ) foreach grep !$index{$_}, @DIRS;
+
+ my $args = join ', ', map "q($_)", map { ($_, $path{$_}) }
+ grep $subdirs{$_}, keys %path;
- if ( my @dirs = map { ( -D => $_ ) } grep $path{$_}, qw(bin html sbin) ) {
- my @po = map { ( -o => $_ ) } grep -f,
+ print "./$_\t=> $path{$_}\n" for sort keys %subdirs;
+
+ if ( my @dirs = map { ( -D => $_ ) } grep $subdirs{$_}, qw(bin html sbin) ) {
+ my @po = map { ( -o => $_ ) }
+ grep -f,
File::Glob::bsd_glob("po/*.po");
$self->postamble(<< ".") if @po;
lexicons ::
@@ -111,7 +116,7 @@
\t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
.
- if ( $path{var} and -d $RT::MasonDataDir ) {
+ if ( $subdirs{var} and -d $RT::MasonDataDir ) {
my ( $uid, $gid ) = ( stat($RT::MasonDataDir) )[ 4, 5 ];
$postamble .= << ".";
\t\$(NOECHO) chown -R $uid:$gid $path{var}
@@ -139,16 +144,17 @@
if ( -e 'etc/initialdata' ) { $has_etc{initialdata}++; }
$self->postamble("$postamble\n");
- if ( %subdirs and !$subdirs{'lib'} ) {
+ unless ( $subdirs{'lib'} ) {
$self->makemaker_args( PM => { "" => "" }, );
} else {
- $self->makemaker_args( INSTALLSITELIB => "$RT::LocalPath/lib" );
+ $self->makemaker_args( INSTALLSITELIB => $path{'lib'} );
+ $self->makemaker_args( INSTALLARCHLIB => $path{'lib'} );
}
- $self->makemaker_args( INSTALLSITEMAN1DIR => "$RT::LocalPath/man/man1" );
- $self->makemaker_args( INSTALLSITEMAN3DIR => "$RT::LocalPath/man/man3" );
- $self->makemaker_args( INSTALLSITEARCH => "$RT::LocalPath/man" );
- $self->makemaker_args( INSTALLARCHLIB => "$RT::LocalPath/lib" );
+ $self->makemaker_args( INSTALLSITEMAN1DIR => "$RT::LocalPath/man/man1" );
+ $self->makemaker_args( INSTALLSITEMAN3DIR => "$RT::LocalPath/man/man3" );
+ $self->makemaker_args( INSTALLSITEARCH => "$RT::LocalPath/man" );
+
if (%has_etc) {
$self->load('RTxInitDB');
print "For first-time installation, type 'make initdb'.\n";
@@ -180,4 +186,4 @@
__END__
-#line 281
+#line 282
Modified: rtfm/trunk/inc/Module/Install/Win32.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/Win32.pm (original)
+++ rtfm/trunk/inc/Module/Install/Win32.pm Wed Jul 30 15:52:59 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
Modified: rtfm/trunk/inc/Module/Install/WriteAll.pm
==============================================================================
--- rtfm/trunk/inc/Module/Install/WriteAll.pm (original)
+++ rtfm/trunk/inc/Module/Install/WriteAll.pm Wed Jul 30 15:52:59 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.72';
+ $VERSION = '0.70';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
More information about the Rt-commit
mailing list