~ubuntu-branches/ubuntu/maverick/padre/maverick

« back to all changes in this revision

Viewing changes to inc/Module/Install.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-05-13 08:24:37 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100513082437-rtvy3fw2efdd60h9
Tags: 0.61.ds1-1
* new upstream bugfix release

* add libpod2-base-perl (>= 0.043) to dependencies
* update translator list in d/copyright
* update debian/not-real-manual.list
* rules: upstream no longer installs .po files next to the .mo files; stop
  removing them

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
use 5.005;
21
21
use strict 'vars';
 
22
use Cwd        ();
 
23
use File::Find ();
 
24
use File::Path ();
 
25
use FindBin;
22
26
 
23
27
use vars qw{$VERSION $MAIN};
24
28
BEGIN {
28
32
        # This is not enforced yet, but will be some time in the next few
29
33
        # releases once we can make sure it won't clash with custom
30
34
        # Module::Install extensions.
31
 
        $VERSION = '0.94';
 
35
        $VERSION = '0.95';
32
36
 
33
37
        # Storage for the pseudo-singleton
34
38
        $MAIN    = undef;
38
42
 
39
43
}
40
44
 
41
 
 
42
 
 
43
 
 
44
 
 
45
 
# Whether or not inc::Module::Install is actually loaded, the
46
 
# $INC{inc/Module/Install.pm} is what will still get set as long as
47
 
# the caller loaded module this in the documented manner.
48
 
# If not set, the caller may NOT have loaded the bundled version, and thus
49
 
# they may not have a MI version that works with the Makefile.PL. This would
50
 
# result in false errors or unexpected behaviour. And we don't want that.
51
 
my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
52
 
unless ( $INC{$file} ) { die <<"END_DIE" }
 
