[Module-build-general] [PATCH] Use ExtUtils::AutoInstall for check_prereq if possible
Status: Beta
Brought to you by:
kwilliams
From: Autrijus T. <aut...@au...> - 2002-12-25 15:31:52
|
The following patch delegates check_prereq to EU::AI 0.50 (a not-yet-released version that should handle -conflict modules), and let EU::AI to handle the (de)installation automatically before ./Build is run. Comments welcome. Thanks, /Autrijus/ --- Base.pm.orig Wed Dec 25 20:19:49 2002 +++ Base.pm Wed Dec 25 20:29:04 2002 @@ -336,6 +336,9 @@ sub check_prereq { my $self =3D shift; =20 + return $self->_check_prereq_with_autoinstall + if eval { require ExtUtils::AutoInstall; ExtUtils::AutoInstall->VERSIO= N >=3D 0.50 }; + my $failures =3D $self->prereq_failures; return 1 unless $failures; =20 @@ -346,10 +349,33 @@ warn "$prefix: $module: $status->{message}\n"; } } - =20 + warn "ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install t= he versions ". "of the modules indicated above before proceeding with this install= ation.\n"; return 0; +} + +sub _check_prereq_with_autoinstall { + my $self =3D shift; + my $req =3D { map %$_, @{$self->{properties}}{qw/build_requires requires= /} }; + my $rec =3D $self->{properties}{recommends}; + my $con =3D $self->{properties}{conflicts}; + + ExtUtils::AutoInstall->import( + -version =3D> 0.50, + %$req ? ( -core =3D> [ + map { $_ =3D> $req->{$_} } sort grep !/^perl$/, keys %$req + ] ) : (), + %$rec ? ( 'Recommended Modules' =3D> [ + map { $_ =3D> $rec->{$_} } sort grep !/^perl$/, keys %$rec + ] ) : (), + %$con ? ( 'Conflicting Modules' =3D> [ + -conflict =3D> 1, + map { $_ =3D> $con->{$_} } sort grep !/^perl$/, keys %$rec + ] ) : (), + ); + + return ExtUtils::AutoInstall->do_install; } =20 sub perl_version_to_float { |