/usr/share/perl5/Module/Install/Admin/Include.pm is in libmodule-install-perl 1.16-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | package Module::Install::Admin::Include;
use strict;
use Module::Install::Base;
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.16';
@ISA = qw{Module::Install::Base};
}
sub include {
my $self = shift;
foreach my $rv ( $self->admin->glob_in_inc($_[0]) ) {
$self->admin->copy_package(@$rv);
my @build_requires;
foreach (@{ $self->build_requires || [] }) {
next if $_->[0] eq $rv->[0];
push @build_requires, $_;
}
$self->Meta->{values}{build_requires} = \@build_requires;
}
}
sub include_deps {
my ($self, $module, $version) = @_;
my $deps = $self->admin->scan_dependencies($module, $self->perl_version, $version) or return;
foreach my $key ( sort keys %$deps ) {
$self->include($key);
}
}
sub auto_include {
my $self = shift;
foreach my $module (
map { $_->[0] }
map { @$_ }
grep { $_ }
$self->build_requires
) {
$self->include($module);
}
}
sub auto_include_deps {
my $self = shift;
foreach my $module (
map { $_ }
map { @$_ }
grep { $_ }
$self->build_requires
) {
my ($name, $version) = @{$module};
$self->include_deps($name, $version);
}
}
=pod
=head1 NAME
Module::Install::Admin::Include - include methods for Module::Install
=head2 auto_include_dependent_dists
Grabs everything in this module's build_requires and attempts to
include everything (at the whole distribution level) recursively.
=cut
sub auto_include_dependent_dists {
my $self = shift;
foreach my $module (
map { $_->[0] }
map { @$_ }
grep { $_ }
$self->build_requires
) {
$self->include_dependent_dists($module);
}
}
=pod
=head2 include_dependent_dists $package
Given a module package name, recursively include every package that
module needs.
=cut
sub include_dependent_dists {
my $self = shift;
my $pkg = shift;
return unless $pkg;
return if $self->{including_dep_dist}->{ $self->_pkg_to_dist($pkg) }++;
$self->include_one_dist($pkg);
foreach my $mod ( @{ $self->_dist_to_mods( $self->_pkg_to_dist($pkg) ) } ) {
my $deps = $self->admin->scan_dependencies($mod) or return;
foreach my $key ( sort grep { $_ } keys %$deps ) {
$self->include_dependent_dists($key);
}
}
}
=pod
=head2 include_one_dist $module
Given a module name, C<$module>, figures out which modules are in the
dist containing that module and copies all those files to ./inc. I bet
there's a way to harness smarter logic from L<PAR>.
=cut
sub include_one_dist {
my $self = shift;
my @mods = $self->_dist_to_mods( $self->_pkg_to_dist($_[0]) );
foreach my $pattern ( grep { $_ } @mods ) {
foreach my $rv ( $self->admin->glob_in_inc($pattern) ) {
$self->admin->copy_package(@$rv);
my @build_requires;
foreach (@{ $self->build_requires || [] }) {
next if $_->[0] eq $rv->[0];
push @build_requires, $_;
}
$self->Meta->{values}{build_requires} = \@build_requires;
}
}
}
=pod
=for private _pkg_to_dist $modname
Given a module name, returns the file on CPAN containing
its latest version.
=cut
sub _pkg_to_dist {
require CPAN;
my $mod = CPAN::Shell->expand( Module => $_[1] ) or return;
$mod->cpan_file;
}
=pod
=for private _dist_to_mods $distname
Takes the output of CPAN::Module->cpan_file and return all the modules
that CPAN.pm knows are in that dist. There's probably a better way using CPANPLUS
=cut
sub _dist_to_mods {
CPAN::Shell->expand( Distribution => $_[1] )->containsmods;
}
1;
|