ASNMTAP
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
Note that you can avoid these questions by passing the '-n' option
to 'Makefile.PL'.
The DEFAULT AUTO for automatic installation of dependencies via CPAN is '$PERL_AUTOINSTALL'.
The Applications are installed when the value equals 1.
The DEFAULT APPLICATIONS for the the plugin templates is '$ASNMTAP_APPLICATIONS'.
The Plugin templates are installed when the value equals 1.
The DEFAULT PLUGINS for the the plugin templates is '$ASNMTAP_PLUGINS'.
The DEFAULT PATH for the applications and/or plugins is '$ASNMTAP_PATH'.
The DEFAULT UID for the applications and plugins is '$ASNMTAP_UID'.
The DEFAULT GID for the applications and plugins is '$ASNMTAP_GID'.
The DEFAULT PROXY for testing the plugins is '$ASNMTAP_PROXY'.
With the environment variables PERL_AUTOINSTALL, ASNMTAP_APPLICATIONS,
ASNMTAP_PLUGINS, ASNMTAP_PATH, ASNMTAP_UID, ASNMTAP_GID and ASNMTAP_PROXY
you can change this.
EOT
$PERL_AUTOINSTALL = ( ExtUtils::MakeMaker::prompt( "\nAutomatic installation of dependencies via CPAN?" => ( $PERL_AUTOINSTALL ? 'yes' : 'no' ) ) =~ /^\s*(y)/i );
$ENV{PERL_AUTOINSTALL} = $PERL_AUTOINSTALL;
$ASNMTAP_APPLICATIONS = ( ExtUtils::MakeMaker::prompt( "\nDo you want to install the Applications?" => ( $ASNMTAP_APPLICATIONS ? 'yes' : 'no' ) ) =~ /^\s*(y)/i );
$ASNMTAP_PLUGINS = ( ExtUtils::MakeMaker::prompt( "\nDo you want to install the Plugin templates?" => ( $ASNMTAP_PLUGINS ? 'yes' : 'no' ) ) =~ /^\s*(y)/i );
if ( $ASNMTAP_APPLICATIONS or $ASNMTAP_PLUGINS ) {
$ASNMTAP_UID = prompt ("\nThe wanted UID for the applications and/or plugins?", $ASNMTAP_UID);
$ASNMTAP_GID = prompt ("\nThe wanted GID for the applications and/or plugins?", $ASNMTAP_GID);
do {
$ASNMTAP_PATH = prompt ("\nWhere do want to install the applications and/or plugins?", $ASNMTAP_PATH);
unless ( -d $ASNMTAP_PATH ) { mkdir $ASNMTAP_PATH or print "- invalid directory: '$ASNMTAP_PATH'\n" };
} while ( ! -d $ASNMTAP_PATH );
}
} else {
if ( $ASNMTAP_APPLICATIONS or $ASNMTAP_PLUGINS ) {
print "\nCreate directory: '$ASNMTAP_PATH':\n";
unless ( -d $ASNMTAP_PATH ) { mkdir $ASNMTAP_PATH or die "- invalid directory '$ASNMTAP_PATH'\n"; }
}
}
if ( $ASNMTAP_APPLICATIONS or $ASNMTAP_PLUGINS ) {
print "- created (when not already exists): '$ASNMTAP_PATH'\n\n";
chown ( $ASNMTAP_UID, $ASNMTAP_GID, $ASNMTAP_PATH ) or die "- chown $ASNMTAP_UID:$ASNMTAP_GID $ASNMTAP_PATH failed: $!";
if ( $ASNMTAP_APPLICATIONS ) {
unlink <$ASNMTAP_PATH/applications/htmlroot/nav/*/reports-*.html> if ( -e "$ASNMTAP_PATH/applications/htmlroot/nav" );
if ( -e "$ASNMTAP_PATH/results" ) {
unlink <$ASNMTAP_PATH/results/FOOTER.html>;
unlink <$ASNMTAP_PATH/results/*/FOOTER.html>;
unlink <$ASNMTAP_PATH/results/*/debug/FOOTER.html>;
unlink <$ASNMTAP_PATH/results/*/reports/FOOTER.html>;
unlink <$ASNMTAP_PATH/results/HEADER.html>;
unlink <$ASNMTAP_PATH/results/*/HEADER.html>;
unlink <$ASNMTAP_PATH/results/*/debug/HEADER.html>;
unlink <$ASNMTAP_PATH/results/*/reports/HEADER.html>;
}
}
}
my $intro = <<EOI;
This Build comes with some package that I can install.
We are about to install ASNMTAP::Asnmtap and for your convenience will
provide you with list of modules and prerequisites, so you'll be able
to choose only modules you need for your configuration.
EOI
if ( $prompt ) {
ExtUtils::MakeMaker::prompt( $intro . "Press <enter> to see the detailed list." );
} else {
print "These are the modules that will get installed:\n\n";
}
# This hash will contain a list of all perl modules we would like to explicitly depend upon in our Makefile
my %PREREQ_PM;
# Maintains a cache of what 3rd party modules you have installed
sub has_module {
my ($module, $version) = @_;
$version ||= '';
return ( ( $version =~ /^\*\d{2,2}(?:\d{2,2}(?:\d{2,2})?)?$/ ) ? 2 : ( $has_module_cache { "$module$version" } ||= eval ( "require $module; Exporter::require_version ( '$module', $version ) if ( $version ); 1" ) ) );
}
# Print a single prerequisite to the screen
sub generate_PREREQ_PM {
my ($feature, $dependency, $modules, $install) = @_;
my $buffer;
my $i = 0;
foreach (keys %$modules) {
my $detected = has_module ( $_, $modules->{$_} );
$buffer .= sprintf ( "%-24s [%s] %-32s %-8s\n", ( $i++ ? '' : $feature), ($detected >= 2 ? '+' : ( $detected ? '*' : ' ') ), $_ . ( $modules->{ $_ } and $modules->{ $_ } !~ /^\*\d{2,2}(?:\d{2,2}(?:\d{2,2})?)?$/ ? " (v$modules->{$_})" : '' ), ( $i...
}
return $buffer;
}
# Print the entire prerequisites table
sub generate_PREREQ_PM_table {
my $buffer = sprintf ( "%-24s %-36s %-8s\n", 'Feature', 'Prerequisites', 'Install?' );
$buffer .= sprintf ( "%s %s %s\n","-" x 24,"-" x 36,"-" x 8 );
foreach my $prerequisites ( @prerequisites ) { $buffer .= generate_PREREQ_PM ( @$prerequisites[1..4] ); }
$buffer .= "\n<- An asterix [*] indicates if the module is currently installed.\n";
return $buffer;
}
# Update the entire prerequisites table
sub update_prerequisites_table {
my ($u_level, $u_default) = @_;
return if ( $u_default > 2 );
( run in 1.202 second using v1.01-cache-2.11-cpan-0c5ce583b80 )