genkey_valid_days: str
genkey_common_name: str
auto_bump: bool
- presets: list[str]
doc_format: DocFormat
@classmethod
access the value from state.
"""
+ presets: tuple[str]
dependencies: tuple[str]
distribution: Distribution
SETTINGS = (
+ MkosiConfigSetting(
+ dest="presets",
+ long="--preset",
+ section="Preset",
+ parse=config_make_list_parser(delimiter=","),
+ help="Specify which presets to build",
+ ),
MkosiConfigSetting(
dest="dependencies",
long="--dependency",
action="store_true",
default=False,
)
- parser.add_argument(
- "--preset",
- action="append",
- dest="presets",
- metavar="PRESET",
- default=[],
- help="Build the specified presets and their dependencies",
- )
parser.add_argument(
"--doc-format",
help="The format to show documentation in",
logging.warning("--cache is no longer supported")
-def resolve_deps(args: MkosiArgs, presets: Sequence[MkosiConfig]) -> list[MkosiConfig]:
+def resolve_deps(presets: Sequence[MkosiConfig], include: Sequence[str]) -> list[MkosiConfig]:
graph = {p.preset: p.dependencies for p in presets}
- if args.presets:
- if any((missing := p) not in graph for p in args.presets):
+ if include:
+ if any((missing := p) not in graph for p in include):
die(f"No preset found with name {missing}")
deps = set()
- queue = [*args.presets]
+ queue = [*include]
while queue:
if (preset := queue.pop(0)) not in deps:
if args.verb == Verb.help:
PagerHelpAction.__call__(None, argparser, namespace) # type: ignore
+ include = ()
+
if args.directory != "":
parse_config(Path("."), namespace, defaults)
+ include = getattr(namespace, "presets", ())
+
if Path("mkosi.presets").exists():
for p in Path("mkosi.presets").iterdir():
if not p.is_dir() and not p.suffix == ".conf":
backward_compat_stubs(namespace)
presets = [load_config(ns) for ns in presets]
- presets = resolve_deps(args, presets)
+ presets = resolve_deps(presets, include)
return args, tuple(presets)
each build in a series will have a version number one higher then
the previous one.
-`--preset=`
-
-: If specified, only build the given presets. Can be specified multiple
- times to build multiple presets. All the given presets and their
- dependencies are built. If not specified, all presets are built. See
- the **Presets** section for more information.
-
`--doc-format`
: The format to show the documentation in. Supports the values `markdown`,
### [Preset] Section
+`Presets=`, `--preset=`
+
+: If specified, only build the given presets. Can be specified multiple
+ times to build multiple presets. All the given presets and their
+ dependencies are built. If not specified, all presets are built. See
+ the **Presets** section for more information.
+
+: Note that this section only takes effect when specified in the global
+ configuration files. It has no effect if specified as a preset
+ specific setting.
+
`Dependencies=`, `--dependency=`
: The presets that this preset depends on specified as a comma-separated
list. All presets configured in this option will be built before this
preset and will be pulled in as dependencies of this preset when
- `--preset` is used.
+ `Presets=` is used.
### [Distribution] Section
When presets are found in `mkosi.presets/`, mkosi will build the
configured preset and its dependencies (or all of them if no presets
-were explicitly configured using `--preset=`). To add dependencies
+were explicitly configured using `Presets=`). To add dependencies
between presets, the `Dependencies=` setting can be used.
When presets are defined, mkosi will first read the global configuration