Silence the warning "Can't locate auto/POSIX/autosplit.ix in @INC"
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / Internals / Constants.pm
CommitLineData
6aaee015 1package CPANPLUS::Internals::Constants;
2
3use strict;
4
5use CPANPLUS::Error;
6
7use File::Spec;
8use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
9
10require Exporter;
11use vars qw[$VERSION @ISA @EXPORT];
12
13use Package::Constants;
14
15
16$VERSION = 0.01;
17@ISA = qw[Exporter];
18@EXPORT = Package::Constants->list( __PACKAGE__ );
19
20
21sub constants { @EXPORT };
22
23use constant INSTALLER_BUILD
24 => 'CPANPLUS::Dist::Build';
25use constant INSTALLER_MM => 'CPANPLUS::Dist::MM';
26use constant INSTALLER_SAMPLE
27 => 'CPANPLUS::Dist::Sample';
28use constant INSTALLER_BASE => 'CPANPLUS::Dist::Base';
29
494f1016 30use constant SHELL_DEFAULT => 'CPANPLUS::Shell::Default';
31use constant SHELL_CLASSIC => 'CPANPLUS::Shell::Classic';
32
6aaee015 33use constant CONFIG => 'CPANPLUS::Config';
34use constant CONFIG_USER => 'CPANPLUS::Config::User';
35use constant CONFIG_SYSTEM => 'CPANPLUS::Config::System';
622d31ac 36use constant CONFIG_BOXED => 'CPANPLUS::Config::Boxed';
6aaee015 37
38use constant TARGET_CREATE => 'create';
39use constant TARGET_PREPARE => 'prepare';
40use constant TARGET_INSTALL => 'install';
41use constant TARGET_IGNORE => 'ignore';
42use constant DOT_CPANPLUS => $^O eq 'VMS' ? '_cpanplus' : '.cpanplus';
43
44use constant OPT_AUTOFLUSH => '-MCPANPLUS::Internals::Utils::Autoflush';
45
46use constant UNKNOWN_DL_LOCATION
47 => 'UNKNOWN-ORIGIN';
48
49use constant NMAKE => 'nmake.exe';
50use constant NMAKE_URL =>
51 'ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe';
52
53use constant INSTALL_VIA_PACKAGE_MANAGER
54 => sub { my $fmt = $_[0] or return;
55 return 1 if $fmt ne INSTALLER_BUILD and
56 $fmt ne INSTALLER_MM;
57 };
58
59use constant IS_CODEREF => sub { ref $_[-1] eq 'CODE' };
60use constant IS_MODOBJ => sub { UNIVERSAL::isa($_[-1],
61 'CPANPLUS::Module') };
62use constant IS_FAKE_MODOBJ => sub { UNIVERSAL::isa($_[-1],
63 'CPANPLUS::Module::Fake') };
64use constant IS_AUTHOBJ => sub { UNIVERSAL::isa($_[-1],
65 'CPANPLUS::Module::Author') };
66use constant IS_FAKE_AUTHOBJ
67 => sub { UNIVERSAL::isa($_[-1],
68 'CPANPLUS::Module::Author::Fake') };
69
70use constant IS_CONFOBJ => sub { UNIVERSAL::isa($_[-1],
71 'CPANPLUS::Configure') };
72
73use constant IS_RVOBJ => sub { UNIVERSAL::isa($_[-1],
74 'CPANPLUS::Backend::RV') };
75
76use constant IS_INTERNALS_OBJ
77 => sub { UNIVERSAL::isa($_[-1],
78 'CPANPLUS::Internals') };
79
80use constant IS_FILE => sub { return 1 if -e $_[-1] };
81
82use constant FILE_EXISTS => sub {
83 my $file = $_[-1];
84 return 1 if IS_FILE->($file);
85 local $Carp::CarpLevel =
86 $Carp::CarpLevel+2;
87 error(loc( q[File '%1' does not exist],
88 $file));
89 return;
90 };
91
92use constant FILE_READABLE => sub {
93 my $file = $_[-1];
94 return 1 if -e $file && -r _;
95 local $Carp::CarpLevel =
96 $Carp::CarpLevel+2;
97 error( loc( q[File '%1' is not readable ].
98 q[or does not exist], $file));
99 return;
100 };
101use constant IS_DIR => sub { return 1 if -d $_[-1] };
102
103use constant DIR_EXISTS => sub {
104 my $dir = $_[-1];
105 return 1 if IS_DIR->($dir);
106 local $Carp::CarpLevel =
107 $Carp::CarpLevel+2;
108 error(loc(q[Dir '%1' does not exist],
109 $dir));
110 return;
111 };
112
113use constant MAKEFILE_PL => sub { return @_
114 ? File::Spec->catfile( @_,
115 'Makefile.PL' )
116 : 'Makefile.PL';
117 };
118use constant MAKEFILE => sub { return @_
119 ? File::Spec->catfile( @_,
120 'Makefile' )
121 : 'Makefile';
122 };
123use constant BUILD_PL => sub { return @_
124 ? File::Spec->catfile( @_,
125 'Build.PL' )
126 : 'Build.PL';
127 };
128
129use constant BLIB => sub { return @_
130 ? File::Spec->catfile(@_, 'blib')
131 : 'blib';
132 };
133
134use constant LIB => 'lib';
135use constant LIB_DIR => sub { return @_
136 ? File::Spec->catdir(@_, LIB)
137 : LIB;
138 };
139use constant AUTO => 'auto';
140use constant LIB_AUTO_DIR => sub { return @_
141 ? File::Spec->catdir(@_, LIB, AUTO)
142 : File::Spec->catdir(LIB, AUTO)
143 };
144use constant ARCH => 'arch';
145use constant ARCH_DIR => sub { return @_
146 ? File::Spec->catdir(@_, ARCH)
147 : ARCH;
148 };
149use constant ARCH_AUTO_DIR => sub { return @_
150 ? File::Spec->catdir(@_,ARCH,AUTO)
151 : File::Spec->catdir(ARCH,AUTO)
152 };
153
154use constant BLIB_LIBDIR => sub { return @_
155 ? File::Spec->catdir(
156 @_, BLIB->(), LIB )
157 : File::Spec->catdir( BLIB->(), LIB );
158 };
159
160use constant CONFIG_USER_LIB_DIR => sub {
161 require CPANPLUS::Internals::Utils;
162 LIB_DIR->(
163 CPANPLUS::Internals::Utils->_home_dir,
164 DOT_CPANPLUS
165 );
166 };
167use constant CONFIG_USER_FILE => sub {
168 File::Spec->catfile(
169 CONFIG_USER_LIB_DIR->(),
170 split('::', CONFIG_USER),
171 ) . '.pm';
172 };
173use constant CONFIG_SYSTEM_FILE => sub {
174 require CPANPLUS::Internals;
175 require File::Basename;
176 my $dir = File::Basename::dirname(
177 $INC{'CPANPLUS/Internals.pm'}
178 );
179
180 ### XXX use constants
181 File::Spec->catfile(
182 $dir, qw[Config System.pm]
183 );
184 };
185
186use constant README => sub { my $obj = $_[0];
187 my $pkg = $obj->package_name;
188 $pkg .= '-' . $obj->package_version .
189 '.readme';
190 return $pkg;
191 };
192use constant OPEN_FILE => sub {
193 my($file, $mode) = (@_, '');
194 my $fh;
195 open $fh, "$mode" . $file
196 or error(loc(
197 "Could not open file '%1': %2",
198 $file, $!));
199 return $fh if $fh;
200 return;
201 };
202
203use constant STRIP_GZ_SUFFIX
204 => sub {
205 my $file = $_[0] or return;
206 $file =~ s/.gz$//i;
207 return $file;
208 };
209
210use constant CHECKSUMS => 'CHECKSUMS';
211use constant PGP_HEADER => '-----BEGIN PGP SIGNED MESSAGE-----';
212use constant ENV_CPANPLUS_CONFIG
213 => 'PERL5_CPANPLUS_CONFIG';
214use constant ENV_CPANPLUS_IS_EXECUTING
215 => 'PERL5_CPANPLUS_IS_EXECUTING';
216use constant DEFAULT_EMAIL => 'cpanplus@example.com';
217use constant CPANPLUS_UA => sub { ### for the version number ###
218 require CPANPLUS::Internals;
219 "CPANPLUS/$CPANPLUS::Internals::VERSION"
220 };
221use constant TESTERS_URL => sub {
222 "http://testers.cpan.org/show/" .
223 $_[0] .".yaml"
224 };
225use constant TESTERS_DETAILS_URL
226 => sub {
227 'http://testers.cpan.org/show/' .
228 $_[0] . '.html';
229 };
230
231use constant CREATE_FILE_URI
232 => sub {
233 my $dir = $_[0] or return;
234 return $dir =~ m|^/|
235 ? 'file:/' . $dir
236 : 'file://' . $dir;
237 };
238
239use constant DOT_SHELL_DEFAULT_RC
240 => '.shell-default.rc';
241
242use constant PREREQ_IGNORE => 0;
243use constant PREREQ_INSTALL => 1;
244use constant PREREQ_ASK => 2;
245use constant PREREQ_BUILD => 3;
246use constant BOOLEANS => [0,1];
247use constant CALLING_FUNCTION
248 => sub { my $lvl = $_[0] || 0;
249 return join '::', (caller(2+$lvl))[3]
250 };
251use constant PERL_CORE => 'perl';
252
253use constant GET_XS_FILES => sub { my $dir = $_[0] or return;
254 require File::Find;
255 my @files;
256 File::Find::find(
257 sub { push @files, $File::Find::name
258 if $File::Find::name =~ /\.xs$/i
259 }, $dir );
260
261 return @files;
262 };
263
264use constant INSTALL_LOG_FILE
265 => sub { my $obj = shift or return;
266 my $name = $obj->name; $name =~ s/::/-/g;
267 $name .= '-'. $obj->version;
268 $name .= '-'. scalar(time) . '.log';
269 return $name;
270 };
271
272use constant ON_WIN32 => $^O eq 'MSWin32';
273use constant ON_NETWARE => $^O eq 'NetWare';
274use constant ON_CYGWIN => $^O eq 'cygwin';
275use constant ON_VMS => $^O eq 'VMS';
276
277use constant ON_OLD_CYGWIN => do { ON_CYGWIN and $] < 5.008
278 ? loc(
279 "Your perl version for %1 is too low; ".
280 "Require %2 or higher for this function",
281 $^O, '5.8.0' )
282 : '';
283 };
284
285### XXX these 2 are probably obsolete -- check & remove;
286use constant DOT_EXISTS => '.exists';
287
288use constant QUOTE_PERL_ONE_LINER
289 => sub { my $line = shift or return;
290
291 ### use double quotes on these systems
292 return qq["$line"]
293 if ON_WIN32 || ON_NETWARE || ON_VMS;
294
295 ### single quotes on the rest
296 return qq['$line'];
297 };
298
2991;
300
301# Local variables:
302# c-indentation-style: bsd
303# c-basic-offset: 4
304# indent-tabs-mode: nil
305# End:
306# vim: expandtab shiftwidth=4: