diff options
author | jim-p <jimp@pfsense.org> | 2012-05-07 13:09:49 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-05-07 13:09:49 -0400 |
commit | 6b6c9a29077e628543953ffccf8bcdec7ac907c4 (patch) | |
tree | f1d049bbad5ea2d70239c4c666051478949b1538 | |
parent | 4ed462f54fbccaa5d35c43ddfcaed2a6ae256eb1 (diff) | |
download | pfsense-packages-6b6c9a29077e628543953ffccf8bcdec7ac907c4.tar.gz pfsense-packages-6b6c9a29077e628543953ffccf8bcdec7ac907c4.tar.bz2 pfsense-packages-6b6c9a29077e628543953ffccf8bcdec7ac907c4.zip |
Add a way to view the full output from a test patch apply/revert
-rw-r--r-- | config/systempatches/patches.inc | 19 | ||||
-rw-r--r-- | config/systempatches/system_patches.php | 15 |
2 files changed, 25 insertions, 9 deletions
diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc index e25db3ff..d17e3614 100644 --- a/config/systempatches/patches.inc +++ b/config/systempatches/patches.inc @@ -43,13 +43,14 @@ function patch_commit($patch, $action, $test=false, $fulldetail=false) { $direction = ($action == "revert") ? "--reverse" : "--forward"; $whitespace = $patch['ignorewhitespace'] ? "--ignore-whitespace" : ""; $pathstrip = '-p' . $patch['pathstrip']; + $full_patch_command = "{$patch_cmd} --directory={$directory} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}"; patch_write($patch); - $status = mwexec("{$patch_cmd} --directory={$directory} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}", true); - //patch_erase($patch); - if ($status == 0) - return true; + if (!$fulldetail) + $output = (mwexec($full_patch_command, true) == 0); else - return false; + $output = $full_patch_command . "\n\n" . shell_exec($full_patch_command . ' 2>&1'); + patch_erase($patch); + return $output; } /* Attempt to apply a patch */ @@ -63,13 +64,13 @@ function patch_revert($patch) { } /* Test if a patch would apply cleanly */ -function patch_test_apply($patch) { - return patch_commit($patch, "apply", true); +function patch_test_apply($patch, $fulldetail=false) { + return patch_commit($patch, "apply", true, $fulldetail); } /* Test if a patch would revert cleanly */ -function patch_test_revert($patch) { - return patch_commit($patch, "revert", true); +function patch_test_revert($patch, $fulldetail=false) { + return patch_commit($patch, "revert", true, $fulldetail); } /* Fetch a patch from a URL or github */ diff --git a/config/systempatches/system_patches.php b/config/systempatches/system_patches.php index 7086f0ca..a10cb0bc 100644 --- a/config/systempatches/system_patches.php +++ b/config/systempatches/system_patches.php @@ -71,8 +71,17 @@ if (($_GET['act'] == "fetch") && ($a_patches[$_GET['id']])) { } if (($_GET['act'] == "test") && ($a_patches[$_GET['id']])) { $savemsg = patch_test_apply($a_patches[$_GET['id']]) ? gettext("Patch can be applied cleanly") : gettext("Patch can NOT be applied cleanly"); + $savemsg .= " (<a href=\"system_patches.php?id={$_GET['id']}&fulltest=apply\">" . gettext("detail") . "</a>)"; $savemsg .= empty($savemsg) ? "" : "<br/>"; $savemsg .= patch_test_revert($a_patches[$_GET['id']]) ? gettext("Patch can be reverted cleanly") : gettext("Patch can NOT be reverted cleanly"); + $savemsg .= " (<a href=\"system_patches.php?id={$_GET['id']}&fulltest=revert\">" . gettext("detail") . "</a>)"; +} +if (($_GET['fulltest']) && ($a_patches[$_GET['id']])) { + if ($_GET['fulltest'] == "apply") { + $fulldetail = patch_test_apply($a_patches[$_GET['id']], true); + } elseif ($_GET['fulltest'] == "revert") { + $fulldetail = patch_test_revert($a_patches[$_GET['id']], true); + } } if (($_GET['act'] == "apply") && ($a_patches[$_GET['id']])) { $savemsg = patch_apply($a_patches[$_GET['id']]) ? gettext("Patch applied successfully") : gettext("Patch could NOT be applied!"); @@ -158,6 +167,12 @@ echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript <br/><br/> <strong><?php echo gettext("Use with caution!"); ?></strong> <br/><br/> +<?php if (!empty($fulldetail)): ?> +</td></tr> +<tr><td></td><td colspan="7" align="left">Output of full patch <?php echo $_GET['fulltest']; ?> test: +<pre><?php echo $fulldetail; ?></pre> +<a href="system_patches.php">Close</a><br/><br/> +<?php endif; ?> </td></tr> <tr id="frheader"> <td width="5%" class="list"> </td> |