Re: [Module::Build] Document install_base_relpaths
Status: Beta
Brought to you by:
kwilliams
|
From: David W. <da...@ki...> - 2006-03-05 02:19:16
|
On Mar 4, 2006, at 13:40, Randy W. Sims wrote:
>> sub add_build_dir {
>> my ($self, $dir) = @_;
>> die "What the?" unless -d $dir;
>> $self->add_build_element($dir);
>> $self->install_base_relpaths->{$elem} ||= [$elem];
>> no strict 'refs';
>> *{ref $self . "::process_$dir\_files"} = sub {
>> my self = shift;
>> my $files = $self->find_files_in_dir($dir);
>> while (my ($file, $dest) = each %$files) {
>> $self->copy_if_modified(
>> from => $file,
>> to => File::Spec->catfile($self->blib, $dest)
>> );
>> }
>> };
>> }
>> Only perhaps less magical. Do you see what I'm getting at?
>
> Does this work with 0.27x ?
I don't think that there's a find_files_in_dir method (it's in my
subclass), and I just typed it into email, but it should work modulo
a few typos.
> IIUC, the desired behavior is that by saying:
>
> my $build = Module::Build->new(
> ...
> conf_files => { 'conf/myconf' => 'conf/myconf' },
> };
Well, with the find_files_in_dir() method, you wouldn't need to
specify conf_files. It would just copy all of the files in the conf/
directory.
> $build->add_build_dir('conf');
>
> The 'conf' files will be automatically installed when an
> 'install_base' is supplied? Eg.
>
> ./Build install --install-base ~
>
> rather than requiring an explicit install-path
>
> .Build install --install-base ~ --install-path conf=~/conf
Right.
> But the supplied patches don't do anything because ->install_types
> () still don't know about 'conf' files.
Well, this works perfectly for me in my subclass. This is in new:
# Add www element and install path.
$self->add_build_element('www');
$self->install_base_relpaths->{www} = ['www'];
And later in the subclass:
sub process_www_files {
my $self = shift;
my $files = $self->find_files_in_dir('www');
while (my ($file, $dest) = each %$files) {
$self->copy_if_modified(
from => $file,
to => File::Spec->catfile($self->blib, $dest)
);
}
}
But I also force install_base to always be set.
> Also, would something similar be done for 'prefix'? Where would the
> default location be? Somewhere like:
>
> "$prefix/share/$dist_name/$elem"
>
> Or did I miss the intent?
I don't know. I assume that people generally know where they want
stuff, though. Maybe you have an etc dir, in which case, if you're
installing to /usr/local, the files would be put into /usr/local/etc.
Does that make sense?
Thanks,
David
|