]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Combine args.force and args.force_count
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 8 Dec 2021 14:20:53 +0000 (15:20 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 8 Dec 2021 14:20:53 +0000 (15:20 +0100)
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.

mkosi/__init__.py
mkosi/backend.py
tests/test_config_parser.py

index 51226df92eb903aa5cf9a4b9b1c493ecddd84efb..05fa1fbc64b44c34f4a02e29ebf5c0a39801aa67 100644 (file)
@@ -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
index 78006f392a7c7c305de881076d798844695f2889..ede8c9fec8bf931c524127905a54f54683576515 100644 (file)
@@ -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]]
 
index 62041e965638dbb2221fbee8b9252c151a6ccb7d..88b63b0dc8573224640bd886dc2cfd132b6ba458 100644 (file)
@@ -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