1 package CPANPLUS::Internals::Constants;
8 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
11 use vars qw[$VERSION @ISA @EXPORT];
13 use Package::Constants;
18 @EXPORT = Package::Constants->list( __PACKAGE__ );
21 sub constants { @EXPORT };
23 use constant INSTALLER_BUILD
24 => 'CPANPLUS::Dist::Build';
25 use constant INSTALLER_MM => 'CPANPLUS::Dist::MM';
26 use constant INSTALLER_SAMPLE
27 => 'CPANPLUS::Dist::Sample';
28 use constant INSTALLER_BASE => 'CPANPLUS::Dist::Base';
30 use constant SHELL_DEFAULT => 'CPANPLUS::Shell::Default';
31 use constant SHELL_CLASSIC => 'CPANPLUS::Shell::Classic';
33 use constant CONFIG => 'CPANPLUS::Config';
34 use constant CONFIG_USER => 'CPANPLUS::Config::User';
35 use constant CONFIG_SYSTEM => 'CPANPLUS::Config::System';
36 use constant CONFIG_BOXED => 'CPANPLUS::Config::Boxed';
38 use constant TARGET_CREATE => 'create';
39 use constant TARGET_PREPARE => 'prepare';
40 use constant TARGET_INSTALL => 'install';
41 use constant TARGET_IGNORE => 'ignore';
42 use constant DOT_CPANPLUS => $^O eq 'VMS' ? '_cpanplus' : '.cpanplus';
44 use constant OPT_AUTOFLUSH => '-MCPANPLUS::Internals::Utils::Autoflush';
46 use constant UNKNOWN_DL_LOCATION
49 use constant NMAKE => 'nmake.exe';
50 use constant NMAKE_URL =>
51 'ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe';
53 use constant INSTALL_VIA_PACKAGE_MANAGER
54 => sub { my $fmt = $_[0] or return;
55 return 1 if $fmt ne INSTALLER_BUILD and
59 use constant IS_CODEREF => sub { ref $_[-1] eq 'CODE' };
60 use constant IS_MODOBJ => sub { UNIVERSAL::isa($_[-1],
61 'CPANPLUS::Module') };
62 use constant IS_FAKE_MODOBJ => sub { UNIVERSAL::isa($_[-1],
63 'CPANPLUS::Module::Fake') };
64 use constant IS_AUTHOBJ => sub { UNIVERSAL::isa($_[-1],
65 'CPANPLUS::Module::Author') };
66 use constant IS_FAKE_AUTHOBJ
67 => sub { UNIVERSAL::isa($_[-1],
68 'CPANPLUS::Module::Author::Fake') };
70 use constant IS_CONFOBJ => sub { UNIVERSAL::isa($_[-1],
71 'CPANPLUS::Configure') };
73 use constant IS_RVOBJ => sub { UNIVERSAL::isa($_[-1],
74 'CPANPLUS::Backend::RV') };
76 use constant IS_INTERNALS_OBJ
77 => sub { UNIVERSAL::isa($_[-1],
78 'CPANPLUS::Internals') };
80 use constant IS_FILE => sub { return 1 if -e $_[-1] };
82 use constant FILE_EXISTS => sub {
84 return 1 if IS_FILE->($file);
85 local $Carp::CarpLevel =
87 error(loc( q[File '%1' does not exist],
92 use constant FILE_READABLE => sub {
94 return 1 if -e $file && -r _;
95 local $Carp::CarpLevel =
97 error( loc( q[File '%1' is not readable ].
98 q[or does not exist], $file));
101 use constant IS_DIR => sub { return 1 if -d $_[-1] };
103 use constant DIR_EXISTS => sub {
105 return 1 if IS_DIR->($dir);
106 local $Carp::CarpLevel =
108 error(loc(q[Dir '%1' does not exist],
113 use constant MAKEFILE_PL => sub { return @_
114 ? File::Spec->catfile( @_,
118 use constant MAKEFILE => sub { return @_
119 ? File::Spec->catfile( @_,
123 use constant BUILD_PL => sub { return @_
124 ? File::Spec->catfile( @_,
129 use constant BLIB => sub { return @_
130 ? File::Spec->catfile(@_, 'blib')
134 use constant LIB => 'lib';
135 use constant LIB_DIR => sub { return @_
136 ? File::Spec->catdir(@_, LIB)
139 use constant AUTO => 'auto';
140 use constant LIB_AUTO_DIR => sub { return @_
141 ? File::Spec->catdir(@_, LIB, AUTO)
142 : File::Spec->catdir(LIB, AUTO)
144 use constant ARCH => 'arch';
145 use constant ARCH_DIR => sub { return @_
146 ? File::Spec->catdir(@_, ARCH)
149 use constant ARCH_AUTO_DIR => sub { return @_
150 ? File::Spec->catdir(@_,ARCH,AUTO)
151 : File::Spec->catdir(ARCH,AUTO)
154 use constant BLIB_LIBDIR => sub { return @_
155 ? File::Spec->catdir(
157 : File::Spec->catdir( BLIB->(), LIB );
160 use constant CONFIG_USER_LIB_DIR => sub {
161 require CPANPLUS::Internals::Utils;
163 CPANPLUS::Internals::Utils->_home_dir,
167 use constant CONFIG_USER_FILE => sub {
169 CONFIG_USER_LIB_DIR->(),
170 split('::', CONFIG_USER),
173 use constant CONFIG_SYSTEM_FILE => sub {
174 require CPANPLUS::Internals;
175 require File::Basename;
176 my $dir = File::Basename::dirname(
177 $INC{'CPANPLUS/Internals.pm'}
180 ### XXX use constants
182 $dir, qw[Config System.pm]
186 use constant README => sub { my $obj = $_[0];
187 my $pkg = $obj->package_name;
188 $pkg .= '-' . $obj->package_version .
192 use constant OPEN_FILE => sub {
193 my($file, $mode) = (@_, '');
195 open $fh, "$mode" . $file
197 "Could not open file '%1': %2",
203 use constant STRIP_GZ_SUFFIX
205 my $file = $_[0] or return;
210 use constant CHECKSUMS => 'CHECKSUMS';
211 use constant PGP_HEADER => '-----BEGIN PGP SIGNED MESSAGE-----';
212 use constant ENV_CPANPLUS_CONFIG
213 => 'PERL5_CPANPLUS_CONFIG';
214 use constant ENV_CPANPLUS_IS_EXECUTING
215 => 'PERL5_CPANPLUS_IS_EXECUTING';
216 use constant DEFAULT_EMAIL => 'cpanplus@example.com';
217 use constant CPANPLUS_UA => sub { ### for the version number ###
218 require CPANPLUS::Internals;
219 "CPANPLUS/$CPANPLUS::Internals::VERSION"
221 use constant TESTERS_URL => sub {
222 "http://testers.cpan.org/show/" .
225 use constant TESTERS_DETAILS_URL
227 'http://testers.cpan.org/show/' .
231 use constant CREATE_FILE_URI
233 my $dir = $_[0] or return;
239 use constant DOT_SHELL_DEFAULT_RC
240 => '.shell-default.rc';
242 use constant PREREQ_IGNORE => 0;
243 use constant PREREQ_INSTALL => 1;
244 use constant PREREQ_ASK => 2;
245 use constant PREREQ_BUILD => 3;
246 use constant BOOLEANS => [0,1];
247 use constant CALLING_FUNCTION
248 => sub { my $lvl = $_[0] || 0;
249 return join '::', (caller(2+$lvl))[3]
251 use constant PERL_CORE => 'perl';
253 use constant GET_XS_FILES => sub { my $dir = $_[0] or return;
257 sub { push @files, $File::Find::name
258 if $File::Find::name =~ /\.xs$/i
264 use 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';
272 use constant ON_WIN32 => $^O eq 'MSWin32';
273 use constant ON_NETWARE => $^O eq 'NetWare';
274 use constant ON_CYGWIN => $^O eq 'cygwin';
275 use constant ON_VMS => $^O eq 'VMS';
277 use constant ON_OLD_CYGWIN => do { ON_CYGWIN and $] < 5.008
279 "Your perl version for %1 is too low; ".
280 "Require %2 or higher for this function",
285 ### XXX these 2 are probably obsolete -- check & remove;
286 use constant DOT_EXISTS => '.exists';
288 use constant QUOTE_PERL_ONE_LINER
289 => sub { my $line = shift or return;
291 ### use double quotes on these systems
293 if ON_WIN32 || ON_NETWARE || ON_VMS;
295 ### single quotes on the rest
302 # c-indentation-style: bsd
304 # indent-tabs-mode: nil
306 # vim: expandtab shiftwidth=4: