|
|
|
@ -76,19 +76,7 @@ def unsparsify(f): |
|
|
|
|
raise Exception("Unhandled sparse chunk type") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def flash_agnos_update(manifest_path, cloudlog, spinner=None): |
|
|
|
|
update = json.load(open(manifest_path)) |
|
|
|
|
|
|
|
|
|
current_slot = subprocess.check_output(["abctl", "--boot_slot"], encoding='utf-8').strip() |
|
|
|
|
target_slot = "_b" if current_slot == "_a" else "_a" |
|
|
|
|
target_slot_number = "0" if target_slot == "_a" else "1" |
|
|
|
|
|
|
|
|
|
cloudlog.info(f"Current slot {current_slot}, target slot {target_slot}") |
|
|
|
|
|
|
|
|
|
# set target slot as unbootable |
|
|
|
|
os.system(f"abctl --set_unbootable {target_slot_number}") |
|
|
|
|
|
|
|
|
|
for partition in update: |
|
|
|
|
def flash_partition(cloudlog, spinner, target_slot, partition): |
|
|
|
|
cloudlog.info(f"Downloading and writing {partition['name']}") |
|
|
|
|
|
|
|
|
|
downloader = StreamingDecompressor(partition['url']) |
|
|
|
@ -129,6 +117,37 @@ def flash_agnos_update(manifest_path, cloudlog, spinner=None): |
|
|
|
|
os.sync() |
|
|
|
|
out.write(partition['hash_raw'].lower().encode()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def flash_agnos_update(manifest_path, cloudlog, spinner=None): |
|
|
|
|
update = json.load(open(manifest_path)) |
|
|
|
|
|
|
|
|
|
current_slot = subprocess.check_output(["abctl", "--boot_slot"], encoding='utf-8').strip() |
|
|
|
|
target_slot = "_b" if current_slot == "_a" else "_a" |
|
|
|
|
target_slot_number = "0" if target_slot == "_a" else "1" |
|
|
|
|
|
|
|
|
|
cloudlog.info(f"Current slot {current_slot}, target slot {target_slot}") |
|
|
|
|
|
|
|
|
|
# set target slot as unbootable |
|
|
|
|
os.system(f"abctl --set_unbootable {target_slot_number}") |
|
|
|
|
|
|
|
|
|
for partition in update: |
|
|
|
|
success = False |
|
|
|
|
|
|
|
|
|
for retries in range(10): |
|
|
|
|
try: |
|
|
|
|
flash_partition(cloudlog, spinner, target_slot, partition) |
|
|
|
|
success = True |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
except requests.exceptions.RequestException: |
|
|
|
|
spinner.update("Waiting for internet...") |
|
|
|
|
cloudlog.info(f"Failed to download {partition['name']}, retrying ({retries})") |
|
|
|
|
time.sleep(10) |
|
|
|
|
|
|
|
|
|
if not success: |
|
|
|
|
cloudlog.info(f"Failed to flash {partition['name']}, aborting") |
|
|
|
|
raise Exception("Maximum retries exceeded") |
|
|
|
|
|
|
|
|
|
cloudlog.info(f"AGNOS ready on slot {target_slot}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|