~ubuntu-branches/ubuntu/raring/libmonitoring-livestatus-class-perl/raring-proposed

« back to all changes in this revision

Viewing changes to inc/Module/Install/AutoInstall.pm

  • Committer: Package Import Robot
  • Author(s): Alexander Wirt
  • Date: 2012-09-23 12:52:44 UTC
  • Revision ID: package-import@ubuntu.com-20120923125244-tj2b60nma3530edj
Tags: upstream-0.3
ImportĀ upstreamĀ versionĀ 0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#line 1
 
2
package Module::Install::AutoInstall;
 
3
 
 
4
use strict;
 
5
use Module::Install::Base ();
 
6
 
 
7
use vars qw{$VERSION @ISA $ISCORE};
 
8
BEGIN {
 
9
        $VERSION = '1.00';
 
10
        @ISA     = 'Module::Install::Base';
 
11
        $ISCORE  = 1;
 
12
}
 
13
 
 
14
sub AutoInstall { $_[0] }
 
15
 
 
16
sub run {
 
17
    my $self = shift;
 
18
    $self->auto_install_now(@_);
 
19
}
 
20
 
 
21
sub write {
 
22
    my $self = shift;
 
23
    $self->auto_install(@_);
 
24
}
 
25
 
 
26
sub auto_install {
 
27
    my $self = shift;
 
28
    return if $self->{done}++;
 
29
 
 
30
    # Flatten array of arrays into a single array
 
31
    my @core = map @$_, map @$_, grep ref,
 
32
               $self->build_requires, $self->requires;
 
33
 
 
34
    my @config = @_;
 
35
 
 
36
    # We'll need Module::AutoInstall
 
37
    $self->include('Module::AutoInstall');
 
38
    require Module::AutoInstall;
 
39
 
 
40
    my @features_require = Module::AutoInstall->import(
 
41
        (@config ? (-config => \@config) : ()),
 
42
        (@core   ? (-core   => \@core)   : ()),
 
43
        $self->features,
 
44
    );
 
45
 
 
46
    my %seen;
 
47
    my @requires = map @$_, map @$_, grep ref, $self->requires;
 
48
    while (my ($mod, $ver) = splice(@requires, 0, 2)) {
 
49
        $seen{$mod}{$ver}++;
 
50
    }
 
51
    my @build_requires = map @$_, map @$_, grep ref, $self->build_requires;
 
52
    while (my ($mod, $ver) = splice(@build_requires, 0, 2)) {
 
53
        $seen{$mod}{$ver}++;
 
54
    }
 
55
    my @configure_requires = map @$_, map @$_, grep ref, $self->configure_requires;
 
56
    while (my ($mod, $ver) = splice(@configure_requires, 0, 2)) {
 
57
        $seen{$mod}{$ver}++;
 
58
    }
 
59
 
 
60
    my @deduped;
 
61
    while (my ($mod, $ver) = splice(@features_require, 0, 2)) {
 
62
        push @deduped, $mod => $ver unless $seen{$mod}{$ver}++;
 
63
    }
 
64
 
 
65
    $self->requires(@deduped);
 
66
 
 
67
    $self->makemaker_args( Module::AutoInstall::_make_args() );
 
68
 
 
69
    my $class = ref($self);
 
70
    $self->postamble(
 
71
        "# --- $class section:\n" .
 
72
        Module::AutoInstall::postamble()
 
73
    );
 
74
}
 
75
 
 
76
sub auto_install_now {
 
77
    my $self = shift;
 
78
    $self->auto_install(@_);
 
79
    Module::AutoInstall::do_install();
 
80
}
 
81
 
 
82
1;