forked from Mirror/pmbootstrap
pmb: Only disable metadata_csum for ext4 on downstream ports
No need to worsen filesystem reliability for mainline devices that don't need this workaround. Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2557 Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2616
This commit is contained in:
parent
7035c0239d
commit
89a80265de
2 changed files with 37 additions and 4 deletions
|
@ -9,6 +9,7 @@ from pathlib import Path
|
|||
import pmb.config
|
||||
from pmb.core.pkgrepo import pkgrepo_glob_one, pkgrepo_iglob
|
||||
from pmb.helpers import logging
|
||||
import pmb.helpers.pmaports
|
||||
|
||||
|
||||
def find_path(codename: str, file: str = "") -> Path | None:
|
||||
|
@ -164,3 +165,26 @@ def get_device_category_by_apkbuild_path(apkbuild_path: Path) -> DeviceCategory:
|
|||
raise RuntimeError(f'Unknown device category "{category_str}"') from exception
|
||||
|
||||
return device_category
|
||||
|
||||
|
||||
def get_device_category_by_directory_path(device_directory: Path) -> DeviceCategory:
|
||||
"""Get the category of a device based on the path to its directory inside of pmaports.
|
||||
|
||||
:device_directory: Path to the device package directory for a particular device.
|
||||
:returns: The device category of the provided device directory.
|
||||
"""
|
||||
device_apkbuild_path = device_directory / "APKBUILD"
|
||||
|
||||
return get_device_category_by_apkbuild_path(device_apkbuild_path)
|
||||
|
||||
|
||||
def get_device_category_by_name(device_name: str) -> DeviceCategory:
|
||||
"""Get the category of a device based on its name.
|
||||
|
||||
:device_name: Name of a particular device to determine the category of.
|
||||
Format should be "vendor-codename".
|
||||
:returns: The device category of the provided device name.
|
||||
"""
|
||||
device_directory = pmb.helpers.pmaports.find(f"device-{device_name}")
|
||||
|
||||
return get_device_category_by_directory_path(device_directory)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# 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
|
||||
import pmb.chroot
|
||||
from pmb.core import Chroot
|
||||
from pmb.core.context import get_context
|
||||
from pmb.types import PartitionLayout, PmbArgs, PathString
|
||||
import os
|
||||
import tempfile
|
||||
|
@ -173,10 +175,17 @@ def format_and_mount_root(
|
|||
filesystem = get_root_filesystem(args)
|
||||
|
||||
if filesystem == "ext4":
|
||||
device_category = get_device_category_by_name(get_context().config.device)
|
||||
|
||||
if device_category == DeviceCategory.DOWNSTREAM:
|
||||
# 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')!
|
||||
mkfs_root_args = ["mkfs.ext4", "-O", "^metadata_csum", "-F", "-q", "-L", root_label]
|
||||
category_opts = ["-O", "^metadata_csum"]
|
||||
else:
|
||||
category_opts = []
|
||||
|
||||
mkfs_root_args = ["mkfs.ext4", *category_opts, "-F", "-q", "-L", root_label]
|
||||
if not disk:
|
||||
# pmb#2568: tell mkfs.ext4 to make a filesystem with enough
|
||||
# indoes that we don't run into "out of space" errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue