# the PM step should always be done first, so it returns a '1' in the init function sub step_pm_init { return 10; # always be first. No other module should return anything less then 2 } sub step_pm { my $modfile = 'modules_' . ($OS ne 'MSWin32' ? 'linux' : lc $OS) . '.cfg'; # module in-file my $psmods = LoadConfig->load(location => catfile($inpath, $modfile), preservecase => 1); my $maxlen = -1 - length((sort { length($b) <=> length($a) } @{$psmods->{modules}})[0]); # get longest length my (@needed, $ver); my $DONE = 0; wraptext($lang->{pm_start}); while (!$DONE) { @needed = (); wraptext($lang->{pm_search}); foreach (@{$psmods->{modules}}) { my $module = $psmods->{usemap}{$_} || $_; eval "use $module"; my $ok = $@ ? 0 : 1; if (!$ok) { $ver = '????'; push(@needed, $_); # wraptext($@); } else { my $V = $module . "::VERSION"; $ver = $$V; } printf(" [%s] %${maxlen}s v%s\n", $ok ? "x" : " ", $_, $ver || '????'); } $wiz->{data}->{totalmissing} = $wiz->{data}->{totalneeded} = $data->{totalneeded} = 0; if (@needed) { $wiz->{data}->{totalmissing} = $wiz->{data}->{totalneeded} = $data->{totalneeded} = scalar @needed; wraptext($lang->{pm_missing}); if ($OS eq 'MSWin32') { my ($ppmver, $ppmexe, $p); $ppmexe = 'ppm'; RETRYPPM: # GOTO LABEL wraptext($lang->{pm_ppmsearch}); $output = `$ppmexe version` || ''; # try to execute ppm and fetch its version if ($output !~ /PPM\s+(\d+)/i) { wraptext($lang->{pm_ppmnotfound}); $p = $wiz->promptfor(">> PPM location: "); if ($p) { $ppmexe = $p; goto RETRYPPM; } else { wraptext($lang->{aborting}); $DONE = 1; } } else { $wiz->{data}->{ppmver} = $1; wraptext($lang->{pm_ppmfound}); wraptext($lang->{pm_download}); if ($wiz->prompt_yesno(1,$lang->{yn_pminstall})) { for (my $i=0; $i < @needed; $i++) { my $m = $needed[$i]; my $module = $wiz->{data}->{module} = $psmods->{ppmmap}{$m} || $m; wraptext($lang->{pm_dl}, {trimtail => 1}); $output = `ppm install ${PPMBASE}${module}.ppd`; if ($output =~ /^Successfully installed/im) { delete $needed[$i]; $wiz->{data}->{dlresult} = "OK!"; wraptext($lang->{pm_dldone}); } else { $wiz->{data}->{dlresult} = "ERROR!\n$output"; wraptext($lang->{pm_dldone}); $DONE=1 && last if $wiz->prompt_yesno(0,$lang->{yn_pminstall2}) == 0; # ignore the rest } } $DONE = 1; wraptext($lang->{pm_done}) unless @needed; } else { wraptext($lang->{pm_skip}); $DONE = 1; # We do not set $FATAL here. The rest of the installation steps can still continue w/o the modules } } } else { # LINUX SETUP $wiz->{data}->{neededmodules} = ""; $wiz->{data}->{neededmodules} .= "\tinstall $_\n" foreach (@needed); wraptext($lang->{pm_linux}); # $FATAL = 1; $DONE = 1; } } else { # NO MODULES ARE NEEDED, WE ARE DONE! wraptext($lang->{pm_done}); $DONE = 1; } } # end while } # end step_pm 1;