diff --git a/pmb/helpers/devices.py b/pmb/helpers/devices.py index 68c29e6f..dc39817b 100644 --- a/pmb/helpers/devices.py +++ b/pmb/helpers/devices.py @@ -51,6 +51,21 @@ class DeviceCategory(Enum): DeviceCategory.DOWNSTREAM, ] + def allows_downstream_ports(self) -> bool: + """Check whether a given category is allowed to contain downstream ports. This does not + necessarily mean that it exclusively contains downstream ports. + + :returns: True, if the category allows downstream ports, False if only allows mainline ports. + """ + + match self: + case DeviceCategory.ARCHIVED | DeviceCategory.DOWNSTREAM: + return True + case DeviceCategory.TESTING | DeviceCategory.COMMUNITY | DeviceCategory.MAIN: + return False + case _: + raise AssertionError + def explain(self) -> str: """Provide an explanation of a given category. diff --git a/pmb/install/format.py b/pmb/install/format.py index 8e898a82..e598f7fc 100644 --- a/pmb/install/format.py +++ b/pmb/install/format.py @@ -1,7 +1,7 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later from pmb.helpers import logging -from pmb.helpers.devices import get_device_category_by_name, DeviceCategory +from pmb.helpers.devices import get_device_category_by_name import pmb.chroot from pmb.core import Chroot from pmb.core.context import get_context @@ -177,7 +177,7 @@ def format_and_mount_root( if filesystem == "ext4": device_category = get_device_category_by_name(get_context().config.device) - if device_category == DeviceCategory.DOWNSTREAM: + if device_category.allows_downstream_ports(): # Some downstream kernels don't support metadata_csum (#1364). # When changing the options of mkfs.ext4, also change them in the # recovery zip code (see 'grep -r mkfs\.ext4')!