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

Handle downloads for different raspi revisions.

This commit is contained in:
Jan Schneider 2017-06-15 22:30:42 +02:00
parent 239d785dac
commit f6f40d8133

View File

@ -29,6 +29,33 @@ namespace eval rmupdate {
variable log_file "" variable log_file ""
} }
proc ::rmupdate::get_rpi_version {} {
set fp [open /proc/cpuinfo r]
set data [read $fp]
foreach d [split $data "\n"] {
regexp {^Revision\s*:\s*(\S+)\s*$} $d match revision
if { [info exists revision] } {
if {$revision == "a22082"} {
# Pi 3 Model B
return "rpi3"
} elseif {$revision == "900092"} {
# Pi Zero
return "rpi0"
} elseif {$revision == "a21041"} {
# Pi 2 Model B
return "rpi2"
} elseif {$revision == "0012"} {
# Pi Model A+
return "rpi1"
} elseif {$revision == "0010"} {
# Pi Model B+
return "rpi1"
}
}
}
return ""
}
proc ::rmupdate::compare_versions {a b} { proc ::rmupdate::compare_versions {a b} {
return [package vcompare $a $b] return [package vcompare $a $b]
} }
@ -45,6 +72,9 @@ proc ::rmupdate::write_log {str} {
proc ::rmupdate::read_install_log {} { proc ::rmupdate::read_install_log {} {
variable install_log variable install_log
if { ![file exist $install_log] } {
return ""
}
set fp [open $install_log r] set fp [open $install_log r]
set data [read $fp] set data [read $fp]
close $fp close $fp
@ -207,13 +237,22 @@ 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 data [exec wget "${release_url}" --no-check-certificate -q -O-] set data [exec wget "${release_url}" --no-check-certificate -q -O-]
foreach d [split $data ">"] { foreach d [split $data ">"] {
set href "" set href ""
regexp {<\s*a\s+href\s*=\s*"([^"]+/releases/download/[^"]+\.zip)"} $d match href regexp {<\s*a\s+href\s*=\s*"([^"]+/releases/download/[^"]+)\.zip"} $d match href
if { [info exists href] && $href != ""} { if { [info exists href] && $href != ""} {
lappend download_urls "https://github.com${href}" set fn [lindex [split $href "/"] end]
set tmp [split $fn "-"]
if { [llength $tmp] == 3 } {
if { $rpi_version != [lindex $tmp 2] } {
continue
}
}
#write_log $href
lappend download_urls "https://github.com${href}.zip"
} }
} }
return $download_urls return $download_urls
@ -284,8 +323,11 @@ proc ::rmupdate::get_available_firmware_images {} {
} }
proc ::rmupdate::get_version_from_filename {filename} { proc ::rmupdate::get_version_from_filename {filename} {
regexp {\-([\d\.]+)\.[^\.]+$} $filename match version set fn [file rootname [file tail $filename]]
return $version set tmp [split $fn "-"]
return [lindex $tmp 1]
#regexp {\-([\d\.]+)\.[^\.]+-*.*$} $filename match version
#return $version
} }
proc ::rmupdate::get_firmware_info {} { proc ::rmupdate::get_firmware_info {} {
@ -406,6 +448,7 @@ proc ::rmupdate::install_firmware_version {version {reboot 1}} {
#rmupdate::umount $rmupdate::mnt_new #rmupdate::umount $rmupdate::mnt_new
#rmupdate::mount_system_partition "/boot" $rmupdate::mnt_cur #rmupdate::mount_system_partition "/boot" $rmupdate::mnt_cur
#rmupdate::umount $rmupdate::mnt_cur #rmupdate::umount $rmupdate::mnt_cur
#puts [rmupdate::get_rpi_version]