⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 build.pm

📁 source of perl for linux application,
💻 PM
📖 第 1 页 / 共 2 页
字号:
    ### prepared from another installer    $dist    = $self->status->dist_cpan if      $self->status->dist_cpan;    $self->status->dist_cpan( $dist )   unless  $self->status->dist_cpan;    my $cb   = $self->parent;    my $conf = $cb->configure_object;    my $mb   = $dist->status->_mb_object;    my %hash = @_;    my $dir;    unless( $dir = $self->status->extract ) {        error( loc( "No dir found to operate on!" ) );        return;    }    my $args;    my( $force, $verbose, $buildflags, $skiptest, $prereq_target,        $perl, $prereq_format, $prereq_build);    {   local $Params::Check::ALLOW_UNKNOWN = 1;        my $tmpl = {            force           => {    default => $conf->get_conf('force'),                                    store   => \$force },            verbose         => {    default => $conf->get_conf('verbose'),                                    store   => \$verbose },            perl            => {    default => $^X, store => \$perl },            buildflags      => {    default => $conf->get_conf('buildflags'),                                    store   => \$buildflags },            skiptest        => {    default => $conf->get_conf('skiptest'),                                    store   => \$skiptest },            prereq_target   => {    default => '', store => \$prereq_target },            ### don't set the default format to 'build' -- that is wrong!            prereq_format   => {    #default => $self->status->installer_type,                                    default => '',                                    store   => \$prereq_format },            prereq_build    => {    default => 0, store => \$prereq_build },                                            };        $args = check( $tmpl, \%hash ) or return;    }    return 1 if $dist->status->created && !$force;    $dist->status->_create_args( $args );    ### is this dist prepared?    unless( $dist->status->prepared ) {        error( loc( "You have not successfully prepared a '%2' distribution ".                    "yet -- cannot create yet", __PACKAGE__ ) );        return;    }    ### chdir to work directory ###    my $orig = cwd();    unless( $cb->_chdir( dir => $dir ) ) {        error( loc( "Could not chdir to build directory '%1'", $dir ) );        return;    }    ### by now we've loaded module::build, and we're using the API, so    ### it's safe to remove CPANPLUS::inc from our inc path, especially    ### because it can trip up tests run under taint (just like EU::MM).    ### turn off our PERL5OPT so no modules from CPANPLUS::inc get    ### included in make test -- it should build without.    ### also, modules that run in taint mode break if we leave    ### our code ref in perl5opt    ### XXX we've removed the ENV settings from cp::inc, so only need    ### to reset the @INC    #local $ENV{PERL5OPT} = CPANPLUS::inc->original_perl5opt;    #local $ENV{PERL5LIB} = CPANPLUS::inc->original_perl5lib;    local @INC           = CPANPLUS::inc->original_inc;    ### but do it *before* the new_from_context, as M::B seems    ### to be actually running the file...    ### an unshift in the block seems to be ignored.. somehow...    #{   my $lib = $self->best_path_to_module_build;    #    unshift @INC, $lib if $lib;    #}    unshift @INC, $self->best_path_to_module_build                if $self->best_path_to_module_build;    ### this will generate warnings under anything lower than M::B 0.2606    my %buildflags = $dist->_buildflags_as_hash( $buildflags );    $dist->status->_buildflags( $buildflags );    my $fail; my $prereq_fail; my $test_fail;    RUN: {        ### this will set the directory back to the start        ### dir, so we must chdir /again/        my $ok = $dist->_resolve_prereqs(                        force           => $force,                        format          => $prereq_format,                        verbose         => $verbose,                        prereqs         => $self->status->prereqs,                        target          => $prereq_target,                        prereq_build    => $prereq_build,                    );        unless( $cb->_chdir( dir => $dir ) ) {            error( loc( "Could not chdir to build directory '%1'", $dir ) );            return;        }        unless( $ok ) {            #### use $dist->flush to reset the cache ###            error( loc( "Unable to satisfy prerequisites for '%1' " .                        "-- aborting install", $self->module ) );            $dist->status->build(0);            $fail++; $prereq_fail++;            last RUN;        }        eval { $mb->dispatch('build', %buildflags) };        if( $@ ) {            error(loc("Could not run '%1': %2", 'Build', "$@"));            $dist->status->build(0);            $fail++; last RUN;        }        $dist->status->build(1);        ### add this directory to your lib ###        $cb->_add_to_includepath(            directories => [ BLIB_LIBDIR->( $self->status->extract ) ]        );        ### this buffer will not include what tests failed due to a         ### M::B/Test::Harness bug. Reported as #9793 with patch         ### against 0.2607 on 26/1/2005        unless( $skiptest ) {            eval { $mb->dispatch('test', %buildflags) };            if( $@ ) {                error(loc("Could not run '%1': %2", 'Build test', "$@"));                ### mark specifically *test* failure.. so we dont                ### send success on force...                $test_fail++;                if( !$force and !$cb->_callbacks->proceed_on_test_failure->(                                      $self, $@ )                 ) {                    $dist->status->test(0);                                     $fail++; last RUN;                     }                            } else {                $dist->status->test(1);            }        } else {            msg(loc("Tests skipped"), $verbose);        }                }    unless( $cb->_chdir( dir => $orig ) ) {        error( loc( "Could not chdir back to start dir '%1'", $orig ) );    }    ### send out test report? ###    if( $conf->get_conf('cpantest') and not $prereq_fail ) {        $cb->_send_report(            module          => $self,            failed          => $test_fail || $fail,            buffer          => CPANPLUS::Error->stack_as_string,            verbose         => $verbose,            force           => $force,            tests_skipped   => $skiptest,        ) or error(loc("Failed to send test report for '%1'",                    $self->module ) );    }    return $dist->status->created( $fail ? 0 : 1 );}=head2 $dist->install([verbose => BOOL, perl => /path/to/perl])Actually installs the created dist.Returns true on success and false on failure.=cutsub install {    ### just in case you already did a create call for this module object    ### just via a different dist object    my $dist = shift;    my $self = $dist->parent;    ### we're also the cpan_dist, since we don't need to have anything    ### prepared from another installer    $dist    = $self->status->dist_cpan if $self->status->dist_cpan;    my $mb   = $dist->status->_mb_object;    my $cb   = $self->parent;    my $conf = $cb->configure_object;    my %hash = @_;        my $verbose; my $perl; my $force;    {   local $Params::Check::ALLOW_UNKNOWN = 1;        my $tmpl = {            verbose => { default => $conf->get_conf('verbose'),                         store   => \$verbose },            force   => { default => $conf->get_conf('force'),                         store   => \$force },            perl    => { default => $^X, store   => \$perl },        };            my $args = check( $tmpl, \%hash ) or return;        $dist->status->_install_args( $args );    }    my $dir;    unless( $dir = $self->status->extract ) {        error( loc( "No dir found to operate on!" ) );        return;    }    my $orig = cwd();    unless( $cb->_chdir( dir => $dir ) ) {        error( loc( "Could not chdir to build directory '%1'", $dir ) );        return;    }    ### value set and false -- means failure ###    if( defined $self->status->installed &&         !$self->status->installed && !$force    ) {        error( loc( "Module '%1' has failed to install before this session " .                    "-- aborting install", $self->module ) );        return;    }    my $fail;    my $buildflags = $dist->status->_buildflags;    ### hmm, how is this going to deal with sudo?    ### for now, check effective uid, if it's not root,    ### shell out, otherwise use the method    if( $> ) {        ### don't worry about loading the right version of M::B anymore        ### the 'new_from_context' already added the 'right' path to        ### M::B at the top of the build.pl        ### On VMS, flags need to be quoted        my $flag    = ON_VMS ? '"install"' : 'install';        my $cmd     = [$perl, BUILD->($dir), $flag, $buildflags];        my $sudo    = $conf->get_program('sudo');        unshift @$cmd, $sudo if $sudo;        my $buffer;        unless( scalar run( command => $cmd,                            buffer  => \$buffer,                            verbose => $verbose )        ) {            error(loc("Could not run '%1': %2", 'Build install', $buffer));            $fail++;        }    } else {        my %buildflags = $dist->_buildflags_as_hash($buildflags);        eval { $mb->dispatch('install', %buildflags) };        if( $@ ) {            error(loc("Could not run '%1': %2", 'Build install', "$@"));            $fail++;        }    }    unless( $cb->_chdir( dir => $orig ) ) {        error( loc( "Could not chdir back to start dir '%1'", $orig ) );    }    return $dist->status->installed( $fail ? 0 : 1 );}### returns the string 'foo=bar zot=quux' as (foo => bar, zot => quux)sub _buildflags_as_hash {    my $self    = shift;    my $flags   = shift or return;    my @argv    = Module::Build->split_like_shell($flags);    my ($argv)  = Module::Build->read_args(@argv);    return %$argv;}sub dist_dir {    ### just in case you already did a create call for this module object    ### just via a different dist object    my $dist = shift;    my $self = $dist->parent;    ### we're also the cpan_dist, since we don't need to have anything    ### prepared from another installer    $dist    = $self->status->dist_cpan if $self->status->dist_cpan;    my $mb   = $dist->status->_mb_object;    my $cb   = $self->parent;    my $conf = $cb->configure_object;    my %hash = @_;        my $dir;    unless( $dir = $self->status->extract ) {        error( loc( "No dir found to operate on!" ) );        return;    }        ### chdir to work directory ###    my $orig = cwd();    unless( $cb->_chdir( dir => $dir ) ) {        error( loc( "Could not chdir to build directory '%1'", $dir ) );        return;    }    my $fail; my $distdir;    TRY: {            $dist->prepare( @_ ) or (++$fail, last TRY);        eval { $mb->dispatch('distdir') };        if( $@ ) {            error(loc("Could not run '%1': %2", 'Build distdir', "$@"));            ++$fail, last TRY;        }        ### /path/to/Foo-Bar-1.2/Foo-Bar-1.2        $distdir = File::Spec->catdir( $dir, $self->package_name . '-' .                                                $self->package_version );        unless( -d $distdir ) {            error(loc("Do not know where '%1' got created", 'distdir'));            ++$fail, last TRY;        }    }    unless( $cb->_chdir( dir => $orig ) ) {        error( loc( "Could not chdir to start directory '%1'", $orig ) );        return;    }    return if $fail;    return $distdir;}    =head1 KNOWN ISSUESBelow are some of the known issues with Module::Build, that we hope the authors will resolve at some point, so we can make full use ofModule::Build's power. The number listed is the bug number on C<rt.cpan.org>.=over 4=item * Module::Build can not be upgraded using its own API (#13169)This is due to the fact that the Build file insists on adding a pathto C<@INC> which force the loading of the C<not yet installed>Module::Build when it shells out to run it's own build procedure:=item * Module::Build does not provide access to install history (#9793)C<Module::Build> runs the create, test and install procedures in it'sown processes, but does not provide access to any diagnostic messages ofthose processes. As an end result, we can not offer these diagnostic messages when, for example, reporting automated build failures to siteslike C<testers.cpan.org>.=back=head1 AUTHOROriginally by Jos Boumans E<lt>kane@cpan.orgE<gt>.  Brought to workingcondition and currently maintained by Ken Williams E<lt>kwilliams@cpan.orgE<gt>.=head1 COPYRIGHTThe CPAN++ interface (of which this module is a part of) iscopyright (c) 2001, 2002, 2003, 2004, 2005 Jos Boumans E<lt>kane@cpan.orgE<gt>.All rights reserved.This library is free software;you may redistribute and/or modify it under the sameterms as Perl itself.=cut1;# Local variables:# c-indentation-style: bsd# c-basic-offset: 4# indent-tabs-mode: nil# End:# vim: expandtab shiftwidth=4:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -