aboutsummaryrefslogtreecommitdiffstats
path: root/config/systempatches/patches.inc
diff options
context:
space:
mode:
Diffstat (limited to 'config/systempatches/patches.inc')
-rw-r--r--config/systempatches/patches.inc63
1 files changed, 61 insertions, 2 deletions
diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc
index 89610565..9b347620 100644
--- a/config/systempatches/patches.inc
+++ b/config/systempatches/patches.inc
@@ -29,11 +29,19 @@
require_once("globals.inc");
require_once("util.inc");
-$git_root_url = "http://github.com/bsdperimeter/pfsense/commit/";
+$git_root_url = "http://github.com/pfsense/pfsense/commit/";
$patch_suffix = ".patch";
$patch_dir = "/var/patches";
$patch_cmd = "/usr/bin/patch";
+function patch_package_install() {
+ patch_add_shellcmd();
+}
+
+function patch_package_deinstall() {
+ patch_remove_shellcmd();
+}
+
function patch_commit($patch, $action, $test=false, $fulldetail=false) {
global $patch_dir, $patch_cmd, $patch_suffix;
$directory = empty($patch['basedir']) ? "/" : $patch['basedir'];
@@ -139,4 +147,55 @@ function is_github_url($url) {
$urlbits = explode("/", $url);
return (substr($urlbits[2], -10) == "github.com");
}
-?> \ No newline at end of file
+
+function bootup_apply_patches() {
+ global $config;
+
+ $a_patches = &$config['installedpackages']['patches']['item'];
+
+ foreach ($a_patches as $patch) {
+ /* Skip the patch if it should not be automatically applied. */
+ if (!isset($patch['autoapply']))
+ continue;
+ /* If the patch can be reverted it is already applied, so skip it. */
+ if (!patch_test_revert($patch)) {
+ /* Only attempt to apply if it can be applied. */
+ if (patch_test_apply($patch)) {
+ patch_apply($patch);
+ }
+ }
+ }
+}
+
+function patch_add_shellcmd() {
+ global $config;
+ $a_earlyshellcmd = &$config['system']['earlyshellcmd'];
+ if (!is_array($a_earlyshellcmd))
+ $a_earlyshellcmd = array();
+ $found = false;
+ foreach ($a_earlyshellcmd as $idx => $cmd)
+ if (stristr($cmd, "apply_patches.php"))
+ $found = true;
+ if (!$found) {
+ $a_earlyshellcmd[] = "/usr/local/bin/php -f /usr/local/bin/apply_patches.php";
+ write_config("System Patches package added a shellcmd");
+ }
+}
+
+function patch_remove_shellcmd() {
+ global $config;
+ $a_earlyshellcmd = &$config['system']['earlyshellcmd'];
+ if (!is_array($a_earlyshellcmd))
+ $a_earlyshellcmd = array();
+ $removed = false;
+ foreach ($a_earlyshellcmd as $idx => $cmd) {
+ if (stristr($cmd, "apply_patches.php")) {
+ unset($a_earlyshellcmd[$idx]);
+ $removed = true;
+ }
+ }
+ if ($removed)
+ write_config("System Patches package removed a shellcmd");
+}
+
+?>