use
vars
qw[$VERSION @ISA @EXPORT]
;
@ISA
=
qw[Exporter]
;
@EXPORT
= Package::Constants->list( __PACKAGE__ );
sub
constants {
@EXPORT
};
=>
'CPANPLUS::Dist::Build'
;
use
constant
INSTALLER_MM
=>
'CPANPLUS::Dist::MM'
;
=>
'CPANPLUS::Dist::Sample'
;
use
constant
INSTALLER_BASE
=>
'CPANPLUS::Dist::Base'
;
=>
'CPANPLUS::Dist::Autobundle'
;
use
constant
SHELL_DEFAULT
=>
'CPANPLUS::Shell::Default'
;
use
constant
SHELL_CLASSIC
=>
'CPANPLUS::Shell::Classic'
;
use
constant
CONFIG
=>
'CPANPLUS::Config'
;
use
constant
CONFIG_USER
=>
'CPANPLUS::Config::User'
;
use
constant
CONFIG_SYSTEM
=>
'CPANPLUS::Config::System'
;
use
constant
CONFIG_BOXED
=>
'CPANPLUS::Config::Boxed'
;
=>
'CPANPLUS::Internals::Source::Memory'
;
use
constant
TARGET_PREPARE
=>
'prepare'
;
use
constant
TARGET_INSTALL
=>
'install'
;
use
constant
ON_WIN32
=> $^O eq
'MSWin32'
;
use
constant
ON_NETWARE
=> $^O eq
'NetWare'
;
use
constant
ON_CYGWIN
=> $^O eq
'cygwin'
;
use
constant
DOT_CPANPLUS
=> ON_VMS ?
'_cpanplus'
:
'.cpanplus'
;
use
constant
OPT_AUTOFLUSH
=>
'-MCPANPLUS::Internals::Utils::Autoflush'
;
=>
'UNKNOWN-ORIGIN'
;
use
constant
INSTALL_VIA_PACKAGE_MANAGER
=>
sub
{
my
$fmt
=
$_
[0] or
return
;
return
1
if
$fmt
ne INSTALLER_BUILD and
$fmt
ne INSTALLER_MM;
};
use
constant
IS_CODEREF
=>
sub
{
ref
$_
[-1] eq
'CODE'
};
use
constant
IS_MODOBJ
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Module'
) };
use
constant
IS_FAKE_MODOBJ
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Module::Fake'
) };
use
constant
IS_AUTHOBJ
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Module::Author'
) };
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Module::Author::Fake'
) };
use
constant
IS_CONFOBJ
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Configure'
) };
use
constant
IS_RVOBJ
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Backend::RV'
) };
=>
sub
{ UNIVERSAL::isa(
$_
[-1],
'CPANPLUS::Internals'
) };
use
constant
IS_FILE
=>
sub
{
return
1
if
-e
$_
[-1] };
my
$file
=
$_
[-1];
return
1
if
IS_FILE->(
$file
);
local
$Carp::CarpLevel
=
$Carp::CarpLevel
+2;
error(loc(
q[File '%1' does not exist]
,
$file
));
return
;
};
my
$file
=
$_
[-1];
return
1
if
-e
$file
&& -r _;
local
$Carp::CarpLevel
=
$Carp::CarpLevel
+2;
error( loc(
q[File '%1' is not readable ]
.
q[or does not exist]
,
$file
));
return
;
};
use
constant
IS_DIR
=>
sub
{
return
1
if
-d
$_
[-1] };
my
$dir
=
$_
[-1];
return
1
if
IS_DIR->(
$dir
);
local
$Carp::CarpLevel
=
$Carp::CarpLevel
+2;
error(loc(
q[Dir '%1' does not exist]
,
$dir
));
return
;
};
use
constant
MAKEFILE
=>
sub
{
my
$file
=
(ON_VMS and
$Config::Config
{make} =~ /MM[S|K]/i)
?
'DESCRIP.MMS'
:
'Makefile'
;
return
@_
? File::Spec->catfile(
@_
,
$file
)
:
$file
;
};
use
constant
MAKEFILE_PL
=>
sub
{
return
@_
? File::Spec->catfile(
@_
,
'Makefile.PL'
)
:
'Makefile.PL'
;
};
use
constant
BUILD_PL
=>
sub
{
return
@_
? File::Spec->catfile(
@_
,
'Build.PL'
)
:
'Build.PL'
;
};
use
constant
META_YML
=>
sub
{
return
@_
? File::Spec->catfile(
@_
,
'META.yml'
)
:
'META.yml'
;
};
? File::Spec->catfile(
@_
,
'blib'
)
:
'blib'
;
};
? File::Spec->catdir(
@_
, LIB)
: LIB;
};
use
constant
LIB_AUTO_DIR
=>
sub
{
return
@_
? File::Spec->catdir(
@_
, LIB, AUTO)
: File::Spec->catdir(LIB, AUTO)
};
use
constant
ARCH_DIR
=>
sub
{
return
@_
? File::Spec->catdir(
@_
, ARCH)
: ARCH;
};
use
constant
ARCH_AUTO_DIR
=>
sub
{
return
@_
? File::Spec->catdir(
@_
,ARCH,AUTO)
: File::Spec->catdir(ARCH,AUTO)
};
use
constant
BLIB_LIBDIR
=>
sub
{
return
@_
? File::Spec->catdir(
@_
, BLIB->(), LIB )
: File::Spec->catdir( BLIB->(), LIB );
};
use
constant
CONFIG_USER_LIB_DIR
=>
sub
{
LIB_DIR->(
CPANPLUS::Internals::Utils->_home_dir,
DOT_CPANPLUS
);
};
File::Spec->catfile(
CONFIG_USER_LIB_DIR->(),
split
(
'::'
, CONFIG_USER),
) .
'.pm'
;
};
use
constant
CONFIG_SYSTEM_FILE
=>
sub
{
my
$dir
= File::Basename::dirname(
$INC
{
'CPANPLUS/Internals.pm'
}
);
File::Spec->catfile(
$dir
,
qw[Config System.pm]
);
};
use
constant
README
=>
sub
{
my
$obj
=
$_
[0];
my
$pkg
=
$obj
->package_name;
$pkg
.=
'-'
.
$obj
->package_version .
'.readme'
;
return
$pkg
;
};
use
constant
META
=>
sub
{
my
$obj
=
$_
[0];
my
$pkg
=
$obj
->package_name;
$pkg
.=
'-'
.
$obj
->package_version .
'.'
. META_EXT;
return
$pkg
;
};
my
(
$file
,
$mode
) = (
@_
,
''
);
my
$fh
;
open
$fh
,
"$mode"
.
$file
or error(loc(
"Could not open file '%1': %2"
,
$file
, $!));
return
$fh
if
$fh
;
return
;
};
my
$dir
=
shift
;
my
$dh
;
opendir
$dh
,
$dir
or error(loc(
"Could not open dir '%1': %2"
,
$dir
, $!
));
return
$dh
if
$dh
;
return
;
};
my
$dir
=
shift
;
my
$dh
= OPEN_DIR->(
$dir
) or
return
;
my
@files
=
grep
{
$_
!~ /^\.{1,2}/ }
readdir
(
$dh
);
if
( ON_VMS ) {
s/(?<!\^)\.$//
for
@files
;
}
return
@files
;
};
=>
sub
{
my
$file
=
$_
[0] or
return
;
$file
=~ s/.gz$//i;
return
$file
;
};
use
constant
PGP_HEADER
=>
'-----BEGIN PGP SIGNED MESSAGE-----'
;
=>
'PERL5_CPANPLUS_CONFIG'
;
=>
'PERL5_CPANPLUS_IS_EXECUTING'
;
use
constant
DEFAULT_EMAIL
=>
'cpanplus@example.com'
;
"CPANPLUS/$CPANPLUS::Internals::VERSION"
};
uc
(
substr
(
$_
[0],0,1)) .
'/'
.
$_
[0] .
'.yaml'
;
};
=>
sub
{
uc
(
substr
(
$_
[0],0,1)) .
'/'
.
$_
[0];
};
=>
sub
{
my
$dir
=
$_
[0] or
return
;
return
$dir
=~ m|^/|
};
=>
'LOCAL'
;
=>
'.shell-default.rc'
;
=>
'db.sql'
;
=>
sub
{
my
$lvl
=
$_
[0] || 0;
return
join
'::'
, (
caller
(2+
$lvl
))[3]
};
use
constant
GET_XS_FILES
=>
sub
{
my
$dir
=
$_
[0] or
return
;
my
@files
;
File::Find::find(
sub
{
push
@files
,
$File::Find::name
if
$File::Find::name
=~ /\.xs$/i
},
$dir
);
return
@files
;
};
=>
sub
{
my
$obj
=
shift
or
return
;
my
$name
=
$obj
->name;
$name
=~ s/::/-/g;
$name
.=
'-'
.
$obj
->version;
$name
.=
'-'
.
scalar
(
time
) .
'.log'
;
return
$name
;
};
use
constant
ON_OLD_CYGWIN
=>
do
{ ON_CYGWIN and $] < 5.008
? loc(
"Your perl version for %1 is too low; "
.
"Require %2 or higher for this function"
,
$^O,
'5.8.0'
)
:
''
;
};
=>
sub
{
my
$line
=
shift
or
return
;
return
qq["$line"]
if
ON_WIN32 || ON_NETWARE || ON_VMS;
return
qq['$line']
;
};
1;