diff --git a/supervisor/addons/build.py b/supervisor/addons/build.py index b5ccc7a61..41ae7934b 100644 --- a/supervisor/addons/build.py +++ b/supervisor/addons/build.py @@ -84,7 +84,7 @@ class AddonBuild(FileConfiguration, CoreSysAttributes): def base_image(self) -> str: """Return base image for this add-on.""" if not self._data[ATTR_BUILD_FROM]: - return f"ghcr.io/home-assistant/{self.sys_arch.default!s}-base:latest" + return f"ghcr.io/home-assistant/{self.arch!s}-base:latest" if isinstance(self._data[ATTR_BUILD_FROM], str): return self._data[ATTR_BUILD_FROM] @@ -220,7 +220,7 @@ class AddonBuild(FileConfiguration, CoreSysAttributes): build_args = { "BUILD_FROM": self.base_image, "BUILD_VERSION": version, - "BUILD_ARCH": self.sys_arch.default, + "BUILD_ARCH": self.arch, **self.additional_args, } diff --git a/supervisor/addons/model.py b/supervisor/addons/model.py index 57b6527ea..4ac0a1030 100644 --- a/supervisor/addons/model.py +++ b/supervisor/addons/model.py @@ -550,10 +550,7 @@ class AddonModel(JobGroup, ABC): @property def arch(self) -> CpuArch: """Return architecture to use for the addon's image.""" - if ATTR_IMAGE in self.data: - return self.sys_arch.match(self.data[ATTR_ARCH]) - - return self.sys_arch.default + return self.sys_arch.match(self.data[ATTR_ARCH]) @property def image(self) -> str | None: @@ -725,4 +722,5 @@ class AddonModel(JobGroup, ABC): return config[ATTR_IMAGE].format(arch=arch) # local build - return f"{config[ATTR_REPOSITORY]}/{self.sys_arch.default!s}-addon-{config[ATTR_SLUG]}" + arch = self.sys_arch.match(config[ATTR_ARCH]) + return f"{config[ATTR_REPOSITORY]}/{arch!s}-addon-{config[ATTR_SLUG]}" diff --git a/supervisor/arch.py b/supervisor/arch.py index c214c231d..882d06ba9 100644 --- a/supervisor/arch.py +++ b/supervisor/arch.py @@ -64,11 +64,12 @@ class CpuArchManager(CoreSysAttributes): if not self.sys_machine or self.sys_machine not in arch_data: _LOGGER.warning("Can't detect the machine type!") self._default_arch = native_support - self._supported_arch.append(self.default) + self._supported_arch = [self.default] + self._supported_set = {self.default} return # Use configs from arch.json - self._supported_arch.extend(CpuArch(a) for a in arch_data[self.sys_machine]) + self._supported_arch = [CpuArch(a) for a in arch_data[self.sys_machine]] self._default_arch = self.supported[0] # Make sure native support is in supported list diff --git a/tests/conftest.py b/tests/conftest.py index 04a500178..927051dc0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,6 +48,7 @@ from supervisor.const import ( ATTR_VERSION, REQUEST_FROM, CoreState, + CpuArch, ) from supervisor.coresys import CoreSys from supervisor.dbus.network import NetworkManager @@ -506,8 +507,9 @@ async def coresys( "Config": {"Labels": {"io.hass.arch": "amd64"}}, "HostConfig": {"Privileged": True}, } - coresys_obj.arch._default_arch = "amd64" - coresys_obj.arch._supported_set = {"amd64"} + coresys_obj.arch._default_arch = CpuArch.AMD64 + coresys_obj.arch._supported_arch = [CpuArch.AMD64] + coresys_obj.arch._supported_set = {CpuArch.AMD64} coresys_obj._machine = "qemux86-64" coresys_obj._machine_id = uuid4() @@ -984,15 +986,15 @@ async def mount_propagation(container: DockerContainer, coresys: CoreSys) -> Non @pytest.fixture def mock_amd64_arch_supported(coresys: CoreSys) -> None: """Mock amd64 arch as supported.""" - coresys.arch._supported_arch = ["amd64"] - coresys.arch._supported_set = {"amd64"} + coresys.arch._supported_arch = [CpuArch.AMD64] + coresys.arch._supported_set = {CpuArch.AMD64} @pytest.fixture def mock_aarch64_arch_supported(coresys: CoreSys) -> None: """Mock aarch64 arch as supported.""" - coresys.arch._supported_arch = ["amd64"] - coresys.arch._supported_set = {"amd64"} + coresys.arch._supported_arch = [CpuArch.AMD64] + coresys.arch._supported_set = {CpuArch.AMD64} @pytest.fixture