]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop --all and --all-directory 1328/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 31 Jan 2023 18:56:57 +0000 (19:56 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 1 Feb 2023 09:28:03 +0000 (10:28 +0100)
Job control should be delegated to a build system so let's drop this
from mkosi.

NEWS.md
mkosi.md
mkosi/__init__.py
mkosi/__main__.py
mkosi/backend.py
tests/test_parse_load_args.py

diff --git a/NEWS.md b/NEWS.md
index 6e793fd58d71de497fa850196d7b512fcbe491d9..3a81fcebec53f2c0c922bc71b187349250bfbb27 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -39,6 +39,8 @@
 - Removed `-stream` from CentOS release specifiers. Instead of specifying `8-stream`,
   you know just specify `8`.
 - Removed default kernel command line arguments `rhgb`, `selinux=0` and `audit=0`.
+- Dropped --all and --all-directory as this functionality is better implemented by
+  using a build system.
 
 ## v14
 
index d8337487dda7d1a81487f393025e065b1c5b7691..658a70ca2ea46379154141009dece28801801e8f 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -1057,20 +1057,6 @@ Those settings cannot be configured in the configuration files.
   wins, except for options taking lists in which case both lists are
   combined.
 
-`--all`, `-a`
-
-: Iterate through all files `mkosi.*` in the `mkosi.files/`
-  subdirectory, and build each as if `--config=mkosi.files/mkosi.…`
-  was invoked. This is a quick way to build a large number of images
-  in one go. Any additional specified command line arguments override
-  the relevant options in all files processed this way.
-
-`--all-directory=`
-
-: If specified, overrides the directory the `--all` logic described
-  above looks for settings files in. If unspecified, defaults to
-  `mkosi.files/` in the current working directory.
-
 `--incremental`, `-i`
 
 : Enable incremental build mode. This only applies if the two-phase
index 7fb943d83bddb5a8aae069aa85b88b22de12a715..caf596f0dac9411287e2814e47028f0190b1beaf 100644 (file)
@@ -2303,20 +2303,6 @@ def create_parser() -> ArgumentParserMkosi:
         type=Path,
         metavar="PATH",
     )
