From 0e7ddc8768725b4f9fd11da394a6473eaff73a58 Mon Sep 17 00:00:00 2001 From: Bodong Yang Date: Fri, 10 May 2024 11:57:56 +0000 Subject: [PATCH] minor fix jetson_cboot related --- otaclient/app/boot_control/_jetson_cboot.py | 9 ++++----- otaclient/app/boot_control/_jetson_common.py | 19 +++++++++++-------- tests/test_boot_control/test_jetson_cboot.py | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/otaclient/app/boot_control/_jetson_cboot.py b/otaclient/app/boot_control/_jetson_cboot.py index e46bc0490..63c4ddab1 100644 --- a/otaclient/app/boot_control/_jetson_cboot.py +++ b/otaclient/app/boot_control/_jetson_cboot.py @@ -25,8 +25,7 @@ import subprocess from functools import partial from pathlib import Path -from subprocess import CalledProcessError, CompletedProcess, run -from typing import Generator, Literal, Optional +from typing import Generator, Optional from otaclient.app import errors as ota_errors from otaclient.app.common import ( @@ -36,15 +35,17 @@ ) from otaclient.app.proto import wrapper +from ..configs import config as cfg from ._common import CMDHelperFuncs, OTAStatusFilesControl, SlotMountHelper from ._jetson_common import ( + NVBootctrlTarget, FirmwareBSPVersionControl, NVBootctrlCommon, SlotID, parse_bsp_version, update_extlinux_cfg, ) -from .configs import cboot_cfg as cfg +from .configs import cboot_cfg as boot_cfg from .protocol import BootControllerProtocol logger = logging.getLogger(__name__) @@ -61,8 +62,6 @@ class _NVBootctrl(NVBootctrlCommon): Without -t option, the target will be bootloader by default. """ - NVBootctrlTarget = Literal["bootloader", "rootfs"] - @classmethod def mark_boot_successful( cls, slot_id: SlotID, *, target: Optional[NVBootctrlTarget] = None diff --git a/otaclient/app/boot_control/_jetson_common.py b/otaclient/app/boot_control/_jetson_common.py index da3c0194d..8ddb1821c 100644 --- a/otaclient/app/boot_control/_jetson_common.py +++ b/otaclient/app/boot_control/_jetson_common.py @@ -78,22 +78,26 @@ def dump(to_export: BSPVersion) -> str: return f"R{to_export.major_ver}.{to_export.major_rev}.{to_export.minor_rev}" +BSPVersionStr = Annotated[ + BSPVersion, + BeforeValidator(BSPVersion.parse), + PlainSerializer(BSPVersion.dump, return_type=str), +] +"""BSPVersion in string representation, used by FirmwareBSPVersion model.""" + + class FirmwareBSPVersion(BaseModel): """ BSP version string schema: Rxx.yy.z """ - BSPVersionStr = Annotated[ - BSPVersion, - BeforeValidator(BSPVersion.parse), - PlainSerializer(BSPVersion.dump, return_type=str), - ] - """BSPVersion in string representation, used by FirmwareBSPVersion model.""" - slot_a: Optional[BSPVersionStr] = None slot_b: Optional[BSPVersionStr] = None +NVBootctrlTarget = Literal["bootloader", "rootfs"] + + class NVBootctrlCommon: """Helper for calling nvbootctrl commands. @@ -111,7 +115,6 @@ class NVBootctrlCommon: """ NVBOOTCTRL = "nvbootctrl" - NVBootctrlTarget = Literal["bootloader", "rootfs"] @classmethod def _nvbootctrl( diff --git a/tests/test_boot_control/test_jetson_cboot.py b/tests/test_boot_control/test_jetson_cboot.py index a292d4a86..ce12fdf7a 100644 --- a/tests/test_boot_control/test_jetson_cboot.py +++ b/tests/test_boot_control/test_jetson_cboot.py @@ -25,13 +25,13 @@ import pytest from otaclient.app.boot_control import _jetson_cboot +from otaclient.app.boot_control._jetson_cboot import _CBootControl from otaclient.app.boot_control._jetson_common import ( BSPVersion, FirmwareBSPVersion, SlotID, parse_bsp_version, ) -from otaclient.app.boot_control._jetson_cboot import _CBootControl logger = logging.getLogger(__name__)