Check if firmware image is compressed

This commit is contained in:
Jan Schneider 2018-03-24 00:18:27 +01:00
parent 025cdf26ea
commit 73b3efaca3
1 changed files with 151 additions and 139 deletions

View File

@ -445,18 +445,24 @@ proc ::rmupdate::update_cmdline {cmdline root} {
}
proc ::rmupdate::update_boot_scr {boot_scr root} {
set fd [open $boot_scr r]
fconfigure $fd -translation binary
set boot_script "/tmp/boot.script"
catch { exec /bin/dd if=$boot_scr of=$boot_script bs=72 skip=1 }
set fd [open $boot_script r]
set data [read $fd]
close $fd
regsub -all "setenv rootfs \[0-9\]" $data "setenv rootfs ${root}" data
regsub -all "setenv userfs \[0-9\]" $data "setenv userfs 4" data
set fd [open $boot_scr w]
fconfigure $fd -translation binary
set fd [open $boot_script w]
puts $fd $data
close $fd
exec /usr/bin/mkimage -C none -A arm -T script -d $boot_script $boot_scr
file delete $boot_script
}
proc ::rmupdate::get_system_device {} {
@ -466,13 +472,15 @@ proc ::rmupdate::get_system_device {} {
close $fd
foreach d [split $data "\n"] {
if { [regexp {root=PARTUUID=(\S+)} $d match partuuid] } {
set x [file readlink "/dev/disk/by-partuuid/${partuuid}"]
if { [regexp {(mmcblk.*)p\d} [file tail $x] match device] } {
set sys_dev "/dev/${device}"
return $sys_dev
} elseif { [regexp {(.*)\d} [file tail $x] match device] } {
set sys_dev "/dev/${device}"
return $sys_dev
catch {
set x [file readlink "/dev/disk/by-partuuid/${partuuid}"]
if { [regexp {(mmcblk.*)p\d} [file tail $x] match device] } {
set sys_dev "/dev/${device}"
return $sys_dev
} elseif { [regexp {(.*)\d} [file tail $x] match device] } {
set sys_dev "/dev/${device}"
return $sys_dev
}
}
}
}
@ -1049,20 +1057,24 @@ proc ::rmupdate::download_firmware {{download_url ""} {version ""}} {
write_install_log ""
write_install_log "Download completed."
write_install_log "Extracting firmware %s.\nThis process takes some minutes, please be patient..." [file tail $archive_file]
set data [exec /usr/bin/unzip -ql "${archive_file}" 2>/dev/null]
set img_file ""
foreach d [split $data "\n"] {
regexp {\s+(\S+\.img)\s*$} $d match img_file
if { $img_file != "" } {
break
if {[regexp {.*\.zip$} $archive_file match]} {
write_install_log "Extracting firmware %s.\nThis process takes some minutes, please be patient..." [file tail $archive_file]
set data [exec /usr/bin/unzip -ql "${archive_file}" 2>/dev/null]
set img_file ""
foreach d [split $data "\n"] {
regexp {\s+(\S+\.img)\s*$} $d match img_file
if { $img_file != "" } {
break
}
}
if { $img_file == "" } {
error [i18n "Failed to extract firmware image from archive."]
}
exec /usr/bin/unzip "${archive_file}" "${img_file}" -o -d "${img_dir}" 2>/dev/null
set img_file "${img_dir}/${img_file}"
} else {
set img_file $archive_file
}
if { $img_file == "" } {
error [i18n "Failed to extract firmware image from archive."]
}
exec /usr/bin/unzip "${archive_file}" "${img_file}" -o -d "${img_dir}" 2>/dev/null
set img_file "${img_dir}/${img_file}"
#puts "${img_file} ${image_file}"
if {$version == ""} {
set image_file $img_file