diff options
author | jim-p <jimp@pfsense.org> | 2012-05-07 12:16:34 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-05-07 12:16:34 -0400 |
commit | 4ed462f54fbccaa5d35c43ddfcaed2a6ae256eb1 (patch) | |
tree | a16aa4aa03e34cb8bc0e1c542527a33e4b557b2f | |
parent | fab7a944a4c297f061d338a8626bff9a6e53a038 (diff) | |
download | pfsense-packages-4ed462f54fbccaa5d35c43ddfcaed2a6ae256eb1.tar.gz pfsense-packages-4ed462f54fbccaa5d35c43ddfcaed2a6ae256eb1.tar.bz2 pfsense-packages-4ed462f54fbccaa5d35c43ddfcaed2a6ae256eb1.zip |
Add an option to specify a base directory for the patch
-rw-r--r-- | config/systempatches/patches.inc | 9 | ||||
-rw-r--r-- | config/systempatches/system_patches_edit.php | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc index 971b9da3..e25db3ff 100644 --- a/config/systempatches/patches.inc +++ b/config/systempatches/patches.inc @@ -32,10 +32,11 @@ require_once("util.inc"); $git_root_url = "http://github.com/bsdperimeter/pfsense/commit/"; $patch_suffix = ".patch"; $patch_dir = "/var/patches"; -$patch_cmd = "/usr/bin/patch --directory=/ "; +$patch_cmd = "/usr/bin/patch"; -function patch_commit($patch, $action, $test=false) { +function patch_commit($patch, $action, $test=false, $fulldetail=false) { global $patch_dir, $patch_cmd, $patch_suffix; + $directory = empty($patch['basedir']) ? "/" : $patch['basedir']; $filename = '-i ' . $patch_dir . '/' . $patch['uniqid'] . $patch_suffix; $check = ($test) ? "--check" : ""; $force = ($action == "revert") ? "-f" : "-t"; @@ -43,8 +44,8 @@ function patch_commit($patch, $action, $test=false) { $whitespace = $patch['ignorewhitespace'] ? "--ignore-whitespace" : ""; $pathstrip = '-p' . $patch['pathstrip']; patch_write($patch); - $status = mwexec("{$patch_cmd} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}", false); - patch_erase($patch); + $status = mwexec("{$patch_cmd} --directory={$directory} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}", true); + //patch_erase($patch); if ($status == 0) return true; else diff --git a/config/systempatches/system_patches_edit.php b/config/systempatches/system_patches_edit.php index dd9e1ce7..bfa0af36 100644 --- a/config/systempatches/system_patches_edit.php +++ b/config/systempatches/system_patches_edit.php @@ -59,6 +59,7 @@ if (isset($id) && $a_patches[$id]) { $pconfig['location'] = $a_patches[$id]['location']; $pconfig['patch'] = $a_patches[$id]['patch']; $pconfig['pathstrip'] = $a_patches[$id]['pathstrip']; + $pconfig['basedir'] = $a_patches[$id]['basedir']; $pconfig['ignorewhitespace'] = isset($a_patches[$id]['ignorewhitespace']); $pconfig['autoapply'] = isset($a_patches[$id]['autoapply']); $pconfig['uniqid'] = $a_patches[$id]['uniqid']; @@ -89,6 +90,9 @@ if ($_POST) { if (!is_numeric($_POST['pathstrip'])) { $input_errors[] = gettext("Path Strip Count must be numeric!"); } + if (!empty($_POST['basedir']) && (!file_exists($_POST['basedir']) || !is_dir($_POST['basedir']))) { + $input_errors[] = gettext("Base Directory must exist and be a directory!"); + } if (!$input_errors) { $thispatch = array(); @@ -102,6 +106,7 @@ if ($_POST) { $thispatch['pathstrip'] = 1; else $thispatch['pathstrip'] = $_POST['pathstrip']; + $thispatch['basedir'] = empty($_POST['basedir']) ? "/" : $_POST['basedir']; $thispatch['ignorewhitespace'] = isset($_POST['ignorewhitespace']); $thispatch['autoapply'] = isset($_POST['autoapply']); if (empty($_POST['uniqid'])) { @@ -173,6 +178,12 @@ include("fbegin.inc"); ?> </td> </tr> <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Base Directory"); ?></td> + <td width="78%" class="vtable"> + <input name="basedir" type="text" class="formfld unknown" id="basedir" size="40" value="<?=htmlspecialchars($pconfig['basedir']);?>"> + <br> <span class="vexpl"><?=gettext("Enter the base directory for the patch, default is /. Patches from github are all based in /. Custom patches may need a full path here such as /usr/local/www/"); ?></span></td> +</tr> +<tr> <td width="22%" valign="top" class="vncell"><?=gettext("Ignore Whitespace"); ?></td> <td width="78%" class="vtable"> <input name="ignorewhitespace" type="checkbox" id="ignorewhitespace" value="yes" <?php if ($pconfig['ignorewhitespace']) echo "checked"; ?>> |