mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
Use Supervisor arch to determine container arch
For installations with Supervisor, use the architecture from the Supervisor API instead of reading the architecture from the container. This is more coherent as we trust the Supervisor data already, and gets rid of an unnecessary dependency for aiofiles.
This commit is contained in:
@@ -12,7 +12,6 @@ import re
|
||||
import struct
|
||||
from typing import Any, NamedTuple
|
||||
|
||||
import aiofiles
|
||||
from aiohasupervisor import SupervisorError
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -239,12 +238,6 @@ def _is_32_bit() -> bool:
|
||||
return size * 8 == 32
|
||||
|
||||
|
||||
async def _get_arch() -> str:
|
||||
async with aiofiles.open("/etc/apk/arch") as arch_file:
|
||||
raw_arch = await arch_file.read()
|
||||
return {"x86": "i386"}.get(raw_arch, raw_arch)
|
||||
|
||||
|
||||
class APIEndpointSettings(NamedTuple):
|
||||
"""Settings for API endpoint."""
|
||||
|
||||
@@ -566,8 +559,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
hass.data[ADDONS_COORDINATOR] = coordinator
|
||||
|
||||
arch = await _get_arch()
|
||||
|
||||
def deprecated_setup_issue() -> None:
|
||||
os_info = get_os_info(hass)
|
||||
info = get_info(hass)
|
||||
@@ -575,6 +566,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
return
|
||||
is_haos = info.get("hassos") is not None
|
||||
board = os_info.get("board")
|
||||
arch = info.get("arch", "unknown")
|
||||
unsupported_board = board in {"tinker", "odroid-xu4", "rpi2"}
|
||||
unsupported_os_on_board = board in {"rpi3", "rpi4"}
|
||||
if is_haos and (unsupported_board or unsupported_os_on_board):
|
||||
|
@@ -260,16 +260,3 @@ def all_setup_requests(
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def arch() -> str:
|
||||
"""Arch found in apk file."""
|
||||
return "amd64"
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_arch_file(arch: str) -> Generator[None]:
|
||||
"""Mock arch file."""
|
||||
with patch("homeassistant.components.hassio._get_arch", return_value=arch):
|
||||
yield
|
||||
|
@@ -1166,17 +1166,11 @@ async def test_deprecated_installation_issue_os_armv7(
|
||||
freezer: FrozenDateTimeFactory,
|
||||
board: str,
|
||||
issue_id: str,
|
||||
arch: str,
|
||||
) -> None:
|
||||
"""Test deprecated installation issue."""
|
||||
with (
|
||||
patch.dict(os.environ, MOCK_ENVIRON),
|
||||
patch(
|
||||
"homeassistant.components.homeassistant.async_get_system_info",
|
||||
return_value={
|
||||
"installation_type": "Home Assistant OS",
|
||||
"arch": "armv7",
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio._is_32_bit",
|
||||
return_value=True,
|
||||
@@ -1185,7 +1179,8 @@ async def test_deprecated_installation_issue_os_armv7(
|
||||
"homeassistant.components.hassio.get_os_info", return_value={"board": board}
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info", return_value={"hassos": True}
|
||||
"homeassistant.components.hassio.get_info",
|
||||
return_value={"hassos": True, "arch": "armv7"},
|
||||
),
|
||||
patch("homeassistant.components.hardware.async_setup", return_value=True),
|
||||
):
|
||||
@@ -1238,13 +1233,6 @@ async def test_deprecated_installation_issue_32bit_os(
|
||||
"""Test deprecated architecture issue."""
|
||||
with (
|
||||
patch.dict(os.environ, MOCK_ENVIRON),
|
||||
patch(
|
||||
"homeassistant.components.homeassistant.async_get_system_info",
|
||||
return_value={
|
||||
"installation_type": "Home Assistant OS",
|
||||
"arch": arch,
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio._is_32_bit",
|
||||
return_value=True,
|
||||
@@ -1254,7 +1242,8 @@ async def test_deprecated_installation_issue_32bit_os(
|
||||
return_value={"board": "rpi3-64"},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info", return_value={"hassos": True}
|
||||
"homeassistant.components.hassio.get_info",
|
||||
return_value={"hassos": True, "arch": arch},
|
||||
),
|
||||
patch("homeassistant.components.hardware.async_setup", return_value=True),
|
||||
):
|
||||
@@ -1305,13 +1294,6 @@ async def test_deprecated_installation_issue_32bit_supervised(
|
||||
"""Test deprecated architecture issue."""
|
||||
with (
|
||||
patch.dict(os.environ, MOCK_ENVIRON),
|
||||
patch(
|
||||
"homeassistant.components.homeassistant.async_get_system_info",
|
||||
return_value={
|
||||
"installation_type": "Home Assistant Supervised",
|
||||
"arch": arch,
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio._is_32_bit",
|
||||
return_value=True,
|
||||
@@ -1321,7 +1303,8 @@ async def test_deprecated_installation_issue_32bit_supervised(
|
||||
return_value={"board": "rpi3-64"},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info", return_value={"hassos": None}
|
||||
"homeassistant.components.hassio.get_info",
|
||||
return_value={"hassos": None, "arch": arch},
|
||||
),
|
||||
patch("homeassistant.components.hardware.async_setup", return_value=True),
|
||||
):
|
||||
@@ -1376,13 +1359,6 @@ async def test_deprecated_installation_issue_64bit_supervised(
|
||||
"""Test deprecated architecture issue."""
|
||||
with (
|
||||
patch.dict(os.environ, MOCK_ENVIRON),
|
||||
patch(
|
||||
"homeassistant.components.homeassistant.async_get_system_info",
|
||||
return_value={
|
||||
"installation_type": "Home Assistant Supervised",
|
||||
"arch": arch,
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio._is_32_bit",
|
||||
return_value=False,
|
||||
@@ -1392,7 +1368,8 @@ async def test_deprecated_installation_issue_64bit_supervised(
|
||||
return_value={"board": "generic-x86-64"},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info", return_value={"hassos": None}
|
||||
"homeassistant.components.hassio.get_info",
|
||||
return_value={"hassos": None, "arch": arch},
|
||||
),
|
||||
patch("homeassistant.components.hardware.async_setup", return_value=True),
|
||||
):
|
||||
@@ -1445,13 +1422,6 @@ async def test_deprecated_installation_issue_supported_board(
|
||||
"""Test no deprecated installation issue for a supported board."""
|
||||
with (
|
||||
patch.dict(os.environ, MOCK_ENVIRON),
|
||||
patch(
|
||||
"homeassistant.components.homeassistant.async_get_system_info",
|
||||
return_value={
|
||||
"installation_type": "Home Assistant OS",
|
||||
"arch": "aarch64",
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio._is_32_bit",
|
||||
return_value=False,
|
||||
@@ -1460,7 +1430,8 @@ async def test_deprecated_installation_issue_supported_board(
|
||||
"homeassistant.components.hassio.get_os_info", return_value={"board": board}
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info", return_value={"hassos": True}
|
||||
"homeassistant.components.hassio.get_info",
|
||||
return_value={"hassos": True, "arch": "aarch64"},
|
||||
),
|
||||
):
|
||||
assert await async_setup_component(hass, "homeassistant", {})
|
||||
|
Reference in New Issue
Block a user