Thread: [Module::Build] Re: Module::Build and installing in non-standard locations
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <ml...@th...> - 2006-03-28 23:30:58
|
Matisse Enzer wrote:
> What's the standard (if any) for how to configure a build script to
> install specific files (e.g. httpd.conf) in someplace other than the
> standard Perl library/script/man locations?
>
> For example, if my distro contains a bunch of .pm files and .pl files,
> which go in the "normal" place, and my distro also contains:
>
> app_startup.pl
> httpd.conf
>
> and I want those installed as:
>
> app_startup.pl => "$some_dir/app-startup.pl", # mode 555
> httpd.conf => "$some_other_dir/conf", # mode 444
>
> is there a good standardized way to do this?
There are a number of ways to do this. The most simple is:
use strict;
use warnings;
use File::HomeDir;
my $conf_dir = File::Spec->catdir( File::HomeDir->my_home, '.Foo' );
use Module::Build;
my $builder = Module::Build->new(
module_name => 'Foo',
license => 'perl',
conf_files => {
'etc/httpd.conf' => 'conf/httpd.conf',
},
install_path => {
'conf' => $conf_dir,
},
);
$builder->add_build_element( 'conf' );
$builder->create_build_script();
__END__
The add_build_element() method is the key to the process. It lets M::B
know it should look for a 'conf_files' property that describes files to
be copied from somewhere in your distribution to a directory in 'blib'.
In the above example, 'etc/httpd.conf' in your distribution root to
'blib/conf/httpd.conf'.
Note that it's a current limitation that the first element of the
directory name in blib must be the same as the name of the build
element, in this case 'conf'.
Next the 'install_path' is looked at for a path to install build
elements of that type. The build elements will be copied from the
directory in 'blib' to the directory given. It is not necessary to
specify the 'install_path' here; it can be specified on the command line
by the user when invoking the install action:
./Build install --install-path conf=/etc/
If specified on the command line it will override the constructor arg.
If it is not specified in either place, those files will not be
installed, so it can be used as a flag.
Since we use ExtUtils::Install to install there is currently no way to
specifiy the file mode.
This has turned out to be one of the most FAQ with Module::Build. There
are plans to greatly simplify the process in the next version of M::B,
including removing the above mentioned limitations.
There are also several other more advanced ways to accomplish the above
by creating a subclass and providing methods to enumerate the files you
want to install or to create the files to be installed. There are
examples of these in Module::Build::Cookbook.
Also, there is a list dedicated to Module::Build which I've CC'd.
Regards,
Randy.
|
|
From: Matisse E. <ma...@ma...> - 2006-03-29 01:31:35
|
On Tue, 28 Mar 2006, Randy W. Sims wrote:
> The add_build_element() method is the key to the process.
Ah-Ha and thank you Very Nice!
I did read the perldoc - but just didn't get that
add_build_element('foo_files')
would make M::B look for a foo_fiels element - and I thought i would have
to provide a process_foo_files() method, I did not realize that I
didn't have to do that part (the documentation seems to say I had to.)
> Since we use ExtUtils::Install to install there is currently no way to
> specifiy the file mode.
I'll find some way to live with that for now :-)
It's mainly an issue for executables.
> This has turned out to be one of the most FAQ with Module::Build. There
> are plans to greatly simplify the process in the next version of M::B,
> including removing the above mentioned limitations.
Cool, and thanks again.
-Matisse
|
|
From: Matisse E. <ma...@ma...> - 2006-03-30 22:59:14
|
On Tue, 28 Mar 2006, Randy W. Sims wrote:
> There are a number of ways to do this. The most simple is:
>
> use strict;
> use warnings;
>
> use File::HomeDir;
> my $conf_dir = File::Spec->catdir( File::HomeDir->my_home, '.Foo' );
>
> use Module::Build;
> my $builder = Module::Build->new(
> module_name => 'Foo',
> license => 'perl',
>
> conf_files => {
> 'etc/httpd.conf' => 'conf/httpd.conf',
> },
>
> install_path => {
> 'conf' => $conf_dir,
> },
> );
>
> $builder->add_build_element( 'conf' );
>
> $builder->create_build_script();
>
> __END__
I haven't been able to get this approach to work.
The file(s) from the new build_element *do* get copied into blib, so in
the above example httpd.conf gets copied to blib/conf/httpd.conf
but, when i do Build install it does not get installed.
I looked in _build/build_params and the install_path hash
does contain an entry for my new build element(s), but nothing gets
installed there when I run ./Build install (and ./Build fakesinstall
doesn't show the files either.)
-M
|
|
From: Randy W. S. <ml...@th...> - 2006-03-30 23:29:30
|
Matisse Enzer wrote:
> On Tue, 28 Mar 2006, Randy W. Sims wrote:
>
>> There are a number of ways to do this. The most simple is:
>>
>> use strict;
>> use warnings;
>>
>> use File::HomeDir;
>> my $conf_dir = File::Spec->catdir( File::HomeDir->my_home, '.Foo' );
>>
>> use Module::Build;
>> my $builder = Module::Build->new(
>> module_name => 'Foo',
>> license => 'perl',
>>
>> conf_files => {
>> 'etc/httpd.conf' => 'conf/httpd.conf',
>> },
>>
>> install_path => {
>> 'conf' => $conf_dir,
>> },
>> );
>>
>> $builder->add_build_element( 'conf' );
>>
>> $builder->create_build_script();
>>
>> __END__
>
> I haven't been able to get this approach to work.
>
> The file(s) from the new build_element *do* get copied into blib, so in
> the above example httpd.conf gets copied to blib/conf/httpd.conf
> but, when i do Build install it does not get installed.
>
> I looked in _build/build_params and the install_path hash
> does contain an entry for my new build element(s), but nothing gets
> installed there when I run ./Build install (and ./Build fakesinstall
> doesn't show the files either.)
Did you try the script as above? I tested it on M::B 0.2612 & 0.27x from
cvs. Can you post your Build.PL script?
Note that the entries in install_path must have the same name as
supplied to add_build_element() (not with the '_files' appendage).
Regards,
Randy.
(Who hasn't been able to access sf.net cvs repository for +15 hrs now.)
|
|
From: Matisse E. <ma...@ma...> - 2006-03-31 00:14:14
|
On Thu, 30 Mar 2006, Randy W. Sims wrote:
> Note that the entries in install_path must have the same name as
> supplied to add_build_element() (not with the '_files' appendage).
OK - thanks again, that is my problem... the naming of the entries...
I was too dense to appreciate your note about the first element of the
blib subdirectory having to match the new build element type.
I actually found this by going through the Module::Build::Base source code
and found that install_map() was looking
I've re-written your example, using some_new_type to
possibly make this more clear to slow folks like myself.
##############################################################
use strict;
use warnings;
my $installation_dir = '/some/special/path';
use Module::Build;
my $builder = Module::Build->new(
module_name => 'Foo',
license => 'perl',
some_new_type_files => {
'dir/in/distro/httpd.conf' => 'some_new_type/httpd.conf',
# ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
# location in distriibution location in blib
},
install_path => {
'some_new_type' => $installation_dir,
},
);
$builder->add_build_element( 'some_new_type' );
$builder->create_build_script();
|