build_remote.py: better detection of invalid snaps

This commit is contained in:
Will Greenberg
2026-07-21 17:02:15 -07:00
parent c777edbf77
commit 9dd1f5eb4c
+10 -7
View File
@@ -144,14 +144,17 @@ def _build_snap(
for arch in archs: for arch in archs:
snap_path_list = glob.glob(join(workspace, f'{target}_*_{arch}.snap')) snap_path_list = glob.glob(join(workspace, f'{target}_*_{arch}.snap'))
assert len(snap_path_list) == 1 assert len(snap_path_list) == 1
with open(snap_path_list[0], 'r') as f: with open(snap_path_list[0], 'rb') as f:
try: first_block = f.read(10)
first_line = f.readline().rstrip() # 'hsqs' is the magic number that SquashFS files start with
except UnicodeDecodeError: if first_block.startswith(b'hsqs'):
first_line = '' continue
if first_line == "<!DOCTYPE html>":
failed_archs.add(arch) failed_archs.add(arch)
print(f'The {target} {arch} snap file contains html instead of a snap') try:
first_block_str = first_block.decode()
except UnicodeDecodeError:
first_block_str = first_block.hex()
print(f'The {target} {arch} snap file began with invalid data: {first_block_str}')
dump_output = bool(failed_archs) dump_output = bool(failed_archs)
if not dump_output: if not dump_output: