On Friday 27 February 2009 16:42:58 Shlomi Fish wrote:
> Hi all!
>
> In the XML-Grammar-ProductsSyndication Build.PL file, I have the following
> code:
>
> {{{{{{{{{{{{{{{{{{{{{{{
> use strict;
> use warnings;
>
> use File::Spec;
> use lib File::Spec->catdir(File::Spec->curdir(), "inc");
>
> use Test::Run::Builder;
>
> use File::Find;
>
> sub data_inc
> {
>     return "/usr/share/perl5/data/modules/XML-Grammar-Products-
> Syndication/data";
> }
>
> my @extradata_files;
>
> sub filter_files
> {
>     my $filename = $File::Find::name;
>     if ((-f $filename) && ($filename =~ /\.(?:mod|xslt|dtd|ent|cat|jpg|
> xcf\.bz2)$/))
>     {
>         push @extradata_files, $filename;
>     }
> }
>
> find({ wanted => \&filter_files, no_chdir => 1}, "extradata");
>
> my $builder = Test::Run::Builder->new(
>     module_name         => 'XML::Grammar::ProductsSyndication',
>     license             => 'bsd',
>     dist_author         => 'Shlomi Fish <shlo...@cpan.org>',
>     dist_version_from   => 'lib/XML/Grammar/ProductsSyndication.pm',
>     build_requires => {
>         'Test::More' => 0,
>         'Test::XML' => 0,
>         'XML::LibXML' => 0,
>         'XML::LibXSLT' => 0,
>         'Class::Accessor' => 0,
>         'XML::Amazon' => 0,
>         'LWP::UserAgent' => 0,
>         'Imager' => 0,
>     },
>     add_to_cleanup      => [ 'XML::Grammar::ProductsSyndication-*' ],
>     create_makefile_pl => 'passthrough',
>     install_path =>
>     {
>         extradata => data_inc(),
>     },
>     extradata_files =>
>     {
>         map { $_ => $_ } @extradata_files,
>     },
> );
>
> $builder->add_build_element('extradata');
> $builder->install_path->{'extradata'} = $builder->prefix() .
> "/data/modules/XML-Grammar-Products-Syndication/data";
>
> $builder->config_data('extradata_install_path' => [$builder->install_path-
>
> >{'extradata'}]);
>
> $builder->create_build_script();
> }}}}}}}}}}}}}}}}}}}}}
>
> (sorry for the wordwrap).
>
> Now, the problem is that when --prefix is not specified $builder->prefix()
> defaults to undef, which makes Module::Build attempts to install the
> extradata at "/data/modules...." (starting from the /-directory).
>
> I'd like the install_path->{'extradata'} to default to somewhere under
> where the Perl interpreter was installed. How can I achieve this?
>

Replying to myself, I should note that the following seems to work:

{{{{{{{{{{{{{{
sub get_prefix
{
        if (defined(my $p = $builder->prefix()))
        {
                return $p;
        }
        else
        {
                return $builder->original_prefix('site');
        }
}
}}}}}}}}}}}}}}

Am I right, or is there a better or more correct solution?

Regards,

        Shlomi Fish

> Regards,
>
> -- Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Stop Using MSIE - http://www.shlomifish.org/no-ie/

<mauke>    I'm not interested in what you're doing; what are you trying to 
           achieve?
<PerlJam>  mauke: I'm trying to achieve world peace and this regex is
           the last thing standing in my way! ;)

Reply via email to