diff --git a/src/otaclient/boot_control/_grub.py b/src/otaclient/boot_control/_grub.py index 996764917..6b79f4ca8 100644 --- a/src/otaclient/boot_control/_grub.py +++ b/src/otaclient/boot_control/_grub.py @@ -848,7 +848,7 @@ def _cleanup_standby_ota_partition_folder(self): def _copy_boot_files_from_standby_slot(self): """Copy boot files under /boot to standby ota-partition folder.""" standby_ota_partition_dir = self._ota_status_control.standby_ota_status_dir - for f in self._mp_control.standby_boot_dir.iterdir(): + for f in (self._mp_control.standby_slot_mount_point / "boot").iterdir(): if f.is_file() and not f.is_symlink(): shutil.copy(f, standby_ota_partition_dir) @@ -857,9 +857,6 @@ def _copy_boot_files_from_standby_slot(self): def get_standby_slot_path(self) -> Path: # pragma: no cover return self._mp_control.standby_slot_mount_point - def get_standby_boot_dir(self) -> Path: # pragma: no cover - return self._mp_control.standby_boot_dir - def load_version(self) -> str: # pragma: no cover return self._ota_status_control.load_active_slot_version() diff --git a/src/otaclient/boot_control/_jetson_cboot.py b/src/otaclient/boot_control/_jetson_cboot.py index 0c0bcd5d4..ac240aaf7 100644 --- a/src/otaclient/boot_control/_jetson_cboot.py +++ b/src/otaclient/boot_control/_jetson_cboot.py @@ -584,9 +584,6 @@ def _firmware_update(self) -> bool | None: def get_standby_slot_path(self) -> Path: # pragma: no cover return self._mp_control.standby_slot_mount_point - def get_standby_boot_dir(self) -> Path: # pragma: no cover - return self._mp_control.standby_boot_dir - def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby: bool): try: logger.info("jetson-cboot: pre-update ...") diff --git a/src/otaclient/boot_control/_jetson_uefi.py b/src/otaclient/boot_control/_jetson_uefi.py index dd9a6523b..606df4910 100644 --- a/src/otaclient/boot_control/_jetson_uefi.py +++ b/src/otaclient/boot_control/_jetson_uefi.py @@ -962,9 +962,6 @@ def _firmware_update(self) -> bool: def get_standby_slot_path(self) -> Path: # pragma: no cover return self._mp_control.standby_slot_mount_point - def get_standby_boot_dir(self) -> Path: # pragma: no cover - return self._mp_control.standby_boot_dir - def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby: bool): try: logger.info("jetson-uefi: pre-update ...") diff --git a/src/otaclient/boot_control/_rpi_boot.py b/src/otaclient/boot_control/_rpi_boot.py index ace80c7b0..69cff1aef 100644 --- a/src/otaclient/boot_control/_rpi_boot.py +++ b/src/otaclient/boot_control/_rpi_boot.py @@ -479,9 +479,6 @@ def _write_standby_fstab(self): def get_standby_slot_path(self) -> Path: # pragma: no cover return self._mp_control.standby_slot_mount_point - def get_standby_boot_dir(self) -> Path: # pragma: no cover - return self._mp_control.standby_boot_dir - def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby: bool): try: logger.info("rpi_boot: pre-update setup...") diff --git a/src/otaclient/boot_control/_slot_mnt_helper.py b/src/otaclient/boot_control/_slot_mnt_helper.py index 868850b57..ec95998f8 100644 --- a/src/otaclient/boot_control/_slot_mnt_helper.py +++ b/src/otaclient/boot_control/_slot_mnt_helper.py @@ -23,7 +23,7 @@ from pathlib import Path from otaclient.configs.cfg import cfg -from otaclient_common import cmdhelper, replace_root +from otaclient_common import cmdhelper from otaclient_common.typing import StrOrPath logger = logging.getLogger(__name__) @@ -46,16 +46,6 @@ def __init__( self.standby_slot_mount_point = Path(standby_slot_mount_point) self.active_slot_mount_point = Path(active_slot_mount_point) - # standby slot /boot dir - # NOTE(20230907): this will always be /boot, - # in the future this attribute will not be used by - # standby slot creater. - self.standby_boot_dir = Path( - replace_root( - cfg.BOOT_DPATH, cfg.CANONICAL_ROOT, self.standby_slot_mount_point - ) - ) - # ensure the each mount points being umounted at termination atexit.register( partial( diff --git a/src/otaclient/boot_control/protocol.py b/src/otaclient/boot_control/protocol.py index 5fda7d60b..27b6fe75d 100644 --- a/src/otaclient/boot_control/protocol.py +++ b/src/otaclient/boot_control/protocol.py @@ -19,8 +19,6 @@ from pathlib import Path from typing import Protocol -from typing_extensions import deprecated - from otaclient._types import OTAStatus @@ -39,22 +37,6 @@ def get_booted_ota_status(self) -> OTAStatus: def get_standby_slot_path(self) -> Path: """Get the Path points to the standby slot mount point.""" - @deprecated( - "standby slot creator doesn't need to treat the files under /boot specially" - ) - @abstractmethod - def get_standby_boot_dir(self) -> Path: - """Get the Path points to the standby slot's boot folder. - - NOTE(20230907): this will always return the path to - /boot. - DEPRECATED(20230907): standby slot creator doesn't need to - treat the files under /boot specially, it is - boot controller's responsibility to get the - kernel/initrd.img from standby slot and prepare - them to actual boot dir. - """ - @abstractmethod def load_version(self) -> str: """Read the version info from the current slot.""" diff --git a/src/otaclient/ota_core.py b/src/otaclient/ota_core.py index c36759cad..78cb25f9b 100644 --- a/src/otaclient/ota_core.py +++ b/src/otaclient/ota_core.py @@ -489,9 +489,14 @@ def _execute_update(self): self._ota_tmp_image_meta_dir_on_standby.mkdir(exist_ok=True) # ------ in-update ------ # + # NOTE(20230907): standby slot creator doesn't need to + # treat the files under /boot specially, it is + # boot controller's responsibility to get the + # kernel/initrd.img from standby slot and prepare + # them to actual boot dir. standby_slot_creator = self._create_standby_cls( ota_metadata=otameta, - boot_dir=str(self._boot_controller.get_standby_boot_dir()), + boot_dir=str(Path(cfg.STANDBY_SLOT_MNT) / "boot"), active_slot_mount_point=cfg.ACTIVE_SLOT_MNT, standby_slot_mount_point=cfg.STANDBY_SLOT_MNT, status_report_queue=self._status_report_queue, diff --git a/tests/test_otaclient/test_create_standby.py b/tests/test_otaclient/test_create_standby.py index cb2abf3bf..444449114 100644 --- a/tests/test_otaclient/test_create_standby.py +++ b/tests/test_otaclient/test_create_standby.py @@ -88,7 +88,6 @@ def mock_setup(self, mocker: MockerFixture, prepare_ab_slots): self._boot_control = typing.cast( BootControllerProtocol, mocker.MagicMock(spec=BootControllerProtocol) ) - self._boot_control.get_standby_boot_dir.return_value = self.slot_b_boot_dir # type: ignore # ------ mock otaclient cfg ------ # mocker.patch(f"{OTA_CORE_MODULE}.cfg.STANDBY_SLOT_MNT", str(self.slot_b))