1 package CPANPLUS::Config;
6 use base 'Object::Accessor';
8 use base 'CPANPLUS::Internals::Utils';
15 use CPANPLUS::Internals::Constants;
17 use File::Basename qw[dirname];
18 use IPC::Cmd qw[can_run];
19 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
20 use Module::Load::Conditional qw[check_install];
24 'blacklist' => [ 'ftp' ],
31 'path' => '/pub/CPAN/',
32 'host' => 'ftp.cpan.org'
37 'host' => 'www.cpan.org'
41 'path' => '/pub/CPAN/',
42 'host' => 'ftp.nl.uu.net'
46 'path' => '/pub/CPAN/',
47 'host' => 'cpan.valueclick.com'
51 'path' => '/pub/languages/perl/CPAN/',
52 'host' => 'ftp.funet.fi'
55 'allow_build_interactivity' => 1,
56 'base' => File::Spec->catdir(
57 __PACKAGE__->_home_dir, DOT_CPANPLUS ),
63 'email' => DEFAULT_EMAIL,
70 'makemakerflags' => '',
72 check_install( module => 'Digest::MD5' ) ? 1 : 0 ),
75 ### if we dont have c::zlib, we'll need to use /bin/tar or we
76 ### can not extract any files. Good time to change the default
77 'prefer_bin' => (eval {require Compress::Zlib; 1}?0:1),
78 'prefer_makefile' => 1,
79 'prereqs' => PREREQ_ASK,
80 'shell' => 'CPANPLUS::Shell::Default',
81 'show_startup_tip' => 1,
82 'signature' => ( (can_run( 'gpg' ) ||
83 check_install( module => 'Crypt::OpenPGP' ))?1:0 ),
86 check_install( module => 'Storable' ) ? 1 : 0 ),
88 'verbose' => $ENV{PERL5_CPANPLUS_VERBOSE} || 0,
89 'write_install_logs' => 1,
91 ### Paths get stripped of whitespace on win32 in the constructor
92 ### sudo gets emptied if there's no need for it in the constructor
94 'editor' => ( $ENV{'EDITOR'} || $ENV{'VISUAL'} ||
95 can_run('vi') || can_run('pico')
97 'make' => ( can_run($Config{'make'}) || can_run('make') ),
98 'pager' => ( $ENV{'PAGER'} || can_run('less') || can_run('more') ),
99 ### no one uses this feature anyway, and it's only working for EU::MM
100 ### and not for module::build
102 'shell' => ( $^O eq 'MSWin32' ? $ENV{COMSPEC} : $ENV{SHELL} ),
103 'sudo' => ( $> # check for all install dirs!
104 # installsiteman3dir is a 5.8'ism.. don't check
106 ? ( -w $Config{'installsitelib'} &&
107 ( defined $Config{'installsiteman3dir'} &&
108 -w $Config{'installsiteman3dir'}
110 -w $Config{'installsitebin'}
116 ### perlwrapper that allows us to turn on autoflushing
117 'perlwrapper' => ( ### parallel to your cpanp/cpanp-boxed
118 do { my $f = File::Spec->rel2abs(
120 dirname($0), 'cpanp-run-perl'
126 ### parallel to your CPANPLUS.pm:
127 ### $INC{cpanplus}/../bin/cpanp-run-perl
128 do { my $f = File::Spec->rel2abs(
130 dirname( $INC{'CPANPLUS.pm'} ),
138 ### you installed CPANPLUS in a custom prefix,
139 ### so go paralel to /that/. PREFIX=/tmp/cp
140 ### would put cpanp-run-perl in /tmp/cp/bin and
142 ### /tmp/cp/lib/perl5/site_perl/5.8.8
143 do { my $f = File::Spec->rel2abs(
145 dirname( $INC{'CPANPLUS.pm'} ),
146 '..', '..', '..', '..', # 4x updir
154 ### in your path -- take this one last, the
155 ### previous two assume extracted tarballs
157 ### note that we don't use 'can_run' as it's
158 ### not an executable, just a wrapper...
160 for (split(/\Q$Config::Config{path_sep}\E/,
161 $ENV{PATH}), File::Spec->curdir
163 my $path = File::Spec->catfile(
164 $_, 'cpanp-run-perl' );
174 ### XXX try to be a no-op instead then..
175 ### cross your fingers...
176 ### pass '-P' to perl: "run program through C
177 ### preprocessor before compilation"
180 "Could not find the '%1' in your path".
181 "--this may be a problem.\n".
182 "Please locate this program and set ".
183 "your '%1' config entry to its path.\n".
184 "Attempting to provide a reasonable ".
186 'cpanp-run-perl', 'perlwrapper'
193 ### _source, _build and _mirror are supposed to be static
194 ### no changes should be needed unless pause/cpan changes
196 'hosts' => 'MIRRORED.BY',
197 'auth' => '01mailrc.txt.gz',
198 'stored' => 'sourcefiles',
199 'dslip' => '03modlist.data.gz',
201 'mod' => '02packages.details.txt.gz'
204 'plugins' => 'plugins',
208 'autobundle' => 'autobundle',
209 'autobundle_prefix' => 'Snapshot',
210 'autdir' => 'authors',
211 'install_log_dir' => 'install-logs',
215 'base' => 'authors/id/',
216 'auth' => 'authors/01mailrc.txt.gz',
217 'dslip' => 'modules/03modlist.data.gz',
218 'mod' => 'modules/02packages.details.txt.gz'
224 my $obj = $class->SUPER::new;
226 $obj->mk_accessors( keys %$Conf );
228 for my $acc ( keys %$Conf ) {
229 my $subobj = Object::Accessor->new;
230 $subobj->mk_accessors( keys %{$Conf->{$acc}} );
232 ### read in all the settings from the sub accessors;
233 for my $subacc ( $subobj->ls_accessors ) {
234 $subobj->$subacc( $Conf->{$acc}->{$subacc} );
237 ### now store it in the parent object
238 $obj->$acc( $subobj );
241 $obj->_clean_up_paths;
243 ### shut up IPC::Cmd warning about not findin IPC::Run on win32
249 sub _clean_up_paths {
252 ### clean up paths if we are on win32
253 if( $^O eq 'MSWin32' ) {
254 for my $pgm ( $self->program->ls_accessors ) {
255 $self->program->$pgm(
256 Win32::GetShortPathName( $self->program->$pgm )
257 ) if $self->program->$pgm =~ /\s+/;