From c3c30f4bd8a4f58e47ef4e19c521e7d028448aee Mon Sep 17 00:00:00 2001 From: Andrei Radulescu Date: Thu, 8 Aug 2024 02:11:38 +0300 Subject: [PATCH 1/2] package_ota: don't convert sparse image to raw if raw images already exists --- scripts/package_ota.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/package_ota.py b/scripts/package_ota.py index a03ea21b..5ce33bfe 100755 --- a/scripts/package_ota.py +++ b/scripts/package_ota.py @@ -32,12 +32,18 @@ def process_file(fn, name, sparse=False, full_check=True, has_ab=True, alt=None) print(f" {size} bytes, hash {hash}") if sparse: - with NamedTemporaryFile() as tmp_f: + raw_img = OUTPUT_DIR / "system.raw.img" + if raw_img.exists(): + print(" using existing raw image") + hash_raw = checksum(raw_img) + size = raw_img.stat().st_size + else: print(" converting sparse image to raw") - subprocess.check_call(["simg2img", fn, tmp_f.name]) - hash_raw = checksum(tmp_f.name) - size = Path(tmp_f.name).stat().st_size - print(f" {size} bytes, hash {hash} (raw)") + with NamedTemporaryFile() as tmp_f: + subprocess.check_call(["simg2img", fn, tmp_f.name]) + hash_raw = checksum(tmp_f.name) + size = Path(tmp_f.name).stat().st_size + print(f" {size} bytes, hash {hash_raw} (raw)") print(" compressing") xz_fn = OTA_OUTPUT_DIR / f"{fn.stem}-{hash_raw}.img.xz" From ba1dfd09c8bddb8cde8fc7491b122a1eb0ae836e Mon Sep 17 00:00:00 2001 From: Andrei Radulescu Date: Thu, 8 Aug 2024 02:32:42 +0300 Subject: [PATCH 2/2] don't convert anymore --- .github/workflows/build.yaml | 1 - scripts/package_ota.py | 7 ------- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2c172122..28beb76e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -69,7 +69,6 @@ jobs: env: AGNOS_UPDATE_URL: https://raw.githubusercontent.com/commaai/ci-artifacts/agnos-builder/pr-${{ github.event.number }}/ run: | - sudo apt-get install -y android-sdk-libsparse-utils scripts/package_ota.py - name: Copy and push boot, system and agnos.json diff --git a/scripts/package_ota.py b/scripts/package_ota.py index 5ce33bfe..8334bd7e 100755 --- a/scripts/package_ota.py +++ b/scripts/package_ota.py @@ -5,7 +5,6 @@ import subprocess from copy import deepcopy from pathlib import Path -from tempfile import NamedTemporaryFile ROOT = Path(__file__).parent.parent OUTPUT_DIR = ROOT / "output" @@ -37,12 +36,6 @@ def process_file(fn, name, sparse=False, full_check=True, has_ab=True, alt=None) print(" using existing raw image") hash_raw = checksum(raw_img) size = raw_img.stat().st_size - else: - print(" converting sparse image to raw") - with NamedTemporaryFile() as tmp_f: - subprocess.check_call(["simg2img", fn, tmp_f.name]) - hash_raw = checksum(tmp_f.name) - size = Path(tmp_f.name).stat().st_size print(f" {size} bytes, hash {hash_raw} (raw)") print(" compressing")