Simon Ruderich | 1 Apr 2011 19:15

Install custom files

Hi,

I'm trying to install custom files to a specific location which
should be relative to the given prefix/install_base/.. In this
case into share/locale. So e.g. if --prefix=/usr/local then it
should install into /usr/local/share/locale/.

I'm using Module::Build 0.340201 on Debian Squeeze.

I tried the following ($class has a method process_locale_files()
which creates the files in blib/locale, that part works just
fine):

    my $build = $class->new(
        ...
    );
    $build->add_build_element('locale');
    $build->install_base_relpaths(locale => 'locale');
    $build->create_build_script;

But no files get installed. After some testing it looks like
$build->install_base_relpaths() doesn't work at all -
$build->install_base_relpaths(lib => 'whatever') does nothing for
me, my .pm files are still installed in the same place.

I could use $build->install_path(locale => '...') but that
requires an absolute path. At the moment I'm using the following
hack to get the real installation path (I'm not sure if that's
even correct all the time):

(Continue reading)

Simon Ruderich | 1 Apr 2011 21:15

Re: Install custom files

On Fri, Apr 01, 2011 at 07:15:45PM +0200, Simon Ruderich wrote:
>     sub install_base_path {
>         my $self = shift;
>
>         if (defined $self->install_base) {
>             return $self->install_base;
>         } elsif (defined $self->prefix) {
>             return $self->prefix;
>         } else {
>             return $self->original_prefix->{$self->installdirs};
>         }
>     }

Hm, found the first issue - it only works if the user specifies
the prefix/install_base when calling perl Build.PL, not when
calling ./Build. But I've no idea how to fix this. Any ideas?

Regards,
Simon
--

-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
Leon Timmermans | 1 Apr 2011 21:15
Picon
Gravatar

Re: Install custom files

On Fri, Apr 1, 2011 at 7:15 PM, Simon Ruderich <simon <at> ruderich.org> wrote:
> I'm trying to install custom files to a specific location which
> should be relative to the given prefix/install_base/.. In this
> case into share/locale. So e.g. if --prefix=/usr/local then it
> should install into /usr/local/share/locale/.

How do you call your Build/Build.PL exactly? Do you call your example
with --install_base?

> I'm using Module::Build 0.340201 on Debian Squeeze.

You might want to upgrade to a more recent version of Module::Build.
«apt-get install libmodule-build-perl» should upgrade it to 0.3607.
CPAN will upgrade it to 0.38. It might solve your problems.

>    $build->add_build_element('locale');
>    $build->install_base_relpaths(locale => 'locale');

The general solution looks something like this:

  use File::Spec 'catdir';
  …
  $build->add_build_element('locale');
  $build->install_base_relpaths(locale => catdir('share', 'locale'));
  $build->prefix_relpaths($_, locale => catdir('share', 'locale')) for
qw/core vendor site/;
  $build->install_sets($_, 'locale',
catdir($build->original_prefix($_)), 'share', 'locale')) for qw/core
vendor site/;

(Continue reading)

Leon Timmermans | 1 Apr 2011 21:19
Picon
Gravatar

Re: Install custom files

On Fri, Apr 1, 2011 at 9:15 PM, Leon Timmermans <fawaka <at> gmail.com> wrote:
>  $build->install_sets($_, 'locale', catdir($build->original_prefix($_)), 'share', 'locale'))
for qw/core vendor site/;

Oops, that would be a parenthesis too many:

$build->install_sets($_, 'locale', catdir($build->original_prefix($_),
'share', 'locale')) for qw/core vendor site/;

Mark Harris | 1 Apr 2011 21:43
Favicon

CPAN install errors:

   Since the release of v3800 I have been unable to install
Module::Build using the CPAN module. It appears to install but the
files aren't copied. I have tried setting the --install_base path
option in '~/.cpan/CPAN/MyConfig.pm' using 'o conf mbuild_install_arg'
 but, had the same results. I also tried installing the previous
version of Module::Build that had worked before but, still the same
errors. It appears that an array is not being dereferenced by the
installer. Any advice will be appreciated, I have included the CPAN
output as an attachment. Thanks. ./mark
Running install for module 'Module::Build'                                                                                                                   
Running make for D/DA/DAGOLDEN/Module-Build-0.3800.tar.gz                                                                                                    
CPAN: checksum security checks disabled because Digest::SHA not installed.                                                                                   
Module-Build-0.3800                                                                                                                                          
Module-Build-0.3800/Changes                                                                                                                                  
Module-Build-0.3800/MANIFEST                                                                                                                                 
Module-Build-0.3800/META.json                                                                                                                                
Module-Build-0.3800/README                                                                                                                                   
Module-Build-0.3800/LICENSE                                                                                                                                  
Module-Build-0.3800/Build.PL                                                                                                                                 
Module-Build-0.3800/META.yml                                                                                                                                 
Module-Build-0.3800/INSTALL                                                                                                                                  
Module-Build-0.3800/Makefile.PL                                                                                                                              
Module-Build-0.3800/t                                                                                                                                        
Module-Build-0.3800/t/perl_mb_opt.t                                                                                                                          
Module-Build-0.3800/t/write_default_maniskip.t                                                                                                               
Module-Build-0.3800/t/help.t                                                                                                                                 
Module-Build-0.3800/t/tilde.t                                                                                                                                
Module-Build-0.3800/t/sample.t                                                                                                                               
(Continue reading)

Leon Timmermans | 4 Apr 2011 12:54
Picon
Gravatar

Re: CPAN install errors:

On Fri, Apr 1, 2011 at 9:43 PM, Mark Harris <mark.harris <at> netwitness.com>wrote:

>   Since the release of v3800 I have been unable to install
> Module::Build using the CPAN module. It appears to install but the
> files aren't copied. I have tried setting the --install_base path
> option in '~/.cpan/CPAN/MyConfig.pm' using 'o conf mbuild_install_arg'
>  but, had the same results. I also tried installing the previous
> version of Module::Build that had worked before but, still the same
> errors. It appears that an array is not being dereferenced by the
> installer. Any advice will be appreciated, I have included the CPAN
> output as an attachment. Thanks. ./mark
>

This seems to be a combination of a bug in Module::Build and a configuration
issue on your site. The bug in Module::Build is that it turns install_base
into an array when you supply it twice. The configuration issue is that
you're doing exactly that (you're also giving it a lot more arguments that
are superfluous for that matter). I suspect this has something to do with
Makefile.PL compatibility, since you appear to be using that too.

Leon
Simon Ruderich | 4 Apr 2011 15:55

Re: Install custom files

On Fri, Apr 01, 2011 at 09:15:53PM +0200, Leon Timmermans wrote:
> On Fri, Apr 1, 2011 at 7:15 PM, Simon Ruderich wrote:
>> I'm trying to install custom files to a specific location which
>> should be relative to the given prefix/install_base/.. In this
>> case into share/locale. So e.g. if --prefix=/usr/local then it
>> should install into /usr/local/share/locale/.
>
> How do you call your Build/Build.PL exactly? Do you call your example
> with --install_base?

Hi Leon,

Thanks for your quick response.

Yes, I tried --install_base and --prefix, both have the same
problem. It looks like --destdir also doesn't work with ./Build,
just with perl Build.PL. I'm not sure if this is expected or a
bug.

>> I'm using Module::Build 0.340201 on Debian Squeeze.

> You might want to upgrade to a more recent version of Module::Build.
> «apt-get install libmodule-build-perl» should upgrade it to 0.3607.
> CPAN will upgrade it to 0.38. It might solve your problems.

Retried with 0.38, same problem.

>>    $build->add_build_element('locale');
>>    $build->install_base_relpaths(locale => 'locale');
>
(Continue reading)

Simon Ruderich | 4 Apr 2011 16:08

Re: Install custom files

On Mon, Apr 04, 2011 at 03:55:24PM +0200, Simon Ruderich wrote:
>>> I'm using Module::Build 0.340201 on Debian Squeeze.
>
>> You might want to upgrade to a more recent version of Module::Build.
>> «apt-get install libmodule-build-perl» should upgrade it to 0.3607.
>> CPAN will upgrade it to 0.38. It might solve your problems.
>
> Retried with 0.38, same problem.

Sorry, wrong version. I retried it with 0.36.

>> The general solution looks something like this:
>>
>>   use File::Spec 'catdir';
>>   …
>>   $build->add_build_element('locale');
>>   $build->install_base_relpaths(locale => catdir('share', 'locale'));
>>   $build->prefix_relpaths($_, locale => catdir('share', 'locale')) for
>> qw/core vendor site/;
>>   $build->install_sets($_, 'locale',
>> catdir($build->original_prefix($_)), 'share', 'locale')) for qw/core
>> vendor site/;

It would be great if this could get added to the cookbook.

Regards,
Simon
--

-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
(Continue reading)

Leon Timmermans | 4 Apr 2011 17:12
Picon
Gravatar

Re: Install custom files

On Mon, Apr 4, 2011 at 3:55 PM, Simon Ruderich <simon <at> ruderich.org> wrote:
> Yes, I tried --install_base and --prefix, both have the same
> problem. It looks like --destdir also doesn't work with ./Build,
> just with perl Build.PL. I'm not sure if this is expected or a
> bug.

What *exactly* did you try to do? «./Build --install_base foo» or
«./Build install --install_base foo»? Or both?

> Hm, looks really complicated for such a simple task :-/

I agree. I think adding a helper function for this may be a good idea.

> Yeah, at the moment I rewrite the files to point to the right
> place. My current solution feels really like a hack:

It has the issue that the install_destination may not be known at
build time. The stages are rather independent. In theory it may even
be installed to multiple locations.

> Is there a simple way for text replacements like this in
> Module::Build (or maybe a better way to do it)? One known problem
> with my solution is that a --prefix/--install_base change doesn't
> case an update to the file, so it points to the wrong path.

No there isn't (nor should there be IMO, it has enough cruft as it is).

> I had a look at it, but I want a path like /usr/share/locale, and
> it gives me something like /usr/share/perl/5.10.1/auto/≤package-name>.

(Continue reading)

Simon Ruderich | 4 Apr 2011 21:38

Re: Install custom files

On Mon, Apr 04, 2011 at 05:12:00PM +0200, Leon Timmermans wrote:
> What *exactly* did you try to do? «./Build --install_base foo» or
> «./Build install --install_base foo»? Or both?

Sorry. I tried the following.

Works fine:

    perl Build.PL --install_base ~/test
    ./Build
    ./Build install

Works, but doesn't correctly replace the paths with my hacky
solution. Exactly the problem you mentioned below.

    perl Build.PL
    ./Build
    ./Build install --install_base ~/test

Doesn't work:

    perl Build.PL
    ./Build --install_base ~/test
    ./Build install

I thought ./Build --install_base ~/test would store the path
somewhere.

>> Hm, looks really complicated for such a simple task :-/
>
(Continue reading)


Gmane