From: Daan De Meyer Date: Wed, 8 Dec 2021 14:20:53 +0000 (+0100) Subject: Combine args.force and args.force_count X-Git-Tag: v13~100^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54a353e6a6983508c854395e10dcbef1614a24cd;p=thirdparty%2Fmkosi.git Combine args.force and args.force_count args.force becomes an integer which behaves the same as a bool. args.force_count is removed and every usage of force_count is replaced by force. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 51226df92..05fa1fbc6 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -5110,7 +5110,7 @@ def create_parser() -> ArgumentParserMkosi: "-f", "--force", action="count", - dest="force_count", + dest="force", default=0, help="Remove existing image file before operation", ) @@ -5887,11 +5887,11 @@ def unlink_output(args: CommandLineArguments) -> None: # additional "--force". if args.verb == "clean": - remove_build_cache = args.force_count > 0 - remove_package_cache = args.force_count > 1 + remove_build_cache = args.force > 0 + remove_package_cache = args.force > 1 else: - remove_build_cache = args.force_count > 1 - remove_package_cache = args.force_count > 2 + remove_build_cache = args.force > 1 + remove_package_cache = args.force > 2 if remove_build_cache: if args.cache_pre_dev is not None or args.cache_pre_inst is not None: @@ -6142,8 +6142,6 @@ def load_args(args: argparse.Namespace) -> CommandLineArguments: if args.cmdline and args.verb not in MKOSI_COMMANDS_CMDLINE: die("Additional parameters only accepted for " + str(MKOSI_COMMANDS_CMDLINE)[1:-1] + " invocations.") - args.force = args.force_count > 0 - if args.output_format is None: args.output_format = OutputFormat.gpt_ext4 @@ -7144,7 +7142,7 @@ def need_cache_images(args: CommandLineArguments) -> bool: if not args.incremental: return False - if args.force_count > 1: + if args.force > 1: return True assert args.cache_pre_dev diff --git a/mkosi/backend.py b/mkosi/backend.py index 78006f392..ede8c9fec 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -363,7 +363,6 @@ class CommandLineArguments: manifest_format: List[ManifestFormat] output: Path output_dir: Optional[Path] - force_count: int bootable: bool boot_protocols: List[str] kernel_command_line: List[str] @@ -460,7 +459,7 @@ class CommandLineArguments: verity_size: Optional[int] verity_sig_size: Optional[int] machine_id: str - force: bool + force: int original_umask: int passphrase: Optional[Dict[str, str]] diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 62041e965..88b63b0dc 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -69,7 +69,7 @@ class MkosiConfig: "extra_search_paths": [], "extra_trees": [], "finalize_script": None, - "force_count": 0, + "force": 0, "gpt_first_lba": None, "home_size": None, "hostname": None, @@ -233,7 +233,7 @@ class MkosiConfig: if "Output" in mk_config_output: self.reference_config[job_name]["output"] = Path(mk_config_output["Output"]) if "Force" in mk_config_output: - self.reference_config[job_name]["force_count"] += 1 + self.reference_config[job_name]["force"] += 1 if "Bootable" in mk_config_output: self.reference_config[job_name]["bootable"] = mk_config_output["Bootable"] if "BootProtocols" in mk_config_output: @@ -736,7 +736,7 @@ class MkosiConfigManyParams(MkosiConfigOne): ref_c["distribution"] = "arch" ref_c["release"] = "7" self._append_list("repositories", "centos/repos", j) - ref_c["force_count"] += 1 + ref_c["force"] += 1 ref_c["read_only"] = False ref_c["incremental"] = True