1
0
mirror of https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git synced 2023-10-10 13:37:40 +02:00

Check latest supported firmware version

This commit is contained in:
Jan Schneider 2018-03-18 16:54:55 +01:00
parent f8005e3b75
commit 6ef8c2359a
2 changed files with 27 additions and 5 deletions

View File

@ -17,6 +17,7 @@
# #
namespace eval rmupdate { namespace eval rmupdate {
variable support_file_url "https://github.com/j-a-n/raspberrymatic-addon-rmupdate/raw/master/support.json"
variable release_url "https://github.com/jens-maus/RaspberryMatic/releases" variable release_url "https://github.com/jens-maus/RaspberryMatic/releases"
variable addon_dir "/usr/local/addons/rmupdate" variable addon_dir "/usr/local/addons/rmupdate"
variable rc_dir "/usr/local/etc/config/rc.d" variable rc_dir "/usr/local/etc/config/rc.d"
@ -958,8 +959,8 @@ proc ::rmupdate::get_current_firmware_version {} {
proc ::rmupdate::get_available_firmware_downloads {} { proc ::rmupdate::get_available_firmware_downloads {} {
variable release_url variable release_url
set rpi_version [get_rpi_version]
set download_urls [list] set download_urls [list]
set rpi_version [get_rpi_version]
set data [exec /usr/bin/wget "${release_url}" --no-check-certificate -q -O-] set data [exec /usr/bin/wget "${release_url}" --no-check-certificate -q -O-]
foreach d [split $data ">"] { foreach d [split $data ">"] {
set href "" set href ""
@ -1059,6 +1060,14 @@ proc ::rmupdate::get_version_from_filename {filename} {
proc ::rmupdate::get_firmware_info {} { proc ::rmupdate::get_firmware_info {} {
variable release_url variable release_url
variable support_file_url
set data [exec /usr/bin/wget "${support_file_url}" --no-check-certificate -q -O-]
if { ! [regexp {\"latest_supported_version\"\s*:\s*\"([^\"]+)\"} $data match latest_supported_version] } {
write_log 1 "Failed to get latest supported version from ${support_file_url}"
return "\[\]"
}
set current [get_current_firmware_version] set current [get_current_firmware_version]
set versions [list $current] set versions [list $current]
foreach e [get_available_firmware_downloads] { foreach e [get_available_firmware_downloads] {
@ -1084,12 +1093,16 @@ proc ::rmupdate::get_firmware_info {} {
if {$v == $current} { if {$v == $current} {
set installed "true" set installed "true"
} }
set supported "false"
if {[compare_versions $latest_supported_version $v] >= 0} {
set supported "true"
}
set image "" set image ""
catch { set image $images($v) } catch { set image $images($v) }
set url "" set url ""
catch { set url $downloads($v) } catch { set url $downloads($v) }
set info_url "${release_url}/tag/${v}" set info_url "${release_url}/tag/${v}"
append json "\{\"version\":\"${v}\",\"installed\":${installed},\"latest\":${latest}\,\"url\":\"${url}\"\,\"info_url\":\"${info_url}\",\"image\":\"${image}\"\}," append json "\{\"version\":\"${v}\",\"installed\":${installed},\"latest\":${latest},\"supported\":${supported},\"url\":\"${url}\",\"info_url\":\"${info_url}\",\"image\":\"${image}\"\},"
set latest "false" set latest "false"
} }
if {[llength versions] > 0} { if {[llength versions] > 0} {

View File

@ -245,13 +245,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$('#dimmer-firmware-info').addClass('active'); $('#dimmer-firmware-info').addClass('active');
rest("GET", "/get_firmware_info", null, function(data) { rest("GET", "/get_firmware_info", null, function(data) {
$('#firmware-info tbody').empty(); $('#firmware-info tbody').empty();
var latest_firmware_supported = false;
data.forEach(function(fw) { data.forEach(function(fw) {
if (fw.latest) latest_firmware = fw.version; if (fw.latest) {
latest_firmware = fw.version;
latest_firmware_supported = fw.supported;
}
if (fw.installed) current_firmware = fw.version; if (fw.installed) current_firmware = fw.version;
var color = 'yellow'; var color = 'yellow';
if (fw.latest) color = 'green'; if (fw.latest) color = 'green';
if (fw.installed) color = 'gray'; if (fw.installed) color = 'gray';
var disabled = (fw.image || fw.url ? '' : 'disabled'); var disabled = ((fw.image || fw.url) && fw.supported ? '' : 'disabled');
var binstall = $('<div class="ui '+ color +' basic '+ disabled +' button">').attr('data-install-firmware-version', fw.version).append($('<i class="sign in icon">'), i18next.t('install')); var binstall = $('<div class="ui '+ color +' basic '+ disabled +' button">').attr('data-install-firmware-version', fw.version).append($('<i class="sign in icon">'), i18next.t('install'));
binstall.click(function() { binstall.click(function() {
install_firmware(this.getAttribute('data-install-firmware-version')); install_firmware(this.getAttribute('data-install-firmware-version'));
@ -265,6 +269,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}); });
var available = (fw.url ? 'checked=""' : '') var available = (fw.url ? 'checked=""' : '')
var supported = (fw.supported ? 'checked=""' : '')
var downloaded = (fw.image ? 'checked=""' : '') var downloaded = (fw.image ? 'checked=""' : '')
var cls = ''; var cls = '';
if (fw.installed) cls = ' class="warning"'; if (fw.installed) cls = ' class="warning"';
@ -272,6 +277,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$("#firmware-info tbody").append($('<tr' + cls + '>').append( $("#firmware-info tbody").append($('<tr' + cls + '>').append(
$('<td>').append($('<a>', {text: fw.version, title: i18next.t('open_release_info'), href: fw.info_url, target: "_blank"})), $('<td>').append($('<a>', {text: fw.version, title: i18next.t('open_release_info'), href: fw.info_url, target: "_blank"})),
$('<td class="center aligned">').append($('<div class="ui disabled checkbox">').append($('<input type="checkbox" disabled="disabled" '+available+'>'),$('<label></label>'))), $('<td class="center aligned">').append($('<div class="ui disabled checkbox">').append($('<input type="checkbox" disabled="disabled" '+available+'>'),$('<label></label>'))),
$('<td class="center aligned">').append($('<div class="ui disabled checkbox">').append($('<input type="checkbox" disabled="disabled" '+supported+'>'),$('<label></label>'))),
$('<td class="center aligned">').append($('<div class="ui disabled checkbox">').append($('<input type="checkbox" disabled="disabled" '+downloaded+'>'),$('<label></label>'))), $('<td class="center aligned">').append($('<div class="ui disabled checkbox">').append($('<input type="checkbox" disabled="disabled" '+downloaded+'>'),$('<label></label>'))),
$('<td class="center aligned">').append(bdelete, binstall) $('<td class="center aligned">').append(bdelete, binstall)
)); ));
@ -285,7 +291,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$('<div class="ui item">').html(i18next.t('current_installed_version') + ': <span style="color:'+ color +'">' + current_firmware + '</span>'), $('<div class="ui item">').html(i18next.t('current_installed_version') + ': <span style="color:'+ color +'">' + current_firmware + '</span>'),
$('<div class="ui item">').html(i18next.t('latest_available_version') + ': ' + latest_firmware) $('<div class="ui item">').html(i18next.t('latest_available_version') + ': ' + latest_firmware)
); );
if (current_firmware != latest_firmware) { if (latest_firmware_supported && current_firmware != latest_firmware) {
$("#firmware-summary").append( $("#firmware-summary").append(
$('<div id="install-latest-firmware-button" class="ui green basic button" style="margin-top:20px; margin-bottom:20px;">').click(install_latest_firmware).append($('<i class="sign in icon">'), i18next.t('install_latest_firmware')) $('<div id="install-latest-firmware-button" class="ui green basic button" style="margin-top:20px; margin-bottom:20px;">').click(install_latest_firmware).append($('<i class="sign in icon">'), i18next.t('install_latest_firmware'))
); );
@ -670,6 +676,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
loading: 'Loading', loading: 'Loading',
version: 'Version', version: 'Version',
available: 'Available', available: 'Available',
supported: 'Supported',
downloaded: 'Downloaded', downloaded: 'Downloaded',
action: 'Action', action: 'Action',
delete_download: 'Delete download', delete_download: 'Delete download',
@ -748,6 +755,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
loading: 'Lade', loading: 'Lade',
version: 'Version', version: 'Version',
available: 'Verfügbar', available: 'Verfügbar',
supported: 'Unterstützt',
downloaded: 'Heruntergeladen', downloaded: 'Heruntergeladen',
action: 'Aktion', action: 'Aktion',
delete_download: 'Download löschen', delete_download: 'Download löschen',
@ -911,6 +919,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tr> <tr>
<th data-i18n="version"></th> <th data-i18n="version"></th>
<th class="center aligned" data-i18n="available"></th> <th class="center aligned" data-i18n="available"></th>
<th class="center aligned" data-i18n="supported"></th>
<th class="center aligned" data-i18n="downloaded"></th> <th class="center aligned" data-i18n="downloaded"></th>
<th class="center aligned" data-i18n="action"></th> <th class="center aligned" data-i18n="action"></th>
</tr> </tr>