From 0b750a39dad588b22029b65ba91db0e8cd8956a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 4 Oct 2021 14:53:47 +0200 Subject: [PATCH] Rename Partition.name to Partition.description As suggested in https://github.com/systemd/mkosi/pull/798#discussion_r714875622. --- mkosi/__init__.py | 30 +++++++++++++++--------------- mkosi/backend.py | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index ba798478b..d0e8c7f8b 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -529,7 +529,7 @@ def disable_cow(path: PathString) -> None: run(["chattr", "+C", path], stdout=DEVNULL, stderr=DEVNULL, check=False) -def root_partition_name( +def root_partition_description( args: Optional[CommandLineArguments], suffix: Optional[str] = None, image_id: Optional[str] = None, @@ -598,7 +598,7 @@ def initialize_partition_table(args: CommandLineArguments) -> None: (not is_generated_root(args), PartitionIdentifier.root, args.root_size, gpt_root_native(args.architecture, args.usr_only).root, - root_partition_name(args), + root_partition_description(args), args.read_only)): if condition and size is not None: @@ -894,7 +894,7 @@ def luks_format_root( return assert args.passphrase is not None - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): luks_format(part.blockdev(loopdev), args.passphrase) @@ -910,7 +910,7 @@ def luks_format_home(args: CommandLineArguments, loopdev: Path, do_run_build_scr return assert args.passphrase is not None - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): luks_format(part.blockdev(loopdev), args.passphrase) @@ -926,7 +926,7 @@ def luks_format_srv(args: CommandLineArguments, loopdev: Path, do_run_build_scri return assert args.passphrase is not None - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): luks_format(part.blockdev(loopdev), args.passphrase) @@ -942,7 +942,7 @@ def luks_format_var(args: CommandLineArguments, loopdev: Path, do_run_build_scri return assert args.passphrase is not None - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): luks_format(part.blockdev(loopdev), args.passphrase) @@ -958,7 +958,7 @@ def luks_format_tmp(args: CommandLineArguments, loopdev: Path, do_run_build_scri return assert args.passphrase is not None - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): luks_format(part.blockdev(loopdev), args.passphrase) @@ -967,7 +967,7 @@ def luks_open(part: Partition, loopdev: Path, passphrase: Dict[str, str]) -> Gen name = str(uuid.uuid4()) dev = part.blockdev(loopdev) - with complete_step(f"Setting up LUKS on {part.name}…"): + with complete_step(f"Setting up LUKS on {part.description}…"): if passphrase["type"] == "stdin": passphrase_content = (passphrase["content"] + "\n").encode("utf-8") run(["cryptsetup", "open", "--type", "luks", dev, name], input=passphrase_content) @@ -980,7 +980,7 @@ def luks_open(part: Partition, loopdev: Path, passphrase: Dict[str, str]) -> Gen try: yield path finally: - with complete_step(f"Closing LUKS on {part.name}"): + with complete_step(f"Closing LUKS on {part.description}"): run(["cryptsetup", "close", path]) @@ -3359,7 +3359,7 @@ def insert_partition( loopdev: Path, blob: BinaryIO, ident: PartitionIdentifier, - name: str, + description: str, type_uuid: uuid.UUID, read_only: bool, part_uuid: Optional[uuid.UUID] = None, @@ -3369,7 +3369,7 @@ def insert_partition( luks_extra = 16 * 1024 * 1024 if args.encrypt == "all" else 0 blob_size = os.stat(blob.name).st_size - part = args.partition_table.add(ident, blob_size + luks_extra, type_uuid, name, part_uuid) + part = args.partition_table.add(ident, blob_size + luks_extra, type_uuid, description, part_uuid) disk_size = args.partition_table.disk_size() ss = f" ({disk_size // args.partition_table.sector_size} sectors)" if 'disk' in ARG_DEBUG else "" @@ -3420,7 +3420,7 @@ def insert_generated_root( loopdev, image, PartitionIdentifier.root, - root_partition_name(args), + root_partition_description(args), type_uuid=gpt_root_native(args.architecture, args.usr_only).root, read_only=args.read_only) @@ -3472,7 +3472,7 @@ def insert_verity( loopdev, verity, PartitionIdentifier.verity, - root_partition_name(args, "Verity"), + root_partition_description(args, "Verity"), gpt_root_native(args.architecture, args.usr_only).verity, read_only=True, part_uuid=u) @@ -3577,7 +3577,7 @@ def insert_verity_sig( loopdev, verity_sig, PartitionIdentifier.verity_sig, - root_partition_name(args, "Signature"), + root_partition_description(args, "Signature"), gpt_root_native(args.architecture, args.usr_only).verity_sig, read_only=True, part_uuid=u) @@ -5907,7 +5907,7 @@ def load_args(args: argparse.Namespace) -> CommandLineArguments: args.kernel_command_line.append( "mount.usr=/dev/disk/by-partlabel/" + xescape( - root_partition_name( + root_partition_description( args=None, image_id=args.image_id, image_version=args.image_version, usr_only=args.usr_only ) ) diff --git a/mkosi/backend.py b/mkosi/backend.py index 31e880de5..ae02b57de 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -229,7 +229,7 @@ class Partition: part_uuid: Optional[uuid.UUID] read_only: Optional[bool] - name: str + description: str def blockdev(self, loopdev: Path) -> Path: return Path(f"{loopdev}p{self.number}") @@ -238,7 +238,7 @@ def sfdisk_spec(self) -> str: desc = [f'size={self.n_sectors}', f'type={self.type_uuid}', f'attrs={"GUID:60" if self.read_only else ""}', - f'name="{self.name}"', + f'name="{self.description}"', f'uuid={self.part_uuid}' if self.part_uuid is not None else None] return ', '.join(filter(None, desc)) @@ -280,17 +280,17 @@ def add(self, ident: PartitionIdentifier, size: int, type_uuid: uuid.UUID, - name: str, + description: str, part_uuid: Optional[uuid.UUID] = None, read_only: Optional[bool] = False) -> Partition: - assert '"' not in name + assert '"' not in description size = roundup(size, self.grain) n_sectors = size // self.sector_size part = Partition(len(self.partitions) + 1, - n_sectors, type_uuid, part_uuid, read_only, name) + n_sectors, type_uuid, part_uuid, read_only, description) self.partitions[ident] = part self.last_partition_sector = self.last_partition_offset() // self.sector_size + n_sectors