Fixed installation of alternate firmware version
Required version info was not being downloaded when alternate (not latest) version is selected rsulting in the error "Could not read locally cached release information."
This commit is contained in:
parent
1b7b131adc
commit
5565349255
@ -999,32 +999,41 @@ def ensure_firmware_file(fw_filename):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if selected_version == None:
|
|
||||||
if not upd_nocheck:
|
if not upd_nocheck:
|
||||||
try:
|
|
||||||
try:
|
try:
|
||||||
# if custom firmware url, download latest release
|
# if custom firmware url, download latest release
|
||||||
|
if selected_version == None and fw_url == None:
|
||||||
|
version_url = firmware_version_url+fw_filename
|
||||||
|
RNS.log("Retrieving latest version info from "+version_url)
|
||||||
|
urlretrieve(firmware_version_url+fw_filename, UPD_DIR+"/"+fw_filename+".version.latest")
|
||||||
|
else:
|
||||||
if fw_url != None:
|
if fw_url != None:
|
||||||
|
if selected_version == None:
|
||||||
|
version_url = fw_url+"latest/download/release.json"
|
||||||
|
else:
|
||||||
|
version_url = fw_url+"download/"+selected_version+"/release.json"
|
||||||
|
else:
|
||||||
|
version_url = firmware_update_url+selected_version+"/release.json"
|
||||||
try:
|
try:
|
||||||
RNS.log("Retrieving latest version from custom url "+fw_url+"latest/download/release.json")
|
RNS.log("Retrieving specified version info from "+version_url)
|
||||||
urlretrieve(fw_url+"latest/download/release.json", UPD_DIR+"/fallback_release_info.json")
|
urlretrieve(version_url, UPD_DIR+"/version_release_info.json")
|
||||||
import json
|
import json
|
||||||
with open(UPD_DIR+"/fallback_release_info.json", "rb") as rif:
|
with open(UPD_DIR+"/version_release_info.json", "rb") as rif:
|
||||||
rdat = json.loads(rif.read())
|
rdat = json.loads(rif.read())
|
||||||
variant = rdat[fw_filename]
|
variant = rdat[fw_filename]
|
||||||
with open(UPD_DIR+"/"+fw_filename+".version.latest", "wb") as verf:
|
with open(UPD_DIR+"/"+fw_filename+".version.latest", "wb") as verf:
|
||||||
inf_str = str(variant["version"])+" "+str(variant["hash"])
|
inf_str = str(variant["version"])+" "+str(variant["hash"])
|
||||||
verf.write(inf_str.encode("utf-8"))
|
verf.write(inf_str.encode("utf-8"))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while trying custom URL: "+str(e))
|
RNS.log("Failed to retrive version information for your board.")
|
||||||
raise e
|
RNS.log("Check your internet connection and try again.")
|
||||||
else:
|
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
||||||
urlretrieve(firmware_version_url+fw_filename, UPD_DIR+"/"+fw_filename+".version.latest")
|
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
||||||
|
exit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# if custom firmware url, don't fallback
|
# if custom firmware url, don't fallback
|
||||||
if fw_url != None:
|
if fw_url != None:
|
||||||
RNS.log("Failed to retrive latest version information for your board from the specified url.")
|
RNS.log("Failed to retrive version information for your board from the specified url.")
|
||||||
RNS.log("Check your internet connection and try again.")
|
RNS.log("Check your internet connection and try again.")
|
||||||
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
||||||
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
||||||
@ -1032,7 +1041,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
|
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("WARNING!")
|
RNS.log("WARNING!")
|
||||||
RNS.log("Failed to retrieve latest version information for your board from the default server")
|
RNS.log("Failed to retrieve latest version information for your board from the default server.")
|
||||||
RNS.log("Will retry using the following fallback URL: "+fallback_firmware_version_url)
|
RNS.log("Will retry using the following fallback URL: "+fallback_firmware_version_url)
|
||||||
RNS.log("")
|
RNS.log("")
|
||||||
RNS.log("Hit enter if you want to proceed")
|
RNS.log("Hit enter if you want to proceed")
|
||||||
@ -1051,13 +1060,6 @@ def ensure_firmware_file(fw_filename):
|
|||||||
RNS.log("Error while trying fallback URL: "+str(e))
|
RNS.log("Error while trying fallback URL: "+str(e))
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
RNS.log("Failed to retrive latest version information for your board.")
|
|
||||||
RNS.log("Check your internet connection and try again.")
|
|
||||||
RNS.log("If you don't have Internet access currently, use the --fw-version option to manually specify a version.")
|
|
||||||
RNS.log("You can also use --extract to copy the firmware from a known-good RNode of the same model.")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
file = open(UPD_DIR+"/"+fw_filename+".version.latest", "rb")
|
file = open(UPD_DIR+"/"+fw_filename+".version.latest", "rb")
|
||||||
release_info = file.read().decode("utf-8").strip()
|
release_info = file.read().decode("utf-8").strip()
|
||||||
@ -1070,7 +1072,7 @@ def ensure_firmware_file(fw_filename):
|
|||||||
if not os.path.isdir(UPD_DIR+"/"+selected_version):
|
if not os.path.isdir(UPD_DIR+"/"+selected_version):
|
||||||
os.makedirs(UPD_DIR+"/"+selected_version)
|
os.makedirs(UPD_DIR+"/"+selected_version)
|
||||||
shutil.copy(UPD_DIR+"/"+fw_filename+".version.latest", UPD_DIR+"/"+selected_version+"/"+fw_filename+".version")
|
shutil.copy(UPD_DIR+"/"+fw_filename+".version.latest", UPD_DIR+"/"+selected_version+"/"+fw_filename+".version")
|
||||||
RNS.log("The latest firmware for this board is version "+selected_version)
|
RNS.log("The selected firmware for this board is version "+selected_version)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Online firmware version check was disabled, but no firmware version specified for install.")
|
RNS.log("Online firmware version check was disabled, but no firmware version specified for install.")
|
||||||
|
Loading…
Reference in New Issue
Block a user