On Oct 15, 2007, at 7:14 PM, Michael G Schwern wrote:
Eric Wilhelm wrote:
Hi all,
Steve is proposing that we add the following parameter to Build.PL
installdirs => ($] >= 5.009004 ? 'core' : 'site'),
Is that the preferred way of handling this?
Yes.
I recently had half-a-go at adding a fourth alternative besides
'core', 'site', and 'vendor', called 'auto'. It would sense whether
the given module was currently installed in a core lib, and if so
would choose 'core'. Otherwise 'auto'.
That would eliminate the need to hard-code the core version number.
Didn't succeed yet, I got as far as this:
======================================================
+sub is_core {
+ my $self = shift;
+ my $name = $self->module_name;
+ unless ($name) {
+ warn "Need a module_name to check whether it's a core module";
+ return;
+ }
+ my $from = Module::Build::ModuleInfo->find_module_dir_by_name($name)
+ or return 0;
+ my @from_parts = File::Spec->splitdir($from);
+ foreach my $dir (map $self->config($_), qw(installarchlib
installprivlib)) {
+ my @parts = File::Spec->splitdir($dir);
+ next if grep {$parts[$_] ne $from_parts[$_]} 0..$#parts;
+ return 1;
+ }
+ return 0;
+}
sub _set_install_paths {
my $self = shift;
my $c = $self->{config};
my $p = $self->{properties};
+ if ($self->installdirs eq 'auto') {
+ # Turn into 'core' if this seems to be a core module for this
+ # perl, otherwise 'site'.
+ $self->installdirs( $self->is_core ? 'core' : 'site' );
+ }
+
======================================================
but there's no such thing as Module::Build::ModuleInfo-
>find_module_dir_by_name, and when I tried to create such a thing it
started to get difficult.
-Ken