install: verify pmaports branch supporting fs (MR 2011)

Do not attempt to install with a filesystem that is not supported by the
initramfs code in the checked out pmaports branch.

Previously we would have increased the pmaports.cfg version and require
that new version by pmbootstrap, however this will break compatibility
with release branches where we won't roll out this feature (v20.05).
Therefore don't change the version, but add a new
"supported_root_filesystems" key to pmaports.cfg, which defaults to
"ext4".

Related: https://postmarketos.org/pmaports.cfg
This commit is contained in:
Oliver Smith 2021-03-19 01:30:30 +01:00
parent 807d7019f8
commit 8df7514b8e
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 21 additions and 2 deletions

View file

@ -308,6 +308,9 @@ def install(args):
" packages found. Consider 'pmbootstrap zap -p'" " packages found. Consider 'pmbootstrap zap -p'"
" to delete them.") " to delete them.")
# Verify that the root filesystem is supported by current pmaports branch
pmb.install.get_root_filesystem(args)
pmb.install.install(args) pmb.install.install(args)

View file

@ -4,4 +4,5 @@ from pmb.install._install import install
from pmb.install._install import get_kernel_package from pmb.install._install import get_kernel_package
from pmb.install.partition import partition from pmb.install.partition import partition
from pmb.install.format import format from pmb.install.format import format
from pmb.install.format import get_root_filesystem
from pmb.install.partition import partitions_mount from pmb.install.partition import partitions_mount

View file

@ -67,6 +67,22 @@ def format_luks_root(args, device):
raise RuntimeError("Failed to open cryptdevice!") raise RuntimeError("Failed to open cryptdevice!")
def get_root_filesystem(args):
ret = args.filesystem or args.deviceinfo["root_filesystem"] or "ext4"
pmaports_cfg = pmb.config.pmaports.read_config(args)
supported = pmaports_cfg.get("supported_root_filesystems", "ext4")
supported_list = supported.split(",")
if ret not in supported_list:
raise ValueError(f"Root filesystem {ret} is not supported by your"
" currently checked out pmaports branch. Update your"
" branch ('pmbootstrap pull'), change it"
" ('pmbootstrap init'), or select one of these"
f" filesystems: {', '.join(supported_list)}")
return ret
def format_and_mount_root(args, device, root_label, sdcard): def format_and_mount_root(args, device, root_label, sdcard):
""" """
:param device: root partition on install block device (e.g. /dev/installp2) :param device: root partition on install block device (e.g. /dev/installp2)
@ -75,8 +91,7 @@ def format_and_mount_root(args, device, root_label, sdcard):
""" """
# Format # Format
if not args.rsync: if not args.rsync:
filesystem = (args.filesystem or args.deviceinfo["root_filesystem"] or filesystem = get_root_filesystem(args)
"ext4")
if filesystem == "ext4": if filesystem == "ext4":
# Some downstream kernels don't support metadata_csum (#1364). # Some downstream kernels don't support metadata_csum (#1364).