From 7b78bcfcf9e37ec66f946d6164fe92ad16c1cf63 Mon Sep 17 00:00:00 2001 From: Newbyte Date: Mon, 7 Jul 2025 15:04:28 +0200 Subject: [PATCH] pmb: Also apply ext4 metadata_csum workaround for archived ports Ports in the archived category may be downstream ports. While mainline ports also are allowed, archived ports should generally not be relied on anyway so the loss of ext4 reliability on those shouldn't matter. Fixes 89a80265de7e4228dfb2cea6f1fb6207a327e846 Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2640 --- pmb/helpers/devices.py | 15 +++++++++++++++ pmb/install/format.py | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) 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')!