diff --git a/addon/lib/rmupdate.tcl b/addon/lib/rmupdate.tcl index 1f03852..ca1eb38 100644 --- a/addon/lib/rmupdate.tcl +++ b/addon/lib/rmupdate.tcl @@ -105,6 +105,17 @@ proc ::rmupdate::i18n {str} { } proc ::rmupdate::get_rpi_version {} { + if {[file exists /var/hm_mode]} { + set fd [open /var/hm_mode r] + set data [read $fd] + close $fd + foreach d [split $data "\n"] { + if {[regexp {^HM_HOST='([^']+)'} $d match host]} { + return $host + } + } + } + # Revison list from http://elinux.org/RPi_HardwareHistory set revision_map(0002) "rpi0" set revision_map(0003) "rpi0" @@ -163,7 +174,7 @@ proc ::rmupdate::get_rpi_version {} { # return 1 if a>b, 0 if a=b, -1 if a"] { set href "" @@ -1045,10 +1059,9 @@ proc ::rmupdate::get_available_firmware_downloads {} { if { [info exists href] && $href != ""} { set fn [lindex [split $href "/"] end] set tmp [split $fn "-"] - if { [llength $tmp] == 3 } { - if { $rpi_version != [lindex $tmp 2] } { - continue - } + set v [lindex $tmp [expr {[llength $tmp] - 1}]] + if { $rpi_version != $v } { + continue } #write_log 4 $href if {[string first "https://" $href] == -1} { @@ -1066,7 +1079,7 @@ proc ::rmupdate::get_latest_firmware_version {{experimental 0}} { set versions [list] foreach e [get_available_firmware_downloads] { set version [get_version_from_filename $e] - if {[regexp {\.} $version match] || $experimental == 1} { + if {[string first "-" $version] == -1 || $experimental == 1} { lappend versions $version } } @@ -1154,9 +1167,12 @@ proc ::rmupdate::get_available_firmware_images {} { proc ::rmupdate::get_version_from_filename {filename} { set fn [file rootname [file tail $filename]] set tmp [split $fn "-"] - return [lindex $tmp 1] + set version [lindex $tmp 1] + if {[llength $tmp] == 4} { + append version "-" [lindex $tmp 2] + } #regexp {\-([\d\.]+)\.[^\.]+-*.*$} $filename match version - #return $version + return $version } proc ::rmupdate::get_firmware_info {} { @@ -1196,7 +1212,7 @@ proc ::rmupdate::get_firmware_info {} { foreach v $versions { set experimental "false" set latest "false" - if {![regexp {\.} $v match]} { + if {[string first "-" $v] != -1} { set experimental "true" } else { if {$latest_version == ""} { @@ -1890,6 +1906,7 @@ proc ::rmupdate::set_camera_active {active} { catch { exec /bin/mount -o remount,ro "/boot" } } +#rmupdate::install_firmware "" "3.49.17.20200131-6867276" #puts [rmupdate::get_latest_firmware_version] #puts [rmupdate::get_firmware_info] #puts [rmupdate::get_available_firmware_images] diff --git a/addon/www/rest.cgi b/addon/www/rest.cgi index 5b3f52c..1ee5fb2 100644 --- a/addon/www/rest.cgi +++ b/addon/www/rest.cgi @@ -151,7 +151,7 @@ proc process {} { return [rmupdate::get_addon_info 1 1 1] } elseif {[lindex $path 1] == "start_install_firmware"} { regexp {\"download_url\"\s*:\s*\"([^\"]*)\"} $data match download_url - regexp {\"version\"\s*:\s*\"([\d\.]*)\"} $data match version + regexp {\"version\"\s*:\s*\"([\d\.\-]*)\"} $data match version regexp {\"language\"\s*:\s*\"([^\"]+)\"} $data match lang regexp {\"reboot\"\s*:\s*(true|false)} $data match reboot regexp {\"dryrun\"\s*:\s*(true|false)} $data match dryrun @@ -232,7 +232,7 @@ proc process {} { variable content_type "application/json" -if [catch {process} result] { +if {[catch {process} result]} { set status 500 if { [regexp {^\d+$} $errorCode ] } { set status $errorCode