-    group.add_argument(
-        "-a", "--all",
-        action="store_true",
-        dest="all",
-        default=False,
-        help="Build all settings files in mkosi.files/",
-    )
-    group.add_argument(
-        "--all-directory",
-        metavar="PATH",
-        type=Path,
-        dest="all_directory",
-        help="Specify path to directory to read settings files from",
-    )
     group.add_argument(
         "-B",
         "--auto-bump",
@@ -2359,12 +2345,10 @@ def load_distribution(args: argparse.Namespace) -> argparse.Namespace:
     return args
 
 
-def parse_args(argv: Optional[Sequence[str]] = None) -> dict[str, argparse.Namespace]:
+def parse_args(argv: Optional[Sequence[str]] = None) -> argparse.Namespace:
     """Load config values from files and parse command line arguments
 
-    Do all about config files and command line arguments parsing. If --all argument is passed
-    more than one job needs to be processed. The returned tuple contains MkosiConfig
-    valid for all jobs as well as a dict containing the arguments per job.
+    Do all about config files and command line arguments parsing.
     """
     parser = create_parser()
 
@@ -2403,8 +2387,7 @@ def parse_args(argv: Optional[Sequence[str]] = None) -> dict[str, argparse.Names
     else:
         directory = Path.cwd()
 
-    # Note that directory will be ignored if .all_directory or .config_path are absolute
-    all_directory = directory / (args_pre_parsed.all_directory or "mkosi.files")
+    # Note that directory will be ignored if .config_path are absolute
     if args_pre_parsed.config_path and not directory.joinpath(args_pre_parsed.config_path).exists():
         die(f"No config file found at {directory / args_pre_parsed.config_path}")
 
@@ -2418,42 +2401,14 @@ def parse_args(argv: Optional[Sequence[str]] = None) -> dict[str, argparse.Names
     else:
         config_path = directory / "mkosi.default"
 
-    if args_pre_parsed.all and args_pre_parsed.config_path:
-        die("--all and --config= may not be combined.")
-
-    # Parse everything in --all mode
-    args_all = {}
-    if args_pre_parsed.all:
-        if not os.path.isdir(all_directory):
-            die(f"all-directory {all_directory} does not exist")
-        for f in os.scandir(all_directory):
-            if not f.name.startswith("mkosi."):
-                continue
-            args = parse_args_file(argv, Path(f.path))
-            args_all[f.name] = args
-    # Parse everything in normal mode
-    else:
-        args = parse_args_file_group(argv, config_path)
-
-        args = load_distribution(args)
-
-        if args.distribution:
-            # Parse again with any extra distribution files included.
-            args = parse_args_file_group(argv, config_path, args.distribution)
-
-        args_all["default"] = args
-
-    return args_all
-
+    args = parse_args_file_group(argv, config_path)
+    args = load_distribution(args)
 
-def parse_args_file(argv: list[str], config_path: Path) -> argparse.Namespace:
-    """Parse just one mkosi.* file (--all mode)."""
+    if args.distribution:
+        # Parse again with any extra distribution files included.
+        args = parse_args_file_group(argv, config_path, args.distribution)
 
-    # Parse all parameters handled by mkosi.
-    # Parameters forwarded to subprocesses such as nspawn or qemu end up in cmdline_argv.
-    argv = argv[:1] + [f"@{config_path}"] + argv[1:]
-
-    return create_parser().parse_args(argv)
+    return args
 
 
 def parse_args_file_group(
index fd5d7482cd19a1416daaf79876b168dcc78f74d3..c205157255dd69541cb5176ffc318d4cf25b8ff6 100644 (file)
@@ -7,7 +7,7 @@ import sys
 from collections.abc import Iterator
 from subprocess import CalledProcessError
 
-from mkosi import complete_step, parse_args, run_verb
+from mkosi import parse_args, run_verb
 from mkosi.backend import MkosiException, die
 
 
@@ -26,19 +26,13 @@ def propagate_failed_return() -> Iterator[None]:
 def main() -> None:
     args = parse_args()
 
-    for job_name, a in args.items():
-        # Change working directory if --directory is passed
-        if a.directory:
-            work_dir = a.directory
-            if os.path.isdir(work_dir):
-                os.chdir(work_dir)
-            else:
-                die(f"Error: {work_dir} is not a directory!")
-        if len(args) > 1:
-            with complete_step(f"Processing {job_name}"):
-                run_verb(a)
+    if args.directory:
+        if args.directory.isdir():
+            os.chdir(args.directory)
         else:
-            run_verb(a)
+            die(f"Error: {args.directory} is not a directory!")
+
+    run_verb(args)
 
 
 if __name__ == "__main__":
index 71174a0cb5f3c9a7933f66c8ccae609e7de16162..86536b3493efd0d8b725051813066f3a70fddbc4 100644 (file)
@@ -389,8 +389,6 @@ class MkosiConfig:
     credentials: dict[str, str]
     directory: Optional[Path]
     config_path: Optional[Path]
-    all: bool
-    all_directory: Optional[Path]
     debug: list[str]
     auto_bump: bool
     workspace_dir: Optional[Path]
index d5d33d359114fa29679b64545cdbaae0ca7e71f8..f744714af2b72b526717bd13ec0baded8e60312d 100644 (file)
@@ -15,7 +15,8 @@ from mkosi.backend import Distribution, MkosiConfig, MkosiException, Verb
 
 
 def parse(argv: Optional[List[str]] = None) -> MkosiConfig:
-    return mkosi.load_args(mkosi.parse_args(argv)["default"])
+    return mkosi.load_args(mkosi.parse_args(argv))
+
 
 @contextmanager
 def cd_temp_dir() -> Iterator[None]: