Re: [Module::Build] Document install_base_relpaths
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <ml...@th...> - 2006-03-07 01:51:26
|
David Wheeler wrote:
> On Mar 4, 2006, at 13:40, Randy W. Sims wrote:
>
>>> sub add_build_dir {
[...]
>>> };
>>> }
>>> 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.
The reason I ask is that I didn't see any affect from applying any of
the proposed patches, and I want to make sure it's not a flaw in my
understanding. For an author-defined element to get installed, it must
end up in ->install_types()
sub install_types {
my $self = shift;
my %types = (%{$self->install_path},
%{$self->install_sets($self->installdirs)});
return sort keys %types;
}
The only way to update that is to explicitly set install_path either on
the commandline or programatically or to modify the install_set
programatically. The patches provided don't do either, so the functions
don't seem to have any affective use... Unless I'm misunderstanding
(which is perfectly probable).
>> 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.
If it were added, I'd like to see it work either way.
>> $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?
I think I see what you're wanting, and I can see several ways of doing
it fairly simply, but I'm reluctant to do it now. I'd rather wait until
0.28 is out. add_build_element() can't be changed; it would change the
behavior of existing distros, and it was discussed some time back that
author defined build elements only get installed when supplied with
explicit paths.
I'm also reluctant to document install_base_relpath() & companion
prefix_relpath() as is because I don't like methods that return
references to internal data structures, preferring explicit getter &
setter methods. The behavior you're looking for is one good example of a
change that might be easily accomplished by changing the underlying data
structure. (Some issues with the manpages & html docs are another
parallel issue that could be tidied up with changes to the same data
structure.)
Maybe we can change them to accept a new value, and then document them.
that would be a simple and effective interim solution:
$self->install_base_relpath(); # deprecated; returns reference to
internal data
$self->install_base_relpath($elem); # returns path for $elem
$self->install_base_relpath($elem => $new_val); # sets path for $elem
For a future release, maybe we could provide something more generic.
Issues related to installing custom items have come up a lot on this
list and others, so maybe some easy way to provide for the common cases
would be appropriate?
$builder->auto_build_elements( element => 'conf',
filter => 'conf/*.conf',
install_relpath => 'conf' );
$builder->auto_build_elements( element => 'conf',
process => \&process_conf_files);
Along with associated arguments to the M::B->new() constructor.
Arguments:
element => the name of the element type
filter => a file glob of files to process
process => alternative to 'filter' above
install_relpath => sets default for both install_base_relpath &
prefix_relpath
install_base_relpath => sets default for install_base_relpath
prefix_relpath => sets default for prefix_relpath
Randy.
|