install: add --filesystem to handle ext4 or f2fs (MR 2011)

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
This commit is contained in:
Bobby The Builder 2021-03-07 08:38:37 -05:00 committed by Oliver Smith
parent 958ecc6c72
commit 807d7019f8
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
4 changed files with 33 additions and 14 deletions

View File

@ -420,6 +420,7 @@ deviceinfo_attributes = [
"sd_embed_firmware_step_size",
"partition_blacklist",
"boot_part_start",
"root_filesystem",
# weston
"weston_pixman_type",

View File

@ -251,6 +251,9 @@ def install(args):
if args.rsync:
raise ValueError("--on-device-installer cannot be combined with"
" --rsync")
if args.filesystem:
raise ValueError("--on-device-installer cannot be combined with"
" --filesystem")
else:
if args.ondev_cp:
raise ValueError("--cp can only be combined with --ondev")
@ -279,7 +282,10 @@ def install(args):
if flasher.get("split", False):
args.split = True
# Warning for android recovery zip with FDE
# Android recovery zip related
if args.android_recovery_zip and args.filesystem:
raise ValueError("--android-recovery-zip cannot be combined with"
" --filesystem (patches welcome)")
if args.android_recovery_zip and args.full_disk_encryption:
logging.info("WARNING: --fde is rarely used in combination with"
" --android-recovery-zip. If this does not work, consider"

View File

@ -75,21 +75,28 @@ def format_and_mount_root(args, device, root_label, sdcard):
"""
# Format
if not args.rsync:
# 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_ext4_args = ["mkfs.ext4", "-O", "^metadata_csum", "-F",
"-q", "-L", root_label]
filesystem = (args.filesystem or args.deviceinfo["root_filesystem"] or
"ext4")
# When we don't know the file system size before hand like
# with non-block devices, we need to explicitely set a number of
# inodes. See #1717 and #1845 for details
if not sdcard:
mkfs_ext4_args = mkfs_ext4_args + ["-N", "100000"]
if filesystem == "ext4":
# 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]
# When we don't know the file system size before hand like
# with non-block devices, we need to explicitely set a number of
# inodes. See #1717 and #1845 for details
if not sdcard:
mkfs_root_args = mkfs_root_args + ["-N", "100000"]
elif filesystem == "f2fs":
mkfs_root_args = ["mkfs.f2fs", "-f", "-l", root_label]
else:
raise RuntimeError(f"Don't know how to format {filesystem}!")
install_fsprogs(args, "ext4")
logging.info("(native) format " + device)
pmb.chroot.root(args, mkfs_ext4_args + [device])
install_fsprogs(args, filesystem)
logging.info(f"(native) format {device} (root, {filesystem})")
pmb.chroot.root(args, mkfs_root_args + [device])
# Mount
mountpoint = "/mnt/install"

View File

@ -155,6 +155,11 @@ def arguments_install(subparser):
" 'pmbootstrap install' run or by providing it"
" as CHROOT_DEST with --cp", action="store_true")
# Other
group = ret.add_argument_group("other optional arguments")
group.add_argument("--filesystem", help="root filesystem type",
choices=["ext4", "f2fs"])
def arguments_export(subparser):
ret = subparser.add_parser("export", help="create convenience symlinks"