| | 356 | |
| | 357 | # if component is up-to-date, check it still works and isn't tainted (modified) |
| | 358 | if (defined $result and $result == 0) |
| | 359 | { |
| | 360 | # check it still works |
| | 361 | my $test_result = 1; |
| | 362 | if ($progtype ne 'application' and $progtype ne 'reference') |
| | 363 | { |
| | 364 | $test_result = test_proggy($proggy, $progtype, undef, 1); |
| | 365 | } |
| | 366 | |
| | 367 | if (!$test_result) |
| | 368 | { |
| | 369 | # broken |
| | 370 | $action = 'FAILED'; |
| | 371 | $plugin_data->{$proggy}->{failed_test} = 1; |
| | 372 | } |
| | 373 | else |
| | 374 | { |
| | 375 | # verify the component isn't tainted |
| | 376 | $component_csum = csum_file(query_ldir($proggy, $progtype)."/".$proggy); |
| | 377 | if ($component_csum ne $csum2) |
| | 378 | { |
| | 379 | # tainted |
| | 380 | $action = 'TAINTED'; |
| | 381 | } |
| | 382 | } |
| | 383 | } |
| | 384 | |
| 361 | | # if component is up-to-date, check it still works and isn't tainted (modified) |
| 362 | | if ((defined $result) && ($result == 0)) { |
| 363 | | # check that it still works |
| 364 | | my $test_result = 1; |
| 365 | | if ($progtype ne 'application' and $progtype ne 'reference') { |
| 366 | | $test_result = test_proggy($proggy, $progtype, undef, 1); |
| 367 | | } |
| 368 | | |
| 369 | | if (!$test_result) { |
| 370 | | # broken |
| 371 | | $plugin_data->{$proggy}->{failed_test} = 1; |
| 372 | | } else { |
| 373 | | # verify that the component isn't tainted |
| 374 | | my $component_csum = csum_file(query_ldir($proggy, $progtype)."/".$proggy); |
| 375 | | if ($component_csum ne $csum2) { |
| 376 | | # tainted |
| 377 | | &log(2,"\nWARNING: Component '$proggy' ($progtype) has been modified/tainted\n". |
| 378 | | " - expected checksum: $csum2\n". |
| 379 | | " - actual checksum: $component_csum\n\n"); |
| 380 | | |
| 381 | | # are we running a manual update? |
| 382 | | if ($opt->{update}) { |
| 383 | | # yes - manually force the tainted module to be reinstalled |
| 384 | | $result = -1; |
| 385 | | &log("Forcing reinstall of $proggy due to existing component modified/tainted.\n". |
| 386 | | "If you DON'T wish this to happen CTRL-C now...\n"); |
| 387 | | &countdown(15); |
| 388 | | } else { |
| 389 | | # no - whinge about the tainted module |
| 390 | | $plugin_data->{$proggy}->{tainted} = 1; |
| 391 | | $plugin_data->{tainted} = 1; |
| 392 | | $components_used .= "[tainted]" if ($proggy eq $progname); |
| 393 | | |
| 394 | | &log(2,"Modifying Shepherd or its components is not recommended. If you have added\n". |
| 395 | | "functionality in some way, why not contribute it back? See the wiki at\n". |
| 396 | | "$wiki for details.\n\n". |
| 397 | | "If you wish to revert $proggy back to the standard module, run ".ucfirst($progname)."\n". |
| 398 | | "with --update manually.\n\n"); |
| 399 | | &countdown(10); |
| 400 | | &log(2,"\n\n"); |
| 401 | | } |
| 402 | | } |
| 403 | | } |
| 404 | | } |
| | 390 | if ($action eq 'FAILED') |
| | 391 | { |
| | 392 | &log(2," For details, run Shepherd with --check option.\n"); |
| | 393 | } |
| | 394 | if ($action eq 'TAINTED') |
| | 395 | { |
| | 396 | &log(2,"\nWARNING: Component '$proggy' ($progtype) has been modified/tainted\n". |
| | 397 | " - expected checksum: $csum2\n". |
| | 398 | " - actual checksum: $component_csum\n\n"); |
| | 399 | |
| | 400 | # are we running a manual update? |
| | 401 | if ($opt->{update}) { |
| | 402 | # yes - manually force the tainted module to be reinstalled |
| | 403 | $result = -1; |
| | 404 | &log("Forcing reinstall of $proggy due to existing component modified/tainted.\n". |
| | 405 | "If you DON'T wish this to happen CTRL-C now...\n"); |
| | 406 | &countdown(15); |
| | 407 | } else { |
| | 408 | # no - whinge about the tainted module |
| | 409 | $plugin_data->{$proggy}->{tainted} = 1; |
| | 410 | $plugin_data->{tainted} = 1; |
| | 411 | $components_used .= "[tainted]" if ($proggy eq $progname); |
| | 412 | |
| | 413 | &log(2,"Modifying Shepherd or its components is not recommended. If you have added\n". |
| | 414 | "functionality in some way, why not contribute it back? See the wiki at\n". |
| | 415 | "$wiki for details.\n\n". |
| | 416 | "If you wish to revert $proggy back to the standard module, run ".ucfirst($progname)."\n". |
| | 417 | "with --update manually.\n\n"); |
| | 418 | &countdown(10); |
| | 419 | &log(2,"\n\n"); |
| | 420 | } |
| | 421 | } |
| 569 | | &log("Testing $proggy ... ") if ($quiet); |
| 570 | | &log("FAIL.\n\n".ucfirst($progtype) . " $proggy did not exit cleanly!\n" . |
| 571 | | "It may require configuration.\n"); |
| 572 | | |
| 573 | | &log(sprintf("<<<<<< output from $proggy was as follows:\n%s\n>>>>>> end output from $proggy\n",$test_output)); |
| 574 | | |
| | 586 | unless ($quiet) |
| | 587 | { |
| | 588 | &log("FAIL.\n\n".ucfirst($progtype) . " $proggy did not exit cleanly!\n"); |
| | 589 | |
| | 590 | # can we give any more details on why it failed? |
| | 591 | if ($test_output and $test_output =~ /Can't locate (.*) in \@INC/) |
| | 592 | { |
| | 593 | my $modname = $1; |
| | 594 | $modname =~ s#/#::#g; # turn / into :: |
| | 595 | $modname =~ s#\.pm##g; # remove .pm suffix |
| | 596 | $statusmsg = "Missing module \"$modname\""; |
| | 597 | |
| | 598 | &log("Probably failed due to dependency on missing module '".$modname."'\n"); |
| | 599 | } |
| | 600 | else |
| | 601 | { |
| | 602 | &log("It may require configuration.\n"); |
| | 603 | } |
| | 604 | |
| | 605 | &log(sprintf("\n<<<<<< output from $proggy was as follows:\n%s>>>>>> end output from $proggy\n\n",$test_output)); |
| | 606 | } |
| 576 | | $statusmsg = sprintf "FAILED (return code %d%s) on %s", |
| 577 | | $result, |
| 578 | | ($resultmsg eq "" ? "" : ", '$resultmsg'"), |
| 579 | | POSIX::strftime("%a%d%b%y", localtime(time)); |
| 580 | | |
| 581 | | # can we give any more details on why it failed? |
| 582 | | if ($test_output and $test_output =~ /Can't locate (.*) in \@INC/) { |
| 583 | | my $modname = $1; |
| 584 | | $modname =~ s#/#::#g; # turn / into :: |
| 585 | | $modname =~ s#\.pm##g; # remove .pm suffix |
| 586 | | $statusmsg .= ": missing '".$modname."' module."; |
| 587 | | |
| 588 | | &log("Probably failed due to dependency on missing module '".$modname."'\n"); |
| 589 | | } |
| 590 | | |
| 591 | | &log("\n"); |
| | 608 | unless ($statusmsg) |
| | 609 | { |
| | 610 | $statusmsg = sprintf "return code %d%s", $result, ($resultmsg eq "" ? "" : ", '$resultmsg'"); |
| | 611 | } |
| | 612 | $statusmsg = sprintf "FAILED (%s) on %s", |
| | 613 | $statusmsg, |
| | 614 | POSIX::strftime("%a%d%b%y", localtime(time)); |