diff --git a/src/hhd/plugins/bootc/__init__.py b/src/hhd/plugins/bootc/__init__.py index 98593ddf..d82436d5 100644 --- a/src/hhd/plugins/bootc/__init__.py +++ b/src/hhd/plugins/bootc/__init__.py @@ -77,7 +77,9 @@ def get_bootc_status(): def get_ref_from_status(status: dict | None): - return (status or {}).get("spec", {}).get("image", {}).get("image", "") + return (((status or {}).get("spec", None) or {}).get("image", None) or {}).get( + "image", "" + ) def get_branch(ref: str, branches: dict, fallback: bool = True): @@ -126,12 +128,14 @@ def is_incompatible(status: dict): if status.get("apiVersion", None) != "org.containers.bootc/v1": return True - if ((status.get("status", None) or {}).get("booted", None) or {}).get( - "incompatible", False - ): - return True + boot_incompatible = ( + (status.get("status", None) or {}).get("booted", None) or {} + ).get("incompatible", False) - return False + if staged := ((status.get("status", None) or {}).get("staged", None) or {}): + return staged.get("incompatible", False) + + return boot_incompatible class BootcPlugin(HHDPlugin): @@ -177,14 +181,21 @@ def open( def get_version(self, s): assert self.status return ( - (self.status.get("status", {}).get(s, None) or {}) - .get("image", {}) - .get("version", "") - ) + (self.status.get("status", {}).get(s, None) or {}).get("image", None) or {} + ).get("version", "") def _init(self, conf: Config): self.status = get_bootc_status() - ref = self.status.get("spec", {}).get("image", {}).get("image", "") + + if is_incompatible(self.status): + conf["updates.bootc.stage.mode"] = "incompatible" + self.state = "incompatible" + conf[f"updates.bootc.update"] = None + return + + ref = ((self.status.get("spec", None) or {}).get("image", None) or {}).get( + "image", "" + ) img = ref if "/" in img: img = img[img.rfind("/") + 1 :] @@ -222,7 +233,8 @@ def _init(self, conf: Config): # Then that will be the default, provided there is a rollback rollback = ( not staged - and self.status.get("spec", {}).get("bootOrder", None) == "rollback" + and (self.status.get("spec", None) or {}).get("bootOrder", None) + == "rollback" ) s = self.get_version("rollback") if s and rollback: @@ -253,10 +265,7 @@ def _init(self, conf: Config): else: conf[f"updates.bootc.update"] = None - if is_incompatible(self.status): - conf["updates.bootc.stage.mode"] = "incompatible" - self.state = "incompatible" - elif ( + if ( cached_version and cached_img == img and cached_version != self.get_version("staged") diff --git a/src/hhd/plugins/bootc/settings.yml b/src/hhd/plugins/bootc/settings.yml index f02e0c61..8660cd2c 100644 --- a/src/hhd/plugins/bootc/settings.yml +++ b/src/hhd/plugins/bootc/settings.yml @@ -140,16 +140,17 @@ children: tags: [error] title: Error default: > - Due to layering or custom initramfs, you cannot use bootc. - Undo the customizations and try again. + Due to layering or custom initramfs, you cannot update from here. + You can undo those with the button below. reset: type: action title: Run rpm-ostree reset tag: [verify] hint: >- - Disable the custom initramfs and remove layers. - + Disable the custom initramfs and remove layers. Your personal + data will not be affected. + loading_cancellable: type: container children: