ExtUtils-InstallPaths-0.010/0000775000175000017500000000000012233714510014353 5ustar leonleonExtUtils-InstallPaths-0.010/INSTALL0000644000175000017500000000177112233714510015410 0ustar leonleon This is the Perl distribution ExtUtils-InstallPaths. Installing ExtUtils-InstallPaths is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm ExtUtils::InstallPaths If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S ExtUtils::InstallPaths ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan ExtUtils::InstallPaths ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install ## Documentation ExtUtils-InstallPaths documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc ExtUtils::InstallPaths ExtUtils-InstallPaths-0.010/t/0000775000175000017500000000000012233714510014616 5ustar leonleonExtUtils-InstallPaths-0.010/t/destinations.t0000644000175000017500000002202412233714510017505 0ustar leonleon#!/usr/bin/perl -w use strict; use warnings FATAL => 'all'; use Test::More tests => 105; use Config; use File::Temp (); use File::Spec::Functions ':ALL'; my $tmp = File::Temp::tempdir('EIP-XXXXXXXX', CLEANUP => 1, DIR => tmpdir); use ExtUtils::Config; use ExtUtils::InstallPaths; ######################### # We need to create a well defined environment to test install paths. # We do this by setting up appropriate Config entries. my @installstyle = qw(lib perl5); my $config = ExtUtils::Config->new({ installstyle => catdir(@installstyle), installprivlib => catdir($tmp, @installstyle), installarchlib => catdir($tmp, @installstyle, @Config{qw(version archname)}), installbin => catdir($tmp, 'bin'), installscript => catdir($tmp, 'bin'), installman1dir => catdir($tmp, 'man', 'man1'), installman3dir => catdir($tmp, 'man', 'man3'), installhtml1dir => catdir($tmp, 'html'), installhtml3dir => catdir($tmp, 'html'), installsitelib => catdir($tmp, 'site', @installstyle, 'site_perl'), installsitearch => catdir($tmp, 'site', @installstyle, 'site_perl', @Config{qw(version archname)}), installsitebin => catdir($tmp, 'site', 'bin'), installsitescript => catdir($tmp, 'site', 'bin'), installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'), installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'), installsitehtml1dir => catdir($tmp, 'site', 'html'), installsitehtml3dir => catdir($tmp, 'site', 'html'), }); sub get_ei { my %args = @_; return ExtUtils::InstallPaths->new(installdirs => 'site', config => $config, dist_name => 'ExtUtils-InstallPaths', %args); } isa_ok(get_ei, 'ExtUtils::InstallPaths'); { my $elem = catdir(rootdir, qw/foo bar/); my $ei = get_ei(install_path => { elem => $elem}); is($ei->install_path('elem'), $elem, ' can read stored path'); } { my $ei = get_ei(install_base => catdir(rootdir, 'bar'), install_base_relpaths => { 'elem' => catdir(qw/foo bar/) }); is($ei->install_base_relpaths('elem'), catdir(qw/foo bar/), ' can read stored path'); is($ei->install_destination('lib'), catdir(rootdir, qw/bar lib perl5/), 'destination of other items is not affected'); } { my $ei = eval { get_ei(prefix_relpaths => { 'site' => { 'elem' => catdir(rootdir, qw/foo bar/)} }) }; is ($ei, undef, '$ei undefined'); like($@, qr/Value must be a relative path/, ' emits error if path not relative'); } { my $ei = get_ei(prefix_relpaths => { site => { elem => catdir(qw/foo bar/) } }); my $path = $ei->prefix_relpaths('site', 'elem'); is($path, catdir(qw(foo bar)), ' can read stored path'); } # Check that we install into the proper default locations. { my $ei = get_ei(); test_install_destinations($ei, { lib => catdir($tmp, 'site', @installstyle, 'site_perl'), arch => catdir($tmp, 'site', @installstyle, 'site_perl', @Config{qw(version archname)}), bin => catdir($tmp, 'site', 'bin'), script => catdir($tmp, 'site', 'bin'), bindoc => catdir($tmp, 'site', 'man', 'man1'), libdoc => catdir($tmp, 'site', 'man', 'man3'), binhtml => catdir($tmp, 'site', 'html'), libhtml => catdir($tmp, 'site', 'html'), }, 'installdirs=site'); test_install_map($ei, { read => '', write => catfile($ei->install_destination('arch'), qw/auto ExtUtils InstallPaths .packlist/), catdir('blib', 'lib') => catdir($tmp, 'site', @installstyle, 'site_perl'), catdir('blib', 'arch') => catdir($tmp, 'site', @installstyle, 'site_perl', @Config{qw(version archname)}), catdir('blib', 'bin') => catdir($tmp, 'site', 'bin'), catdir('blib', 'script') => catdir($tmp, 'site', 'bin'), }, 'installdirs=site'); } # Is installdirs honored? { my $ei = get_ei(installdirs => 'core'); is($ei->installdirs, 'core'); test_install_destinations($ei, { lib => catdir($tmp, @installstyle), arch => catdir($tmp, @installstyle, @Config{qw(version archname)}), bin => catdir($tmp, 'bin'), script => catdir($tmp, 'bin'), bindoc => catdir($tmp, 'man', 'man1'), libdoc => catdir($tmp, 'man', 'man3'), binhtml => catdir($tmp, 'html'), libhtml => catdir($tmp, 'html'), }); } # Check install_base() { my $install_base = catdir('foo', 'bar'); my $ei = get_ei(install_base => $install_base); is($ei->prefix, undef); is($ei->install_base, $install_base); test_install_destinations($ei, { lib => catdir($install_base, 'lib', 'perl5'), arch => catdir($install_base, 'lib', 'perl5', $Config{archname}), bin => catdir($install_base, 'bin'), script => catdir($install_base, 'bin'), bindoc => catdir($install_base, 'man', 'man1'), libdoc => catdir($install_base, 'man', 'man3'), binhtml => catdir($install_base, 'html'), libhtml => catdir($install_base, 'html'), }); test_install_map($ei, { read => '', write => catfile($ei->install_destination('arch'), qw/auto ExtUtils InstallPaths .packlist/), catdir('blib', 'lib') => catdir($install_base, 'lib', 'perl5'), catdir('blib', 'arch') => catdir($install_base, 'lib', 'perl5', $Config{archname}), catdir('blib', 'bin') => catdir($install_base, 'bin'), catdir('blib', 'script') => catdir($install_base, 'bin'), }, 'install_base'); } # Basic prefix test. Ensure everything is under the prefix. { my $prefix = catdir(qw/some prefix/); my $ei = get_ei(prefix => $prefix); ok(!defined $ei->install_base, 'install_base is not defined'); is($ei->prefix, $prefix, "The prefix is $prefix"); test_prefix($ei, $prefix); # test_prefix($ei, $prefix, $ei->install_sets('site')); } # And now that prefix honors installdirs. { my $prefix = catdir(qw/some prefix/); my $ei = get_ei(prefix => $prefix, installdirs => 'core'); is($ei->installdirs, 'core'); test_prefix($ei, $prefix); } { my $ei = get_ei; # Try a config setting which would result in installation locations outside # the prefix. Ensure it doesn't. # Get the prefix defaults my @types = $ei->install_types; # Create a configuration involving weird paths that are outside of # the configured prefix. my @prefixes = ([qw(foo bar)], [qw(biz)], []); my %test_config; foreach my $type (@types) { my $prefix = shift @prefixes || [qw(foo bar)]; $test_config{$type} = catdir(rootdir, @$prefix, @{$ei->prefix_relpaths('site', $type)}); } # Poke at the innards of E::IP to change the default install locations. my $prefix = catdir('another', 'prefix'); my $config = ExtUtils::Config->new({ siteprefixexp => catdir(rootdir, 'wierd', 'prefix')}); $ei = get_ei(install_sets => { site => \%test_config }, config => $config, prefix => $prefix); test_prefix($ei, $prefix, \%test_config); } # Check that we can use install_base after setting prefix. { my $install_base = catdir('foo', 'bar'); my $ei = get_ei(install_base => $install_base, prefix => 'whatever'); test_install_destinations($ei, { lib => catdir($install_base, 'lib', 'perl5'), arch => catdir($install_base, 'lib', 'perl5', $Config{archname}), bin => catdir($install_base, 'bin'), script => catdir($install_base, 'bin'), bindoc => catdir($install_base, 'man', 'man1'), libdoc => catdir($install_base, 'man', 'man3'), binhtml => catdir($install_base, 'html'), libhtml => catdir($install_base, 'html'), }); } sub dir_contains { my ($first, $second) = @_; # File::Spec doesn't have an easy way to check whether one directory # is inside another, unfortunately. ($first, $second) = map { canonpath($_) } ($first, $second); my @first_dirs = splitdir($first); my @second_dirs = splitdir($second); return 0 if @second_dirs < @first_dirs; my $is_same = ( case_tolerant() ? sub { lc(shift()) eq lc(shift()) } : sub { shift() eq shift() }); while (@first_dirs) { return 0 unless $is_same->(shift @first_dirs, shift @second_dirs); } return 1; } sub test_prefix { my ($ei, $prefix, $test_config) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; foreach my $type (qw/lib arch bin script bindoc libdoc binhtml libhtml/) { my $dest = $ei->install_destination($type); ok dir_contains($prefix, $dest), "$type prefixed"; SKIP: { skip("'$type' not configured", 1) unless $test_config && $test_config->{$type}; have_same_ending($dest, $test_config->{$type}, " suffix correctish ($test_config->{$type} + $prefix = $dest)"); } } } sub have_same_ending { my ($dir1, $dir2, $message) = @_; $dir1 =~ s{/$}{} if $^O eq 'cygwin'; # remove any trailing slash my (undef, $dirs1, undef) = splitpath $dir1; my @dir1 = splitdir $dirs1; $dir2 =~ s{/$}{} if $^O eq 'cygwin'; # remove any trailing slash my (undef, $dirs2, undef) = splitpath $dir2; my @dir2 = splitdir $dirs2; is $dir1[-1], $dir2[-1], $message; } sub test_install_destinations { my ($build, $expect) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; while(my ($type, $expect) = each %$expect) { is($build->install_destination($type), $expect, "$type destination"); } } sub test_install_map { my ($paths, $expect, $case) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; my $map = $paths->install_map; while(my ($type, $expect) = each %$expect) { is($map->{$type}, $expect, "$type destination for $case"); } } ExtUtils-InstallPaths-0.010/t/release-pod-syntax.t0000644000175000017500000000045012233714510020524 0ustar leonleon#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); ExtUtils-InstallPaths-0.010/t/release-pod-coverage.t0000644000175000017500000000076512233714510021002 0ustar leonleon#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); ExtUtils-InstallPaths-0.010/t/00-compile.t0000644000175000017500000000167512233714510016657 0ustar leonleonuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.036 use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'ExtUtils/InstallPaths.pm' ); # no fake home requested my $inc_switch = q[-Mblib]; use File::Spec; use IPC::Open3; use IO::Handle; my @warnings; for my $lib (@module_files) { # see L open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; ExtUtils-InstallPaths-0.010/Makefile.PL0000644000175000017500000000321212233714510016321 0ustar leonleon use strict; use warnings; use 5.008001; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Build.PL install path logic made easy", "AUTHOR" => "Ken Williams , Leon Timmermans ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "ExtUtils-InstallPaths", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "ExtUtils::InstallPaths", "PREREQ_PM" => { "Carp" => 0, "ExtUtils::Config" => "0.002", "File::Spec" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0 }, "VERSION" => "0.010", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); ExtUtils-InstallPaths-0.010/lib/0000775000175000017500000000000012233714510015121 5ustar leonleonExtUtils-InstallPaths-0.010/lib/ExtUtils/0000775000175000017500000000000012233714510016702 5ustar leonleonExtUtils-InstallPaths-0.010/lib/ExtUtils/InstallPaths.pm0000644000175000017500000004743212233714510021656 0ustar leonleonpackage ExtUtils::InstallPaths; { $ExtUtils::InstallPaths::VERSION = '0.010'; } use 5.008001; use strict; use warnings; use File::Spec (); use Carp (); use ExtUtils::Config 0.002; my %complex_accessors = map { $_ => 1 } qw/prefix_relpaths install_sets/; my %hash_accessors = map { $_ => 1 } qw/install_path install_base_relpaths original_prefix /; my %defaults = ( installdirs => 'site', install_base => undef, prefix => undef, verbose => 0, blib => 'blib', create_packlist => 1, dist_name => undef, module_name => undef, destdir => undef, install_path => sub { {} }, install_sets => \&_default_install_sets, original_prefix => \&_default_original_prefix, install_base_relpaths => \&_default_base_relpaths, prefix_relpaths => \&_default_prefix_relpaths, ); sub _merge_shallow { my ($name, $filter) = @_; return sub { my ($override, $config) = @_; my $defaults = $defaults{$name}->($config); $filter->($_) for grep $filter, values %$override; return { %$defaults, %$override }; } } sub _merge_deep { my ($name, $filter) = @_; return sub { my ($override, $config) = @_; my $defaults = $defaults{$name}->($config); my $pair_for = sub { my $key = shift; my %override = %{ $override->{$key} || {} }; $filter && $filter->($_) for values %override; return $key => { %{ $defaults->{$key} }, %override }; }; return { map { $pair_for->($_) } keys %$defaults }; } } my %allowed_installdir = map { $_ => 1 } qw/core site vendor/; my $must_be_relative = sub { Carp::croak('Value must be a relative path') if File::Spec->file_name_is_absolute($_[0]) }; my %deep_filter = map { $_ => $must_be_relative } qw/install_base_relpaths prefix_relpaths/; my %filter = ( installdirs => sub { my $value = shift; $value = 'core', Carp::carp('Perhaps you meant installdirs to be "core" rather than "perl"?') if $value eq 'perl'; Carp::croak('installdirs must be one of "core", "site", or "vendor"') if not $allowed_installdir{$value}; return $value; }, (map { $_ => _merge_shallow($_, $deep_filter{$_}) } qw/original_prefix install_base_relpaths/), (map { $_ => _merge_deep($_, $deep_filter{$_}) } qw/install_sets prefix_relpaths/), ); for my $attribute (keys %defaults) { no strict qw/refs/; *{$attribute} = $hash_accessors{$attribute} ? sub { my ($self, $key) = @_; Carp::confess("$attribute needs key") if not defined $key; return $self->{$attribute}{$key}; } : $complex_accessors{$attribute} ? sub { my ($self, $installdirs, $key) = @_; Carp::confess("$attribute needs installdir") if not defined $installdirs; Carp::confess("$attribute needs key") if not defined $key; return $self->{$attribute}{$installdirs}{$key}; } : sub { my $self = shift; return $self->{$attribute}; }; } sub new { my ($class, %args) = @_; my $config = $args{config} || ExtUtils::Config->new; my %self = ( config => $config, map { $_ => exists $args{$_} ? $filter{$_} ? $filter{$_}->($args{$_}, $config) : $args{$_} : ref $defaults{$_} ? $defaults{$_}->($config) : $defaults{$_} } keys %defaults, ); $self{module_name} ||= do { my $module_name = $self{dist_name}; $module_name =~ s/-/::/g; $module_name } if defined $self{dist_name}; return bless \%self, $class; } my @install_sets_keys = qw/lib arch bin script bindoc libdoc binhtml libhtml/; my @install_sets_tail = qw/bin script man1dir man3dir html1dir html3dir/; my %install_sets_values = ( core => [ qw/privlib archlib /, @install_sets_tail ], site => [ map { "site$_" } qw/lib arch/, @install_sets_tail ], vendor => [ map { "vendor$_" } qw/lib arch/, @install_sets_tail ], ); sub _default_install_sets { my $c = shift; my %ret; for my $installdir (qw/core site vendor/) { @{$ret{$installdir}}{@install_sets_keys} = map { $c->get("install$_") } @{ $install_sets_values{$installdir} }; } return \%ret; } sub _default_base_relpaths { my $config = shift; return { lib => ['lib', 'perl5'], arch => ['lib', 'perl5', $config->get('archname')], bin => ['bin'], script => ['bin'], bindoc => ['man', 'man1'], libdoc => ['man', 'man3'], binhtml => ['html'], libhtml => ['html'], }; } my %common_prefix_relpaths = ( bin => ['bin'], script => ['bin'], bindoc => ['man', 'man1'], libdoc => ['man', 'man3'], binhtml => ['html'], libhtml => ['html'], ); sub _default_prefix_relpaths { my $c = shift; my @libstyle = $c->get('installstyle') ? File::Spec->splitdir($c->get('installstyle')) : qw(lib perl5); my $arch = $c->get('archname'); my $version = $c->get('version'); return { core => { lib => [@libstyle], arch => [@libstyle, $version, $arch], %common_prefix_relpaths, }, vendor => { lib => [@libstyle], arch => [@libstyle, $version, $arch], %common_prefix_relpaths, }, site => { lib => [@libstyle, 'site_perl'], arch => [@libstyle, 'site_perl', $version, $arch], %common_prefix_relpaths, }, }; } sub _default_original_prefix { my $c = shift; my %ret = ( core => $c->get('installprefixexp'), site => $c->get('siteprefixexp'), vendor => $c->get('usevendorprefix') ? $c->get('vendorprefixexp') : '', ); return \%ret; } sub _log_verbose { my $self = shift; print @_ if $self->verbose; return; } # Given a file type, will return true if the file type would normally # be installed when neither install-base nor prefix has been set. # I.e. it will be true only if the path is set from Config.pm or # set explicitly by the user via install-path. sub is_default_installable { my $self = shift; my $type = shift; my $installable = $self->install_destination($type) && ( $self->install_path($type) || $self->install_sets($self->installdirs, $type)); return $installable ? 1 : 0; } sub _prefixify_default { my $self = shift; my $type = shift; my $rprefix = shift; my $default = $self->prefix_relpaths($self->installdirs, $type); if( !$default ) { $self->_log_verbose(" no default install location for type '$type', using prefix '$rprefix'.\n"); return $rprefix; } else { return File::Spec->catdir(@{$default}); } } # Translated from ExtUtils::MM_Unix::prefixify() sub _prefixify_novms { my($self, $path, $sprefix, $type) = @_; my $rprefix = $self->prefix; $rprefix .= '/' if $sprefix =~ m{/$}; $self->_log_verbose(" prefixify $path from $sprefix to $rprefix\n") if defined $path && length $path; if (not defined $path or length $path == 0 ) { $self->_log_verbose(" no path to prefixify, falling back to default.\n"); return $self->_prefixify_default( $type, $rprefix ); } elsif( !File::Spec->file_name_is_absolute($path) ) { $self->_log_verbose(" path is relative, not prefixifying.\n"); } elsif( $path !~ s{^\Q$sprefix\E\b}{}s ) { $self->_log_verbose(" cannot prefixify, falling back to default.\n"); return $self->_prefixify_default( $type, $rprefix ); } $self->_log_verbose(" now $path in $rprefix\n"); return $path; } sub _catprefix_vms { my ($self, $rprefix, $default) = @_; my ($rvol, $rdirs) = File::Spec->splitpath($rprefix); if ($rvol) { return File::Spec->catpath($rvol, File::Spec->catdir($rdirs, $default), ''); } else { return File::Spec->catdir($rdirs, $default); } } sub _prefixify_vms { my($self, $path, $sprefix, $type) = @_; my $rprefix = $self->prefix; return '' unless defined $path; $self->_log_verbose(" prefixify $path from $sprefix to $rprefix\n"); require VMS::Filespec; # Translate $(PERLPREFIX) to a real path. $rprefix = VMS::Filespec::vmspath($rprefix) if $rprefix; $sprefix = VMS::Filespec::vmspath($sprefix) if $sprefix; $self->_log_verbose(" rprefix translated to $rprefix\n sprefix translated to $sprefix\n"); if (length($path) == 0 ) { $self->_log_verbose(" no path to prefixify.\n") } elsif (!File::Spec->file_name_is_absolute($path)) { $self->_log_verbose(" path is relative, not prefixifying.\n"); } elsif ($sprefix eq $rprefix) { $self->_log_verbose(" no new prefix.\n"); } else { my ($path_vol, $path_dirs) = File::Spec->splitpath( $path ); my $vms_prefix = $self->config->get('vms_prefix'); if ($path_vol eq $vms_prefix.':') { $self->_log_verbose(" $vms_prefix: seen\n"); $path_dirs =~ s{^\[}{\[.} unless $path_dirs =~ m{^\[\.}; $path = $self->_catprefix_vms($rprefix, $path_dirs); } else { $self->_log_verbose(" cannot prefixify.\n"); return File::Spec->catdir($self->prefix_relpaths($self->installdirs, $type)); } } $self->_log_verbose(" now $path\n"); return $path; } BEGIN { *_prefixify = $^O eq 'VMS' ? \&_prefixify_vms : \&_prefixify_novms } # Translated from ExtUtils::MM_Any::init_INSTALL_from_PREFIX sub prefix_relative { my ($self, $installdirs, $type) = @_; my $relpath = $self->install_sets($installdirs, $type); return $self->_prefixify($relpath, $self->original_prefix($installdirs), $type); } sub install_destination { my ($self, $type) = @_; return $self->install_path($type) if $self->install_path($type); if ( $self->install_base ) { my $relpath = $self->install_base_relpaths($type); return $relpath ? File::Spec->catdir($self->install_base, @{$relpath}) : undef; } if ( $self->prefix ) { my $relpath = $self->prefix_relative($self->installdirs, $type); return $relpath ? File::Spec->catdir($self->prefix, $relpath) : undef; } return $self->install_sets($self->installdirs, $type); } sub install_types { my $self = shift; my %types = ( %{ $self->{install_path} }, $self->install_base ? %{ $self->{install_base_relpaths} } : $self->prefix ? %{ $self->{prefix_relpaths}{ $self->installdirs } } : %{ $self->{install_sets}{ $self->installdirs } }); return sort keys %types; } sub install_map { my ($self, $blib) = @_; $blib ||= $self->blib; my (%map, @skipping); foreach my $type ($self->install_types) { my $localdir = File::Spec->catdir($blib, $type); next unless -e $localdir; # the line "...next if (($type eq 'bindoc'..." was one of many changes introduced for # improving HTML generation on ActivePerl, see https://rt.cpan.org/Public/Bug/Display.html?id=53478 # Most changes were ok, but this particular line caused test failures in t/manifypods.t on windows, # therefore it is commented out. # ********* next if (($type eq 'bindoc' || $type eq 'libdoc') && not $self->is_unixish); if (my $dest = $self->install_destination($type)) { $map{$localdir} = $dest; } else { push @skipping, $type; } } warn "WARNING: Can't figure out install path for types: @skipping\nFiles will not be installed.\n" if @skipping; # Write the packlist into the same place as ExtUtils::MakeMaker. if ($self->create_packlist and my $module_name = $self->module_name) { my $archdir = $self->install_destination('arch'); my @ext = split /::/, $module_name; $map{write} = File::Spec->catfile($archdir, 'auto', @ext, '.packlist'); } # Handle destdir if (length(my $destdir = $self->destdir || '')) { foreach (keys %map) { # Need to remove volume from $map{$_} using splitpath, or else # we'll create something crazy like C:\Foo\Bar\E:\Baz\Quux # VMS will always have the file separate than the path. my ($volume, $path, $file) = File::Spec->splitpath( $map{$_}, 0 ); # catdir needs a list of directories, or it will create something # crazy like volume:[Foo.Bar.volume.Baz.Quux] my @dirs = File::Spec->splitdir($path); # First merge the directories $path = File::Spec->catdir($destdir, @dirs); # Then put the file back on if there is one. if ($file ne '') { $map{$_} = File::Spec->catfile($path, $file) } else { $map{$_} = $path; } } } $map{read} = ''; # To keep ExtUtils::Install quiet return \%map; } 1; # ABSTRACT: Build.PL install path logic made easy __END__ =pod =head1 NAME ExtUtils::InstallPaths - Build.PL install path logic made easy =head1 VERSION version 0.010 =head1 SYNOPSIS use ExtUtils::InstallPaths; use ExtUtils::Install 'install'; GetOptions(\my %opt, 'install_base=s', 'install_path=s%', 'installdirs=s', 'destdir=s', 'prefix=s', 'uninst:1', 'verbose:1'); my $paths = ExtUtils::InstallPaths->new(%opt, dist_name => $dist_name); install($paths->install_map, $opt{verbose}, 0, $opt{uninst}); =head1 DESCRIPTION This module tries to make install path resolution as easy as possible. When you want to install a module, it needs to figure out where to install things. The nutshell version of how this works is that default installation locations are determined from L, and they may be individually overridden by using the C attribute. An C attribute lets you specify an alternative installation root like F and C does something similar in a rather different (and more complicated) way. C lets you specify a temporary installation directory like F in case you want to create bundled-up installable packages. The following types are supported by default. =over 4 =item * lib Usually pure-Perl module files ending in F<.pm> or F<.pod>. =item * arch "Architecture-dependent" module files, usually produced by compiling XS, L, or similar code. =item * script Programs written in pure Perl. In order to improve reuse, you may want to make these as small as possible - put the code into modules whenever possible. =item * bin "Architecture-dependent" executable programs, i.e. compiled C code or something. Pretty rare to see this in a perl distribution, but it happens. =item * bindoc Documentation for the stuff in C