From 024bb6a00308b3ad4144bd7cbcb7d55dc47ac9d5 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 5 Feb 2021 00:09:58 +0100 Subject: [PATCH] firmware: UX rework done now #4500 Removed more fluff, concepts anf functionality are there. Plugin conflict labels could probably require improvement, but the way they work is relatively complicated, but maybe it is only getting late. As soon as we have plugin JSON metadata we can ship the plugin conflict rework as well as that seems to help a lot when recovering from strange situations (mostly development things, but we never know). --- .../mvc/app/views/OPNsense/Core/firmware.volt | 23 +++++----- src/opnsense/scripts/firmware/register.php | 46 ++++++++++++++----- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt index a3d2b347c..d066459a4 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt @@ -35,7 +35,7 @@ $('#update_status_container').hide(); $('#updatelist').show(); } - $("#checkupdate_progress").addClass("fa fa-spinner fa-pulse"); + $("#checkupdate_progress").addClass("fa-pulse"); } function updateDismiss() { @@ -58,7 +58,7 @@ // request status ajaxGet('/api/core/firmware/status', {}, function(data,status){ - $("#checkupdate_progress").removeClass("fa fa-spinner fa-pulse"); + $("#checkupdate_progress").removeClass("fa-pulse"); $('.updatestatus').html(data['status_msg']); if (data['status'] == "ok") { @@ -128,7 +128,7 @@ $('#updatetab_progress').addClass("fa fa-cog fa-spin"); if ($.upgrade_action == 'maj') { $("#upgrade_maj").attr("style",""); - $("#upgrade_progress_maj").addClass("fa fa-spinner fa-pulse"); + $('#updatetab_progress').addClass("fa fa-cog fa-spin"); } ajaxCall('/api/core/firmware/upgrade', {upgrade:$.upgrade_action}, function() { @@ -316,7 +316,6 @@ } } if (data['status'] == 'done') { - $("#upgrade_progress_maj").removeClass("fa fa-spinner fa-pulse"); $('#updatetab_progress').removeClass("fa fa-cog fa-spin"); $('#major-upgrade').hide(); $('#upgrade_maj').prop('disabled', true); @@ -801,8 +800,8 @@ - - + +
{{ lang._('This software release has reached its designated end of life.') }} {{ lang._('The next major release is:') }} @@ -832,8 +831,8 @@
- - + + @@ -900,10 +899,10 @@ - + diff --git a/src/opnsense/scripts/firmware/register.php b/src/opnsense/scripts/firmware/register.php index 3cc745ff4..5333a1d8b 100755 --- a/src/opnsense/scripts/firmware/register.php +++ b/src/opnsense/scripts/firmware/register.php @@ -80,10 +80,21 @@ function plugins_set($config, $plugins) Config::getInstance()->save(); } -function plugins_found($name) +function plugins_found($name, $found = []) { $bare = preg_replace('/^os-|-devel$/', '', $name); - return file_exists('/usr/local/opnsense/version/' . $bare); + + if (file_exists('/usr/local/opnsense/version/' . $bare)) { + if (!isset($found[$bare])) { + /* backwards compat with non-JSON, remove in 21.7 */ + return true; + } + if ($found[$bare] == $name) { + return true; + } + } + + return false; } function plugins_remove_sibling($name, $plugins) @@ -120,27 +131,40 @@ switch ($action) { $plugins = plugins_remove_sibling($name, $plugins); break; case 'resync': - $unknown = []; + $found = []; foreach (glob('/usr/local/opnsense/version/*') as $name) { - $name = basename($name); - if (strpos($name, 'base') === 0) { + $filename = basename($name); + if (strpos($filename, 'base') === 0) { continue; } - if (strpos($name, 'kernel') === 0) { + if (strpos($filename, 'kernel') === 0) { continue; } - if (strpos($name, 'core') === 0) { + if (strpos($filename, 'core') === 0) { continue; } - /* XXX when we have JSON data we can read the package name and pick it up */ - $unknown[] = "os-{$name}"; + + $ret = json_decode(@file_get_contents($name), true); + if ($ret == null || !isset($ret['product_id'])) { + /* ignore files without valid metadata */ + continue; + } + + $found[$filename] = $ret['product_id']; } foreach (array_keys($plugins) as $name) { - if (!plugins_found($name)) { - echo "Unregistering plugin: $name" . PHP_EOL; + if (!plugins_found($name, $found)) { + echo "Unregistering missing plugin: $name" . PHP_EOL; unset($plugins[$name]); } } + foreach ($found as $name) { + if (!isset($plugins[$name])) { + echo "Registering misconfigured plugin: $name" . PHP_EOL; + $plugins[$name] = 'yep'; + } + $plugins = plugins_remove_sibling($name, $plugins); + } break; default: exit();