45
sub import {
 
46
        my $class = shift;
 
47
        my $self  = $class->new(@_);
 
48
        my $who   = $self->_caller;
 
49
 
 
50
        #-------------------------------------------------------------
 
51
        # all of the following checks should be included in import(),
 
52
        # to allow "eval 'require Module::Install; 1' to test
 
53
        # installation of Module::Install. (RT #51267)
 
54
        #-------------------------------------------------------------
 
55
 
 
56
        # Whether or not inc::Module::Install is actually loaded, the
 
57
        # $INC{inc/Module/Install.pm} is what will still get set as long as
 
58
        # the caller loaded module this in the documented manner.
 
59
        # If not set, the caller may NOT have loaded the bundled version, and thus
 
60
        # they may not have a MI version that works with the Makefile.PL. This would
 
61
        # result in false errors or unexpected behaviour. And we don't want that.
 
62
        my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
 
63
        unless ( $INC{$file} ) { die <<"END_DIE" }
53
64
 
54
65
Please invoke ${\__PACKAGE__} with:
55
66
 
61
72
 
62
73
END_DIE
63
74
 
64
 
 
65
 
 
66
 
 
67
 
 
68
 
# If the script that is loading Module::Install is from the future,
69
 
# then make will detect this and cause it to re-run over and over
70
 
# again. This is bad. Rather than taking action to touch it (which
71
 
# is unreliable on some platforms and requires write permissions)
72
 
# for now we should catch this and refuse to run.
73
 
if ( -f $0 ) {
74
 
        my $s = (stat($0))[9];
75
 
 
76
 
        # If the modification time is only slightly in the future,
77
 
        # sleep briefly to remove the problem.
78
 
        my $a = $s - time;
79
 
        if ( $a > 0 and $a < 5 ) { sleep 5 }
80
 
 
81
 
        # Too far in the future, throw an error.
82
 
        my $t = time;
83
 
        if ( $s > $t ) { die <<"END_DIE" }
 
75
        # This reportedly fixes a rare Win32 UTC file time issue, but
 
76
        # as this is a non-cross-platform XS module not in the core,
 
77
        # we shouldn't really depend on it. See RT #24194 for detail.
 
78
        # (Also, this module only supports Perl 5.6 and above).
 
79
        eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006;
 
80
 
 
81
        # If the script that is loading Module::Install is from the future,
 
82
        # then make will detect this and cause it to re-run over and over
 
83
        # again. This is bad. Rather than taking action to touch it (which
 
84
        # is unreliable on some platforms and requires write permissions)
 
85
        # for now we should catch this and refuse to run.
 
86
        if ( -f $0 ) {
 
87
                my $s = (stat($0))[9];
 
88
 
 
89
                # If the modification time is only slightly in the future,
 
90
                # sleep briefly to remove the problem.
 
91
                my $a = $s - time;
 
92
                if ( $a > 0 and $a < 5 ) { sleep 5 }
 
93
 
 
94
                # Too far in the future, throw an error.
 
95
                my $t = time;
 
96
                if ( $s > $t ) { die <<"END_DIE" }
84
97
 
85
98
Your installer $0 has a modification time in the future ($s > $t).
86
99
 
89
102
Please correct this, then run $0 again.
90
103
 
91
104
END_DIE
92
 
}
93
 
 
94
 
 
95
 
 
96
 
 
97
 
 
98
 
# Build.PL was formerly supported, but no longer is due to excessive
99
 
# difficulty in implementing every single feature twice.
100
 
if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" }
 
105
        }
 
106
 
 
107
 
 
108
        # Build.PL was formerly supported, but no longer is due to excessive
 
109
        # difficulty in implementing every single feature twice.
 
110
        if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" }
101
111
 
102
112
Module::Install no longer supports Build.PL.
103
113
 
107
117
 
108
118
END_DIE
109
119
 
110
 
 
111
 
 
112
 
 
113
 
 
114
 
# To save some more typing in Module::Install installers, every...
115
 
# use inc::Module::Install
116
 
# ...also acts as an implicit use strict.
117
 
$^H |= strict::bits(qw(refs subs vars));
118
 
 
119
 
 
120
 
 
121
 
 
122
 
 
123
 
use Cwd        ();
124
 
use File::Find ();
125
 
use File::Path ();
126
 
use FindBin;
 
120
        #-------------------------------------------------------------
 
121
 
 
122
        # To save some more typing in Module::Install installers, every...
 
123
        # use inc::Module::Install
 
124
        # ...also acts as an implicit use strict.
 
125
        $^H |= strict::bits(qw(refs subs vars));
 
126
 
 
127
        #-------------------------------------------------------------
 
128
 
 
129
        unless ( -f $self->{file} ) {
 
130
                require "$self->{path}/$self->{dispatch}.pm";
 
131
                File::Path::mkpath("$self->{prefix}/$self->{author}");
 
132
                $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
 
133
                $self->{admin}->init;
 
134
                @_ = ($class, _self => $self);
 
135
                goto &{"$self->{name}::import"};
 
136
        }
 
137
 
 
138
        *{"${who}::AUTOLOAD"} = $self->autoload;
 
139
        $self->preload;
 
140
 
 
141
        # Unregister loader and worker packages so subdirs can use them again
 
142
        delete $INC{"$self->{file}"};
 
143
        delete $INC{"$self->{path}.pm"};
 
144
 
 
145
        # Save to the singleton
 
146
        $MAIN = $self;
 
147
 
 
148
        return 1;
 
149
}
127
150
 
128
151
sub autoload {
129
152
        my $self = shift;
152
175
        };
153
176
}
154
177
 
155
 
sub import {
156
 
        my $class = shift;
157
 
        my $self  = $class->new(@_);
158
 
        my $who   = $self->_caller;
159
 
 
160
 
        unless ( -f $self->{file} ) {
161
 
                require "$self->{path}/$self->{dispatch}.pm";
162
 
                File::Path::mkpath("$self->{prefix}/$self->{author}");
163
 
                $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
164
 
                $self->{admin}->init;
165
 
                @_ = ($class, _self => $self);
166
 
                goto &{"$self->{name}::import"};
167
 
        }
168
 
 
169
 
        *{"${who}::AUTOLOAD"} = $self->autoload;
170
 
        $self->preload;
171
 
 
172
 
        # Unregister loader and worker packages so subdirs can use them again
173
 
        delete $INC{"$self->{file}"};
174
 
        delete $INC{"$self->{path}.pm"};
175
 
 
176
 
        # Save to the singleton
177
 
        $MAIN = $self;
178
 
 
179
 
        return 1;
180
 
}
181
 
 
182
178
sub preload {
183
179
        my $self = shift;
184
180
        unless ( $self->{extensions} ) {