config_parse_script,
config_parse_string,
make_enum_parser,
+ make_path_parser,
parse_source_target_paths,
)
from mkosi.install import (
dest="repo_dirs",
name="RepositoryDirectories",
section="Distribution",
- parse=config_make_list_parser(delimiter=",", parse=Path),
+ parse=config_make_list_parser(delimiter=",", parse=make_path_parser(required=True)),
paths=("mkosi.reposdir",),
),
MkosiConfigSetting(
MkosiConfigSetting(
dest="initrds",
section="Output",
- parse=config_make_list_parser(delimiter=",", parse=Path),
+ parse=config_make_list_parser(delimiter=",", parse=make_path_parser(required=False)),
),
MkosiConfigSetting(
dest="base_packages",
MkosiConfigSetting(
dest="extra_search_paths",
section="Host",
- parse=config_make_list_parser(delimiter=",", parse=Path),
+ parse=config_make_list_parser(delimiter=",", parse=make_path_parser(required=True)),
),
MkosiConfigSetting(
dest="qemu_gui",
def parse_source_target_paths(value: str) -> tuple[Path, Optional[Path]]:
src, _, target = value.partition(':')
+ if not Path(src).exists():
+ die(f"{src} does not exist")
if target and not Path(target).absolute():
die("Target path must be absolute")
return Path(src), Path(target) if target else None
return config_parse_list
+def make_path_parser(required: bool) -> Callable[[str], Path]:
+ def parse_path(value: str) -> Path:
+ if required and not Path(value).exists():
+ die(f"{value} does not exist")
+
+ return Path(value)
+
+ return parse_path
+
+
def config_make_path_parser(required: bool) -> ConfigParseCallback:
def config_parse_path(dest: str, value: Optional[str], namespace: argparse.Namespace) -> Optional[Path]:
if dest in namespace: