From 6ef8c2359a249e5b7f92d6b7ba86062ce84a316e Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sun, 18 Mar 2018 16:54:55 +0100 Subject: [PATCH] Check latest supported firmware version --- addon/lib/rmupdate.tcl | 17 +++++++++++++++-- addon/www/index.html | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/addon/lib/rmupdate.tcl b/addon/lib/rmupdate.tcl index 628585e..141ab86 100644 --- a/addon/lib/rmupdate.tcl +++ b/addon/lib/rmupdate.tcl @@ -17,6 +17,7 @@ # 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 addon_dir "/usr/local/addons/rmupdate" 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 {} { variable release_url - set rpi_version [get_rpi_version] set download_urls [list] + set rpi_version [get_rpi_version] set data [exec /usr/bin/wget "${release_url}" --no-check-certificate -q -O-] foreach d [split $data ">"] { set href "" @@ -1059,6 +1060,14 @@ proc ::rmupdate::get_version_from_filename {filename} { proc ::rmupdate::get_firmware_info {} { 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 versions [list $current] foreach e [get_available_firmware_downloads] { @@ -1084,12 +1093,16 @@ proc ::rmupdate::get_firmware_info {} { if {$v == $current} { set installed "true" } + set supported "false" + if {[compare_versions $latest_supported_version $v] >= 0} { + set supported "true" + } set image "" catch { set image $images($v) } set url "" catch { set url $downloads($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" } if {[llength versions] > 0} { diff --git a/addon/www/index.html b/addon/www/index.html index 8b15ed3..cd2b248 100644 --- a/addon/www/index.html +++ b/addon/www/index.html @@ -245,13 +245,17 @@ along with this program. If not, see . $('#dimmer-firmware-info').addClass('active'); rest("GET", "/get_firmware_info", null, function(data) { $('#firmware-info tbody').empty(); + var latest_firmware_supported = false; 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; var color = 'yellow'; if (fw.latest) color = 'green'; if (fw.installed) color = 'gray'; - var disabled = (fw.image || fw.url ? '' : 'disabled'); + var disabled = ((fw.image || fw.url) && fw.supported ? '' : 'disabled'); var binstall = $('
').attr('data-install-firmware-version', fw.version).append($(''), i18next.t('install')); binstall.click(function() { install_firmware(this.getAttribute('data-install-firmware-version')); @@ -265,6 +269,7 @@ along with this program. If not, see . }); var available = (fw.url ? 'checked=""' : '') + var supported = (fw.supported ? 'checked=""' : '') var downloaded = (fw.image ? 'checked=""' : '') var cls = ''; if (fw.installed) cls = ' class="warning"'; @@ -272,6 +277,7 @@ along with this program. If not, see . $("#firmware-info tbody").append($('').append( $('').append($('', {text: fw.version, title: i18next.t('open_release_info'), href: fw.info_url, target: "_blank"})), $('').append($('
').append($(''),$(''))), + $('').append($('
').append($(''),$(''))), $('').append($('
').append($(''),$(''))), $('').append(bdelete, binstall) )); @@ -285,7 +291,7 @@ along with this program. If not, see . $('
').html(i18next.t('current_installed_version') + ': ' + current_firmware + ''), $('
').html(i18next.t('latest_available_version') + ': ' + latest_firmware) ); - if (current_firmware != latest_firmware) { + if (latest_firmware_supported && current_firmware != latest_firmware) { $("#firmware-summary").append( $('
').click(install_latest_firmware).append($(''), i18next.t('install_latest_firmware')) ); @@ -670,6 +676,7 @@ along with this program. If not, see . loading: 'Loading', version: 'Version', available: 'Available', + supported: 'Supported', downloaded: 'Downloaded', action: 'Action', delete_download: 'Delete download', @@ -748,6 +755,7 @@ along with this program. If not, see . loading: 'Lade', version: 'Version', available: 'Verfügbar', + supported: 'Unterstützt', downloaded: 'Heruntergeladen', action: 'Aktion', delete_download: 'Download löschen', @@ -911,6 +919,7 @@ along with this program. If not, see . +